-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Summary
I would like to review and clean redfish_utils.py to ensure it aligns with best practices for the standard. Some examples of things to cleanup:
- Simplify logic for applying new settings from a user
- Centralize vendor-specific checks/workarounds for standard management functionality
Issue Type
Feature Idea
Component Name
redfish_utils
Additional Information
Some logic I've seen copy/pasted around the module looks like a good candidate to prune/remove altogether. This block of code is a good example of the type of logic we have in the module today for many of the generic "set" routines:
for property in nic_config.keys():
value = nic_config[property]
if property not in target_ethernet_current_setting:
return {'ret': False, 'msg': "Property %s in nic_config is invalid" % property}
if isinstance(value, dict):
if isinstance(target_ethernet_current_setting[property], dict):
payload[property] = value
elif isinstance(target_ethernet_current_setting[property], list):
payload[property] = list()
payload[property].append(value)
else:
return {'ret': False, 'msg': "Value of property %s in nic_config is invalid" % property}
else:
payload[property] = value
This type of code does up-front comparisons between the API response containing the current state of the resource to change and the requested changes by the user. It performs two types of checks: does the API support the requested property and is the property of the correct format. In both cases, the API is expected to return an HTTP 400 Bad Request for either of these cases. So, this type of upfront checks really just saves us a request/response cycle. In my opinion, it's not worth adding this much bloat to the module since it can lead to future bugs if not done correctly.
There was also a recent addition to add a _get_vendor method to redfish_utils. I think this is a good thing to enhance and use in a more common manner in the module. There are some checks in various methods to perform workarounds if a given vendor or other firmware identifier is detected. Some workarounds exist today in virtual media methods for various vendors, and there is an open issue for defining a workaround for one-time boot override for a particular Dell implementation.
Code of Conduct
- I agree to follow the Ansible Code of Conduct