2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-17 21:23:18 +00:00

Add get firmware information.

Show OEM firmware information in /nodes/[node]/inventory/firmware/.
This commit is contained in:
Juliana Motira 2015-08-19 08:13:55 -03:00
parent 56455fe497
commit 55c333b198
3 changed files with 40 additions and 4 deletions

View File

@ -175,6 +175,12 @@ noderesources = {
'default': 'ipmi',
}),
},
'firmware': {
'all': PluginCollection({
'pluginattrs': ['hardwaremanagement.method'],
'default': 'ipmi',
}),
},
},
'power': {
'state': PluginRoute({

View File

@ -799,6 +799,18 @@ class SensorReadings(ConfluentMessage):
self.kvpairs = {name: {'sensors': readings}}
class Firmware(ConfluentMessage):
readonly = True
def __init__(self, data, name):
self.notnode = name is None
self.desc = 'Firmware information'
if self.notnode:
self.kvpairs = {'firmware': data}
else:
self.kvpairs = {name: {'firmware': data}}
class KeyValueData(ConfluentMessage):
readonly = True

View File

@ -569,11 +569,29 @@ class IpmiHandler(object):
for component in components:
self.output.put(msg.ChildCollection(simplify_name(component)))
def list_firmware(self):
self.output.put(msg.ChildCollection('all'))
for id, data in self.ipmicmd.get_firmware():
self.output.put(msg.ChildCollection(simplify_name(id)))
def read_firmware(self, component):
items = []
for id, data in self.ipmicmd.get_firmware():
if component == 'all' or component == simplify_name(id):
items.append({id: data})
self.output.put(msg.Firmware(items, self.node))
def handle_inventory(self):
if len(self.element) == 3: # list things in inventory
return self.list_inventory()
elif len(self.element) == 4: # actually read inventory data
return self.read_inventory(self.element[-1])
if self.element[1] == 'firmware':
if len(self.element) == 3:
return self.list_firmware()
elif len(self.element) == 4:
return self.read_firmware(self.element[-1])
elif self.element[1] == 'hardware':
if len(self.element) == 3: # list things in inventory
return self.list_inventory()
elif len(self.element) == 4: # actually read inventory data
return self.read_inventory(self.element[-1])
raise Exception('Unsupported scenario...')
def read_inventory(self, component):