mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-20 09:21:24 -07:00
Add redfish_info command to get service identification (#7883)
* Update redfish_info.py * Create 7882-add-redfish-get-service-identification.yml * add get_service_identification * Update changelogs/fragments/7882-add-redfish-get-service-identification.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
44028060c3
commit
5a51929aa3
3 changed files with 49 additions and 2 deletions
|
@ -3365,7 +3365,8 @@ class RedfishUtils(object):
|
|||
inventory = {}
|
||||
# Get these entries, but does not fail if not found
|
||||
properties = ['Id', 'FirmwareVersion', 'ManagerType', 'Manufacturer', 'Model',
|
||||
'PartNumber', 'PowerState', 'SerialNumber', 'Status', 'UUID']
|
||||
'PartNumber', 'PowerState', 'SerialNumber', 'ServiceIdentification',
|
||||
'Status', 'UUID']
|
||||
|
||||
response = self.get_request(self.root_uri + manager_uri)
|
||||
if response['ret'] is False:
|
||||
|
@ -3383,6 +3384,30 @@ class RedfishUtils(object):
|
|||
def get_multi_manager_inventory(self):
|
||||
return self.aggregate_managers(self.get_manager_inventory)
|
||||
|
||||
def get_service_identification(self, manager):
|
||||
result = {}
|
||||
if manager is None:
|
||||
if len(self.manager_uris) == 1:
|
||||
manager = self.manager_uris[0].split('/')[-1]
|
||||
elif len(self.manager_uris) > 1:
|
||||
entries = self.get_multi_manager_inventory()['entries']
|
||||
managers = [m[0]['manager_uri'] for m in entries if m[1].get('ServiceIdentification')]
|
||||
if len(managers) == 1:
|
||||
manager = managers[0].split('/')[-1]
|
||||
else:
|
||||
self.module.fail_json(msg=[
|
||||
"Multiple managers with ServiceIdentification were found: %s" % str(managers),
|
||||
"Please specify by using the 'manager' parameter in your playbook"])
|
||||
elif len(self.manager_uris) == 0:
|
||||
self.module.fail_json(msg="No manager identities were found")
|
||||
response = self.get_request(self.root_uri + '/redfish/v1/Managers/' + manager, override_headers=None)
|
||||
try:
|
||||
result['service_identification'] = response['data']['ServiceIdentification']
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="Service ID not found for manager %s" % manager)
|
||||
result['ret'] = True
|
||||
return result
|
||||
|
||||
def set_session_service(self, sessions_config):
|
||||
if sessions_config is None:
|
||||
return {'ret': False, 'msg':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue