diff --git a/lib/ansible/module_utils/redfish_utils.py b/lib/ansible/module_utils/redfish_utils.py index 3e4abf56793..bca48be232f 100644 --- a/lib/ansible/module_utils/redfish_utils.py +++ b/lib/ansible/module_utils/redfish_utils.py @@ -967,6 +967,30 @@ class RedfishUtils(object): return response return {'ret': True, 'changed': True, 'msg': "Modified BIOS attribute"} + def get_chassis_inventory(self): + result = {} + chassis_results = [] + + # Get these entries, but does not fail if not found + properties = ['ChassisType', 'PartNumber', 'AssetTag', + 'Manufacturer', 'IndicatorLED', 'SerialNumber', 'Model'] + + # Go through list + for chassis_uri in self.chassis_uri_list: + response = self.get_request(self.root_uri + chassis_uri) + if response['ret'] is False: + return response + result['ret'] = True + data = response['data'] + chassis_result = {} + for property in properties: + if property in data: + chassis_result[property] = data[property] + chassis_results.append(chassis_result) + + result["entries"] = chassis_results + return result + def get_fan_inventory(self): result = {} fan_results = [] diff --git a/lib/ansible/modules/remote_management/redfish/redfish_facts.py b/lib/ansible/modules/remote_management/redfish/redfish_facts.py index d6935e84919..58e0149ddcd 100644 --- a/lib/ansible/modules/remote_management/redfish/redfish_facts.py +++ b/lib/ansible/modules/remote_management/redfish/redfish_facts.py @@ -137,6 +137,14 @@ EXAMPLES = ''' username: "{{ username }}" password: "{{ password }}" + - name: Get chassis inventory + redfish_facts: + category: Chassis + command: GetChassisInventory + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" + - name: Get all information available in the Manager category redfish_facts: category: Manager @@ -178,7 +186,7 @@ CATEGORY_COMMANDS_ALL = { "GetMemoryInventory", "GetNicInventory", "GetStorageControllerInventory", "GetDiskInventory", "GetBiosAttributes", "GetBootOrder", "GetBootOverride"], - "Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals"], + "Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower", "GetChassisThermals", "GetChassisInventory"], "Accounts": ["ListUsers"], "Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities"], "Manager": ["GetManagerNicInventory", "GetLogs"], @@ -293,6 +301,8 @@ def main(): result["thermals"] = rf_utils.get_chassis_thermals() elif command == "GetChassisPower": result["chassis_power"] = rf_utils.get_chassis_power() + elif command == "GetChassisInventory": + result["chassis"] = rf_utils.get_chassis_inventory() elif category == "Accounts": # execute only if we find an Account service resource