Redfish: Added handling for trailing slashes in URIs when extracting member identifiers (#9057)
Signed-off-by: Mike Raineri <michael.raineri@dell.com>pull/9085/head
parent
9069f673e2
commit
c71f662d55
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- redfish_utils module utils - fix issue with URI parsing to gracefully handling trailing slashes when extracting member identifiers (https://github.com/ansible-collections/community.general/issues/9047, https://github.com/ansible-collections/community.general/pull/9057).
|
|
@ -695,7 +695,7 @@ class RedfishUtils(object):
|
||||||
entry[prop] = logEntry.get(prop)
|
entry[prop] = logEntry.get(prop)
|
||||||
if entry:
|
if entry:
|
||||||
list_of_log_entries.append(entry)
|
list_of_log_entries.append(entry)
|
||||||
log_name = log_svcs_uri.split('/')[-1]
|
log_name = log_svcs_uri.rstrip('/').split('/')[-1]
|
||||||
logs[log_name] = list_of_log_entries
|
logs[log_name] = list_of_log_entries
|
||||||
list_of_logs.append(logs)
|
list_of_logs.append(logs)
|
||||||
|
|
||||||
|
@ -1052,7 +1052,7 @@ class RedfishUtils(object):
|
||||||
if 'Drives' in data[u'Links']:
|
if 'Drives' in data[u'Links']:
|
||||||
for link in data[u'Links'][u'Drives']:
|
for link in data[u'Links'][u'Drives']:
|
||||||
drive_id_link = link[u'@odata.id']
|
drive_id_link = link[u'@odata.id']
|
||||||
drive_id = drive_id_link.split("/")[-1]
|
drive_id = drive_id_link.rstrip('/').split('/')[-1]
|
||||||
drive_id_list.append({'Id': drive_id})
|
drive_id_list.append({'Id': drive_id})
|
||||||
volume_result['Linked_drives'] = drive_id_list
|
volume_result['Linked_drives'] = drive_id_list
|
||||||
volume_results.append(volume_result)
|
volume_results.append(volume_result)
|
||||||
|
@ -3453,7 +3453,7 @@ class RedfishUtils(object):
|
||||||
|
|
||||||
# Capture list of URIs that match a specified HostInterface resource Id
|
# Capture list of URIs that match a specified HostInterface resource Id
|
||||||
if hostinterface_id:
|
if hostinterface_id:
|
||||||
matching_hostinterface_uris = [uri for uri in uris if hostinterface_id in uri.split('/')[-1]]
|
matching_hostinterface_uris = [uri for uri in uris if hostinterface_id in uri.rstrip('/').split('/')[-1]]
|
||||||
if hostinterface_id and matching_hostinterface_uris:
|
if hostinterface_id and matching_hostinterface_uris:
|
||||||
hostinterface_uri = list.pop(matching_hostinterface_uris)
|
hostinterface_uri = list.pop(matching_hostinterface_uris)
|
||||||
elif hostinterface_id and not matching_hostinterface_uris:
|
elif hostinterface_id and not matching_hostinterface_uris:
|
||||||
|
@ -3572,12 +3572,12 @@ class RedfishUtils(object):
|
||||||
result = {}
|
result = {}
|
||||||
if manager is None:
|
if manager is None:
|
||||||
if len(self.manager_uris) == 1:
|
if len(self.manager_uris) == 1:
|
||||||
manager = self.manager_uris[0].split('/')[-1]
|
manager = self.manager_uris[0].rstrip('/').split('/')[-1]
|
||||||
elif len(self.manager_uris) > 1:
|
elif len(self.manager_uris) > 1:
|
||||||
entries = self.get_multi_manager_inventory()['entries']
|
entries = self.get_multi_manager_inventory()['entries']
|
||||||
managers = [m[0]['manager_uri'] for m in entries if m[1].get('ServiceIdentification')]
|
managers = [m[0]['manager_uri'] for m in entries if m[1].get('ServiceIdentification')]
|
||||||
if len(managers) == 1:
|
if len(managers) == 1:
|
||||||
manager = managers[0].split('/')[-1]
|
manager = managers[0].rstrip('/').split('/')[-1]
|
||||||
else:
|
else:
|
||||||
self.module.fail_json(msg=[
|
self.module.fail_json(msg=[
|
||||||
"Multiple managers with ServiceIdentification were found: %s" % str(managers),
|
"Multiple managers with ServiceIdentification were found: %s" % str(managers),
|
||||||
|
@ -3735,7 +3735,7 @@ class RedfishUtils(object):
|
||||||
# Matching Storage Subsystem ID with user input
|
# Matching Storage Subsystem ID with user input
|
||||||
self.storage_subsystem_uri = ""
|
self.storage_subsystem_uri = ""
|
||||||
for storage_subsystem_uri in self.storage_subsystems_uris:
|
for storage_subsystem_uri in self.storage_subsystems_uris:
|
||||||
if storage_subsystem_uri.split("/")[-2] == storage_subsystem_id:
|
if storage_subsystem_uri.rstrip('/').split('/')[-1] == storage_subsystem_id:
|
||||||
self.storage_subsystem_uri = storage_subsystem_uri
|
self.storage_subsystem_uri = storage_subsystem_uri
|
||||||
|
|
||||||
if not self.storage_subsystem_uri:
|
if not self.storage_subsystem_uri:
|
||||||
|
@ -3763,7 +3763,7 @@ class RedfishUtils(object):
|
||||||
|
|
||||||
# Delete each volume
|
# Delete each volume
|
||||||
for volume in self.volume_uris:
|
for volume in self.volume_uris:
|
||||||
if volume.split("/")[-1] in volume_ids:
|
if volume.rstrip('/').split('/')[-1] in volume_ids:
|
||||||
response = self.delete_request(self.root_uri + volume)
|
response = self.delete_request(self.root_uri + volume)
|
||||||
if response['ret'] is False:
|
if response['ret'] is False:
|
||||||
return response
|
return response
|
||||||
|
@ -3797,7 +3797,7 @@ class RedfishUtils(object):
|
||||||
# Matching Storage Subsystem ID with user input
|
# Matching Storage Subsystem ID with user input
|
||||||
self.storage_subsystem_uri = ""
|
self.storage_subsystem_uri = ""
|
||||||
for storage_subsystem_uri in self.storage_subsystems_uris:
|
for storage_subsystem_uri in self.storage_subsystems_uris:
|
||||||
if storage_subsystem_uri.split("/")[-2] == storage_subsystem_id:
|
if storage_subsystem_uri.rstrip('/').split('/')[-1] == storage_subsystem_id:
|
||||||
self.storage_subsystem_uri = storage_subsystem_uri
|
self.storage_subsystem_uri = storage_subsystem_uri
|
||||||
|
|
||||||
if not self.storage_subsystem_uri:
|
if not self.storage_subsystem_uri:
|
||||||
|
|
Loading…
Reference in New Issue