mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adding VerifyBiosAttributes functionality (#5900)
* Adding VerifyBiosAttributes functionality * Updating authors information * PR comment changes * Update plugins/modules/redfish_command.py Agreed Co-authored-by: Felix Fontein <felix@fontein.de> * Adding author as redfish maintainer * Adding changelog fragment * Update changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml Agreed Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Kushal <t-s.kushal@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
33df7b61c0
commit
49e3da3646
4 changed files with 65 additions and 3 deletions
2
.github/BOTMETA.yml
vendored
2
.github/BOTMETA.yml
vendored
|
@ -1037,7 +1037,7 @@ files:
|
||||||
maintainers: dagwieers
|
maintainers: dagwieers
|
||||||
$modules/redfish_:
|
$modules/redfish_:
|
||||||
ignore: jose-delarosa
|
ignore: jose-delarosa
|
||||||
maintainers: $team_redfish
|
maintainers: $team_redfish TSKushal
|
||||||
$modules/redhat_subscription.py:
|
$modules/redhat_subscription.py:
|
||||||
labels: redhat_subscription
|
labels: redhat_subscription
|
||||||
maintainers: barnabycourt alikins kahowell
|
maintainers: barnabycourt alikins kahowell
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- redfish_command - adding ``VerifyBiosAttributes`` functionality (https://github.com/ansible-collections/community.general/pull/5900).
|
|
@ -3163,3 +3163,38 @@ class RedfishUtils(object):
|
||||||
if resp['ret'] and resp['changed']:
|
if resp['ret'] and resp['changed']:
|
||||||
resp['msg'] = 'Modified session service'
|
resp['msg'] = 'Modified session service'
|
||||||
return resp
|
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"
|
||||||
|
}
|
||||||
|
|
|
@ -239,8 +239,16 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
version_added: 3.7.0
|
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 = '''
|
EXAMPLES = '''
|
||||||
|
@ -629,6 +637,17 @@ EXAMPLES = '''
|
||||||
category: Manager
|
category: Manager
|
||||||
command: PowerReboot
|
command: PowerReboot
|
||||||
resource_id: BMC
|
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 = '''
|
RETURN = '''
|
||||||
|
@ -662,7 +681,7 @@ from ansible.module_utils.common.text.converters import to_native
|
||||||
CATEGORY_COMMANDS_ALL = {
|
CATEGORY_COMMANDS_ALL = {
|
||||||
"Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart",
|
"Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart",
|
||||||
"PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride",
|
"PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride",
|
||||||
"IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject"],
|
"IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject", "VerifyBiosAttributes"],
|
||||||
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
|
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
|
||||||
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
|
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
|
||||||
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
|
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
|
||||||
|
@ -726,6 +745,7 @@ def main():
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
strip_etag_quotes=dict(type='bool', default=False),
|
strip_etag_quotes=dict(type='bool', default=False),
|
||||||
|
bios_attributes=dict(type="dict")
|
||||||
),
|
),
|
||||||
required_together=[
|
required_together=[
|
||||||
('username', 'password'),
|
('username', 'password'),
|
||||||
|
@ -785,6 +805,9 @@ def main():
|
||||||
# Etag options
|
# Etag options
|
||||||
strip_etag_quotes = module.params['strip_etag_quotes']
|
strip_etag_quotes = module.params['strip_etag_quotes']
|
||||||
|
|
||||||
|
# BIOS Attributes options
|
||||||
|
bios_attributes = module.params['bios_attributes']
|
||||||
|
|
||||||
# Build root URI
|
# Build root URI
|
||||||
root_uri = "https://" + module.params['baseuri']
|
root_uri = "https://" + module.params['baseuri']
|
||||||
rf_utils = RedfishUtils(creds, root_uri, timeout, module,
|
rf_utils = RedfishUtils(creds, root_uri, timeout, module,
|
||||||
|
@ -845,6 +868,8 @@ def main():
|
||||||
result = rf_utils.virtual_media_insert(virtual_media, category)
|
result = rf_utils.virtual_media_insert(virtual_media, category)
|
||||||
elif command == 'VirtualMediaEject':
|
elif command == 'VirtualMediaEject':
|
||||||
result = rf_utils.virtual_media_eject(virtual_media, category)
|
result = rf_utils.virtual_media_eject(virtual_media, category)
|
||||||
|
elif command == 'VerifyBiosAttributes':
|
||||||
|
result = rf_utils.verify_bios_attributes(bios_attributes)
|
||||||
|
|
||||||
elif category == "Chassis":
|
elif category == "Chassis":
|
||||||
result = rf_utils._find_chassis_resource()
|
result = rf_utils._find_chassis_resource()
|
||||||
|
|
Loading…
Reference in a new issue