2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Mitigate performance impact of oem sensors

The sensormap was being regenerated each time a sensor
was asked for.  Make the sensor map
a more perisstent fixture.
This commit is contained in:
Jarrod Johnson 2019-06-12 14:47:28 -04:00
parent 2a72a6184d
commit b2013e93c5
2 changed files with 7 additions and 6 deletions

View File

@ -59,7 +59,7 @@ def install_license(session, filename):
instargs = {'filename': filename}
for res in session.create(resource, instargs):
pass # print(repr(res))
show_licenses()
show_licenses(session)
def show_licenses(session):
global exitcode

View File

@ -171,6 +171,7 @@ class IpmiCommandWrapper(ipmicommand.Command):
def __init__(self, node, cfm, **kwargs):
self.cfm = cfm
self.node = node
self.sensormap = {}
self._inhealth = False
self._lasthealth = None
kwargs['keepalive'] = False
@ -443,7 +444,6 @@ persistent_ipmicmds = {}
class IpmiHandler(object):
def __init__(self, operation, node, element, cfd, inputdata, cfg, output,
realop):
self.sensormap = {}
self.invmap = {}
self.output = output
self.sensorcategory = None
@ -800,7 +800,7 @@ class IpmiHandler(object):
sensors = self.ipmicmd.get_sensor_descriptions()
for sensor in sensors:
resourcename = sensor['name']
self.sensormap[simplify_name(resourcename)] = resourcename
self.ipmicmd.sensormap[simplify_name(resourcename)] = resourcename
def read_sensors(self, sensorname):
if sensorname == 'all':
@ -821,15 +821,16 @@ class IpmiHandler(object):
readings.append(reading)
self.output.put(msg.SensorReadings(readings, name=self.node))
else:
self.make_sensor_map()
if sensorname not in self.sensormap:
if sensorname not in self.ipmicmd.sensormap:
self.make_sensor_map()
if sensorname not in self.ipmicmd.sensormap:
self.output.put(
msg.ConfluentTargetNotFound(self.node,
'Sensor not found'))
return
try:
reading = self.ipmicmd.get_sensor_reading(
self.sensormap[sensorname])
self.ipmicmd.sensormap[sensorname])
if hasattr(reading, 'health'):
reading.health = _str_health(reading.health)
self.output.put(