2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-23 01:53:28 +00:00

Merge pull request #6 from jufm/master

Treating sensors that has status = Unavailable.
This commit is contained in:
Jarrod Johnson 2015-07-29 16:49:46 -04:00
commit 7a084bf538
2 changed files with 22 additions and 27 deletions

View File

@ -748,19 +748,19 @@ class SensorReadings(ConfluentMessage):
readings = []
self.notnode = name is None
for sensor in sensors:
sensordict = {'name': sensor['name']}
if 'value' in sensor:
sensordict['value'] = sensor['value']
if 'units' in sensor:
sensordict['units'] = sensor['units']
if 'states' in sensor:
sensordict['states'] = sensor['states']
if 'state_ids' in sensor:
sensordict['state_ids'] = sensor['state_ids']
if 'health' in sensor:
sensordict['health'] = sensor['health']
if 'type' in sensor:
sensordict['type'] = sensor['type']
sensordict = {'name': sensor.name}
if hasattr(sensor, 'value'):
sensordict['value'] = sensor.value
if hasattr(sensor, 'units'):
sensordict['units'] = sensor.units
if hasattr(sensor, 'states'):
sensordict['states'] = sensor.states
if hasattr(sensor, 'state_ids'):
sensordict['state_ids'] = sensor.state_ids
if hasattr(sensor, 'health'):
sensordict['health'] = sensor.health
if hasattr(sensor, 'type'):
sensordict['type'] = sensor.type
readings.append(sensordict)
if self.notnode:
self.kvpairs = {'sensors': readings}

View File

@ -276,17 +276,6 @@ def perform_request(operator, node, element,
persistent_ipmicmds = {}
def _dict_sensor(pygreading):
retdict = {'name': pygreading.name, 'value': pygreading.value,
'states': pygreading.states, 'state_ids': pygreading.state_ids,
'units': pygreading.units,
'health': _str_health(pygreading.health),
'type': pygreading.type,
}
return retdict
class IpmiHandler(object):
def __init__(self, operation, node, element, cfd, inputdata, cfg, output):
self.sensormap = {}
@ -532,7 +521,9 @@ class IpmiHandler(object):
if ie.ipmicode == 203:
continue
raise
readings.append(_dict_sensor(reading))
if hasattr(reading, 'health'):
reading.health = _str_health(reading.health)
readings.append(reading)
self.output.put(msg.SensorReadings(readings, name=self.node))
else:
self.make_sensor_map()
@ -543,8 +534,10 @@ class IpmiHandler(object):
return
reading = self.ipmicmd.get_sensor_reading(
self.sensormap[sensorname])
if hasattr(reading, 'health'):
reading.health = _str_health(reading.health)
self.output.put(
msg.SensorReadings([_dict_sensor(reading)],
msg.SensorReadings([reading],
name=self.node))
except pygexc.IpmiException:
self.output.put(msg.ConfluentTargetTimeout(self.node))
@ -635,7 +628,9 @@ class IpmiHandler(object):
if 'badreadings' in response:
badsensors = []
for reading in response['badreadings']:
badsensors.append(_dict_sensor(reading))
if hasattr(reading, 'health'):
reading.health = _str_health(reading.health)
badsensors.append(reading)
self.output.put(msg.SensorReadings(badsensors, name=self.node))
else:
raise exc.InvalidArgumentException('health is read-only')