Skip to content

Commit

Permalink
Add GetFirmwareVersion command to redfish_info (ansible-collections#4900
Browse files Browse the repository at this point in the history
)

* 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 ansible-collections#4899

* Update changelogs/fragments/4899-add-GetManagerInventory-for-redfish_info.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
  • Loading branch information
2 people authored and Dušan Markovič committed Nov 7, 2022
1 parent cbcaa4d commit 19651be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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).
23 changes: 23 additions & 0 deletions plugins/module_utils/redfish_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3029,3 +3029,26 @@ def get_hostinterfaces(self):
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)
12 changes: 11 additions & 1 deletion plugins/modules/remote_management/redfish/redfish_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@
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 = '''
Expand All @@ -301,7 +309,7 @@
"Sessions": ["GetSessions"],
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory"],
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs", "GetNetworkProtocols",
"GetHealthReport", "GetHostInterfaces"],
"GetHealthReport", "GetHostInterfaces", "GetManagerInventory"],
}

CATEGORY_COMMANDS_DEFAULT = {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 19651be

Please sign in to comment.