From 91fe881226cff5add03b01e7a246878bc7e6d725 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:01:37 +0200 Subject: [PATCH] Add GetFirmwareVersion command to redfish_info (#4900) (#4913) * Add GetManagerInventory command to redfish_info Adding GetManagerInventory command to redfish_info, similar to GetSystemInventory to report Manager specific information like: - FirmwareVersion - Model - ManagerType Fixes #4899 * Update changelogs/fragments/4899-add-GetManagerInventory-for-redfish_info.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit 93dcd3f54da29804895a6578c0cc5a0b7d5c961a) Co-authored-by: Jacob Yundt --- ...d-GetManagerInventory-for-redfish_info.yml | 2 ++ plugins/module_utils/redfish_utils.py | 23 +++++++++++++++++++ .../remote_management/redfish/redfish_info.py | 12 +++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4899-add-GetManagerInventory-for-redfish_info.yml diff --git a/changelogs/fragments/4899-add-GetManagerInventory-for-redfish_info.yml b/changelogs/fragments/4899-add-GetManagerInventory-for-redfish_info.yml new file mode 100644 index 0000000000..68c056c485 --- /dev/null +++ b/changelogs/fragments/4899-add-GetManagerInventory-for-redfish_info.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_info - add ``GetManagerInventory`` to report list of Manager inventory information (https://github.com/ansible-collections/community.general/issues/4899). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 0c5bc1b0de..927ce231e6 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -3029,3 +3029,26 @@ class RedfishUtils(object): if not result["entries"]: return {'ret': False, 'msg': "No HostInterface objects found"} return result + + def get_manager_inventory(self, manager_uri): + result = {} + inventory = {} + # Get these entries, but does not fail if not found + properties = ['FirmwareVersion', 'ManagerType', 'Manufacturer', 'Model', + 'PartNumber', 'PowerState', 'SerialNumber', 'Status', 'UUID'] + + response = self.get_request(self.root_uri + manager_uri) + if response['ret'] is False: + return response + result['ret'] = True + data = response['data'] + + for property in properties: + if property in data: + inventory[property] = data[property] + + result["entries"] = inventory + return result + + def get_multi_manager_inventory(self): + return self.aggregate_managers(self.get_manager_inventory) diff --git a/plugins/modules/remote_management/redfish/redfish_info.py b/plugins/modules/remote_management/redfish/redfish_info.py index 886b3f7da1..3ffefd2880 100644 --- a/plugins/modules/remote_management/redfish/redfish_info.py +++ b/plugins/modules/remote_management/redfish/redfish_info.py @@ -277,6 +277,14 @@ EXAMPLES = ''' baseuri: "{{ baseuri }}" username: "{{ username }}" password: "{{ password }}" + + - name: Get Manager Inventory + community.general.redfish_info: + category: Manager + command: GetManagerInventory + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" ''' RETURN = ''' @@ -301,7 +309,7 @@ CATEGORY_COMMANDS_ALL = { "Sessions": ["GetSessions"], "Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory"], "Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs", "GetNetworkProtocols", - "GetHealthReport", "GetHostInterfaces"], + "GetHealthReport", "GetHostInterfaces", "GetManagerInventory"], } CATEGORY_COMMANDS_DEFAULT = { @@ -485,6 +493,8 @@ def main(): result["health_report"] = rf_utils.get_multi_manager_health_report() elif command == "GetHostInterfaces": result["host_interfaces"] = rf_utils.get_hostinterfaces() + elif command == "GetManagerInventory": + result["manager"] = rf_utils.get_multi_manager_inventory() # Return data back module.exit_json(redfish_facts=result)