2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 19:22:05 +00:00

OpenBMC rinv more specific REST calls

This commit is contained in:
Mark Gurevich 2018-05-09 10:56:49 -04:00
parent 175b7f1289
commit a06e3cc850
3 changed files with 24 additions and 10 deletions

View File

@ -528,7 +528,7 @@ class OpenBMCFlashTask(ParallelNodesCommand):
try:
obmc.login()
# Before uploading file, check CPU DD version
inventory_info_dict = obmc.get_inventory_info()
inventory_info_dict = obmc.get_inventory_info('cpu')
cpu_info = inventory_info_dict["CPU"]
for info in cpu_info:
if info.startswith("CPU0 Version : 20"):

View File

@ -83,7 +83,7 @@ class OpenBMCInventoryTask(ParallelNodesCommand):
inventory_info = []
try:
obmc.login()
inventory_info_dict = obmc.get_inventory_info()
inventory_info_dict = obmc.get_inventory_info(inventory_type)
if inventory_type == 'all' or not inventory_type:
keys = inventory_info_dict.keys()

View File

@ -49,7 +49,13 @@ DUMP_URLS = {
GARD_CLEAR_URL = "/org/open_power/control/gard/action/Reset"
INVENTORY_URL = "/inventory/enumerate"
INVENTORY_URLS = {
"all" : "/inventory/enumerate",
"model" : "/inventory/system",
"serial" : "/inventory/system",
"cpu" : "/inventory/system/chassis/motherboard/enumerate",
"dimm" : "/inventory/system/chassis/motherboard/enumerate",
}
LEDS_URL = "/led/physical/enumerate"
@ -546,11 +552,19 @@ class OpenBMCRest(object):
error = 'Received wrong format response: %s' % sensor_data
raise SelfServerException(error)
def get_inventory_info(self):
def get_inventory_info(self, inventory_type):
inventory_data = self.request('GET', INVENTORY_URL, cmd='get_inventory_info')
inventory_data = self.request('GET', INVENTORY_URLS[inventory_type], cmd='get_inventory_info')
try:
inverntory_dict = {}
inventory_dict = {}
if inventory_type == 'model' or inventory_type == 'serial':
# The format of returned data for model and serial a different from other inventory types
inventory_dict['SYSTEM'] = []
for key, value in inventory_data.items():
inventory_dict['SYSTEM'].append('%s %s : %s' % ("SYSTEM", key, value))
return inventory_dict
for key, value in inventory_data.items():
if 'Present' not in value:
logger.debug('Not "Present" for %s' % key)
@ -572,13 +586,13 @@ class OpenBMCRest(object):
else:
source = key_id
if key_type not in inverntory_dict:
inverntory_dict[key_type] = []
if key_type not in inventory_dict:
inventory_dict[key_type] = []
for (sub_key, v) in value.items():
inverntory_dict[key_type].append('%s %s : %s' % (source.upper(), sub_key, v))
inventory_dict[key_type].append('%s %s : %s' % (source.upper(), sub_key, v))
return inverntory_dict
return inventory_dict
except KeyError:
error = 'Received wrong format response: %s' % inventory_data
raise SelfServerException(error)