From 7ddddeb801b74bd1c3b8752146dfa728e5bc3306 Mon Sep 17 00:00:00 2001 From: Jose Delarosa Date: Mon, 1 Apr 2019 12:11:04 -0500 Subject: [PATCH] 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 --- lib/ansible/module_utils/redfish_utils.py | 22 ++++++++++--------- .../redfish/redfish_facts.py | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/ansible/module_utils/redfish_utils.py b/lib/ansible/module_utils/redfish_utils.py index fddb6200211..f48624f6c18 100644 --- a/lib/ansible/module_utils/redfish_utils.py +++ b/lib/ansible/module_utils/redfish_utils.py @@ -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) diff --git a/lib/ansible/modules/remote_management/redfish/redfish_facts.py b/lib/ansible/modules/remote_management/redfish/redfish_facts.py index 9330d1711e9..6ed66727891 100644 --- a/lib/ansible/modules/remote_management/redfish/redfish_facts.py +++ b/lib/ansible/modules/remote_management/redfish/redfish_facts.py @@ -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()