mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
* modified redfish_config and idrac_redfish_config to skip incorrect attributes
Signed-off-by: Trevor Squillario Trevor_Squillario@Dell.com
* modified redfish_utils.py and idrac_redfish_config.py to return empty warning message
* modified redfish_config.py and idrac_redfish_config.py to use module.warn()
* updated changelog fragment for pr 2334
(cherry picked from commit 9d46ccf1b2
)
Co-authored-by: TrevorSquillario <72882537+TrevorSquillario@users.noreply.github.com>
This commit is contained in:
parent
e05769d4bf
commit
3539957bac
4 changed files with 47 additions and 12 deletions
|
@ -1671,19 +1671,31 @@ class RedfishUtils(object):
|
|||
|
||||
# Make a copy of the attributes dict
|
||||
attrs_to_patch = dict(attributes)
|
||||
# List to hold attributes not found
|
||||
attrs_bad = {}
|
||||
|
||||
# Check the attributes
|
||||
for attr in attributes:
|
||||
if attr not in data[u'Attributes']:
|
||||
return {'ret': False, 'msg': "BIOS attribute %s not found" % attr}
|
||||
for attr_name, attr_value in attributes.items():
|
||||
# Check if attribute exists
|
||||
if attr_name not in data[u'Attributes']:
|
||||
# Remove and proceed to next attribute if this isn't valid
|
||||
attrs_bad.update({attr_name: attr_value})
|
||||
del attrs_to_patch[attr_name]
|
||||
continue
|
||||
|
||||
# If already set to requested value, remove it from PATCH payload
|
||||
if data[u'Attributes'][attr] == attributes[attr]:
|
||||
del attrs_to_patch[attr]
|
||||
if data[u'Attributes'][attr_name] == attributes[attr_name]:
|
||||
del attrs_to_patch[attr_name]
|
||||
|
||||
warning = ""
|
||||
if attrs_bad:
|
||||
warning = "Incorrect attributes %s" % (attrs_bad)
|
||||
|
||||
# Return success w/ changed=False if no attrs need to be changed
|
||||
if not attrs_to_patch:
|
||||
return {'ret': True, 'changed': False,
|
||||
'msg': "BIOS attributes already set"}
|
||||
'msg': "BIOS attributes already set",
|
||||
'warning': warning}
|
||||
|
||||
# Get the SettingsObject URI
|
||||
set_bios_attr_uri = data["@Redfish.Settings"]["SettingsObject"]["@odata.id"]
|
||||
|
@ -1693,7 +1705,9 @@ class RedfishUtils(object):
|
|||
response = self.patch_request(self.root_uri + set_bios_attr_uri, payload)
|
||||
if response['ret'] is False:
|
||||
return response
|
||||
return {'ret': True, 'changed': True, 'msg': "Modified BIOS attribute"}
|
||||
return {'ret': True, 'changed': True,
|
||||
'msg': "Modified BIOS attributes %s" % (attrs_to_patch),
|
||||
'warning': warning}
|
||||
|
||||
def set_boot_order(self, boot_list):
|
||||
if not boot_list:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue