Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow DMTF redfish deprecation on StorageControllers #7081

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- redfish_utils - use ``Controllers`` key in redfish data to obtain Storage controllers properties (https://github.com/ansible-collections/community.general/pull/7081).
66 changes: 54 additions & 12 deletions plugins/module_utils/redfish_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ def get_storage_controller_inventory(self, systems_uri):
properties = ['CacheSummary', 'FirmwareVersion', 'Identifiers',
'Location', 'Manufacturer', 'Model', 'Name', 'Id',
'PartNumber', 'SerialNumber', 'SpeedGbps', 'Status']
key = "StorageControllers"
key = "Controllers"
deprecated_key = "StorageControllers"

# Find Storage service
response = self.get_request(self.root_uri + systems_uri)
Expand Down Expand Up @@ -745,7 +746,30 @@ def get_storage_controller_inventory(self, systems_uri):
data = response['data']

if key in data:
controller_list = data[key]
controllers_uri = data[key][u'@odata.id']

response = self.get_request(self.root_uri + controllers_uri)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']

if data[u'Members']:
for controller_member in data[u'Members']:
controller_member_uri = controller_member[u'@odata.id']
response = self.get_request(self.root_uri + controller_member_uri)
if response['ret'] is False:
return response
result['ret'] = True
data = response['data']

controller_result = {}
for property in properties:
if property in data:
controller_result[property] = data[property]
controller_results.append(controller_result)
elif deprecated_key in data:
controller_list = data[deprecated_key]
for controller in controller_list:
controller_result = {}
for property in properties:
Expand Down Expand Up @@ -800,7 +824,25 @@ def get_disk_inventory(self, systems_uri):
return response
data = response['data']
controller_name = 'Controller 1'
if 'StorageControllers' in data:
if 'Controllers' in data:
controllers_uri = data['Controllers'][u'@odata.id']

response = self.get_request(self.root_uri + controllers_uri)
if response['ret'] is False:
return response
result['ret'] = True
cdata = response['data']

if cdata[u'Members']:
controller_member_uri = cdata[u'Members'][0][u'@odata.id']

response = self.get_request(self.root_uri + controller_member_uri)
if response['ret'] is False:
return response
result['ret'] = True
cdata = response['data']
controller_name = cdata['Name']
elif 'StorageControllers' in data:
sc = data['StorageControllers']
if sc:
if 'Name' in sc[0]:
Expand Down Expand Up @@ -904,15 +946,7 @@ def get_volume_inventory(self, systems_uri):
return response
data = response['data']
controller_name = 'Controller %s' % str(idx)
if 'StorageControllers' in data:
sc = data['StorageControllers']
if sc:
if 'Name' in sc[0]:
controller_name = sc[0]['Name']
else:
sc_id = sc[0].get('Id', '1')
controller_name = 'Controller %s' % sc_id
elif 'Controllers' in data:
if 'Controllers' in data:
response = self.get_request(self.root_uri + data['Controllers'][u'@odata.id'])
if response['ret'] is False:
return response
Expand All @@ -930,6 +964,14 @@ def get_volume_inventory(self, systems_uri):
else:
controller_id = member_data.get('Id', '1')
controller_name = 'Controller %s' % controller_id
elif 'StorageControllers' in data:
sc = data['StorageControllers']
if sc:
if 'Name' in sc[0]:
controller_name = sc[0]['Name']
else:
sc_id = sc[0].get('Id', '1')
controller_name = 'Controller %s' % sc_id
volume_results = []
volume_list = []
if 'Volumes' in data:
Expand Down