Fix error with get_manager_nic_inventory method (#54553)

* Fix error with get_manager_nic_inventory function

- Function was not updated when code to handle multiple systems was added

* More elegant way to put self.manager_uri in a list
This commit is contained in:
Jose Delarosa 2019-04-01 12:11:04 -05:00 committed by John R Barker
parent aa2427573b
commit 7ddddeb801
2 changed files with 13 additions and 11 deletions

View file

@ -903,7 +903,7 @@ class RedfishUtils(object):
def get_multi_cpu_inventory(self):
return self.aggregate(self.get_cpu_inventory)
def get_nic_inventory(self, resource_type, systems_uri):
def get_nic_inventory(self, resource_uri):
result = {}
nic_list = []
nic_results = []
@ -913,12 +913,6 @@ class RedfishUtils(object):
'NameServers', 'PermanentMACAddress', 'SpeedMbps', 'MTUSize',
'AutoNeg', 'Status']
# Given resource_type, use the proper URI
if resource_type == 'Systems':
resource_uri = systems_uri
elif resource_type == 'Manager':
resource_uri = self.manager_uri
response = self.get_request(self.root_uri + resource_uri)
if response['ret'] is False:
return response
@ -959,11 +953,19 @@ class RedfishUtils(object):
def get_multi_nic_inventory(self, resource_type):
ret = True
entries = []
for systems_uri in self.systems_uris:
inventory = self.get_nic_inventory(resource_type, systems_uri)
# Given resource_type, use the proper URI
if resource_type == 'Systems':
resource_uris = self.systems_uris
elif resource_type == 'Manager':
# put in a list to match what we're doing with systems_uris
resource_uris = [self.manager_uri]
for resource_uri in resource_uris:
inventory = self.get_nic_inventory(resource_uri)
ret = inventory.pop('ret') and ret
if 'entries' in inventory:
entries.append(({'systems_uri': systems_uri},
entries.append(({'resource_uri': resource_uri},
inventory['entries']))
return dict(ret=ret, entries=entries)

View file

@ -289,7 +289,7 @@ def main():
for command in command_list:
if command == "GetManagerNicInventory":
result["manager_nics"] = rf_utils.get_multi_nic_inventory(resource_type=category)
result["manager_nics"] = rf_utils.get_multi_nic_inventory(category)
elif command == "GetLogs":
result["log"] = rf_utils.get_logs()