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

Adding VerifyBiosAttributes functionality #5900

Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .github/BOTMETA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ files:
maintainers: dagwieers
$modules/redfish_:
ignore: jose-delarosa
maintainers: $team_redfish
maintainers: $team_redfish TSKushal
$modules/redhat_subscription.py:
labels: redhat_subscription
maintainers: barnabycourt alikins kahowell
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- redfish_command module - adding VerifyBiosAttributes functionality (https://github.com/ansible-collections/community.general/pull/5900).
TSKushal marked this conversation as resolved.
Show resolved Hide resolved
35 changes: 35 additions & 0 deletions plugins/module_utils/redfish_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3163,3 +3163,38 @@ def set_session_service(self, sessions_config):
if resp['ret'] and resp['changed']:
resp['msg'] = 'Modified session service'
return resp

def verify_bios_attributes(self, bios_attributes):
# This method verifies BIOS attributes against the provided input
server_bios = self.get_multi_bios_attributes()
if server_bios["ret"] is False:
return server_bios

bios_dict = {}
wrong_param = {}

# Verify bios_attributes with BIOS settings available in the server
for key, value in bios_attributes.items():
if key in server_bios["entries"][0][1]:
if server_bios["entries"][0][1][key] != value:
bios_dict.update({key: value})
else:
wrong_param.update({key: value})

if wrong_param:
return {
"ret": False,
"msg": "Wrong parameters are provided: %s" % wrong_param
}

if bios_dict:
return {
"ret": False,
"msg": "BIOS parameters are not matching: %s" % bios_dict
}

return {
"ret": True,
"changed": False,
"msg": "BIOS verification completed"
}
29 changes: 27 additions & 2 deletions plugins/modules/redfish_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,16 @@
type: bool
default: false
version_added: 3.7.0
bios_attributes:
required: false
description:
- BIOS attributes that needs to be verified in the given server.
type: dict
version_added: 6.4.0

author: "Jose Delarosa (@jose-delarosa)"
author:
- "Jose Delarosa (@jose-delarosa)"
- "T S Kushal (@TSKushal)"
'''

EXAMPLES = '''
Expand Down Expand Up @@ -629,6 +637,17 @@
category: Manager
command: PowerReboot
resource_id: BMC

- name: Verify BIOS attributes
community.general.redfish_command:
category: Systems
command: VerifyBiosAttributes
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
bios_attributes:
SubNumaClustering: "Disabled"
WorkloadProfile: "Virtualization-MaxPerformance"
'''

RETURN = '''
Expand Down Expand Up @@ -662,7 +681,7 @@
CATEGORY_COMMANDS_ALL = {
"Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart",
"PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride",
"IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject"],
"IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject", "VerifyBiosAttributes"],
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
Expand Down Expand Up @@ -726,6 +745,7 @@ def main():
)
),
strip_etag_quotes=dict(type='bool', default=False),
bios_attributes=dict(type="dict")
),
required_together=[
('username', 'password'),
Expand Down Expand Up @@ -785,6 +805,9 @@ def main():
# Etag options
strip_etag_quotes = module.params['strip_etag_quotes']

# BIOS Attributes options
bios_attributes = module.params['bios_attributes']

# Build root URI
root_uri = "https://" + module.params['baseuri']
rf_utils = RedfishUtils(creds, root_uri, timeout, module,
Expand Down Expand Up @@ -845,6 +868,8 @@ def main():
result = rf_utils.virtual_media_insert(virtual_media, category)
elif command == 'VirtualMediaEject':
result = rf_utils.virtual_media_eject(virtual_media, category)
elif command == 'VerifyBiosAttributes':
result = rf_utils.verify_bios_attributes(bios_attributes)

elif category == "Chassis":
result = rf_utils._find_chassis_resource()
Expand Down