From 63f236fcbe917a317d46267aa4db031d0fc0386b Mon Sep 17 00:00:00 2001 From: Kushal Date: Fri, 27 Jan 2023 14:50:07 +0530 Subject: [PATCH 1/7] Adding VerifyBiosAttributes functionality --- plugins/module_utils/redfish_utils.py | 35 +++++++++++++++++++++++++++ plugins/modules/redfish_command.py | 25 ++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index eadca282053..b7fda59a521 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -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" + } diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index 9d5640996ae..45c4f7debba 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -239,6 +239,12 @@ 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.1.0 author: "Jose Delarosa (@jose-delarosa)" ''' @@ -629,6 +635,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 = ''' @@ -662,7 +679,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", @@ -726,6 +743,7 @@ def main(): ) ), strip_etag_quotes=dict(type='bool', default=False), + bios_attributes=dict(type="dict") ), required_together=[ ('username', 'password'), @@ -785,6 +803,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, @@ -845,6 +866,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() From 245e1fcb25d76e1b9a0a5fdac30d84b4b9add123 Mon Sep 17 00:00:00 2001 From: Kushal Date: Fri, 27 Jan 2023 14:57:24 +0530 Subject: [PATCH 2/7] Updating authors information --- .github/BOTMETA.yml | 2 +- plugins/modules/redfish_command.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 2051e34e0a1..5a73efcf10a 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -1036,7 +1036,7 @@ files: $modules/read_csv.py: maintainers: dagwieers $modules/redfish_: - ignore: jose-delarosa + ignore: jose-delarosa varini-hp prativa-n Gayathirideviramasamy TSKushal maintainers: $team_redfish $modules/redhat_subscription.py: labels: redhat_subscription diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index 45c4f7debba..d3969737efa 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -246,7 +246,12 @@ type: dict version_added: 6.1.0 -author: "Jose Delarosa (@jose-delarosa)" +author: + - "Jose Delarosa (@jose-delarosa)" + - "Gayathiri Devi Ramasamy (@Gayathirideviramasamy)" + - "T S Kushal (@TSKushal)" + - "Varni H P (@varini-hp)" + - "Prativa Nayak (@prativa-n)" ''' EXAMPLES = ''' From c829ff79959dce943b92ed4203f6e3da08cce436 Mon Sep 17 00:00:00 2001 From: Kushal Date: Mon, 30 Jan 2023 15:42:35 +0530 Subject: [PATCH 3/7] PR comment changes --- .github/BOTMETA.yml | 2 +- plugins/modules/redfish_command.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index 5a73efcf10a..f8420b2f796 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -1036,7 +1036,7 @@ files: $modules/read_csv.py: maintainers: dagwieers $modules/redfish_: - ignore: jose-delarosa varini-hp prativa-n Gayathirideviramasamy TSKushal + ignore: jose-delarosa TSKushal maintainers: $team_redfish $modules/redhat_subscription.py: labels: redhat_subscription diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index d3969737efa..a8c848e6b35 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -244,14 +244,11 @@ description: - BIOS attributes that needs to be verified in the given server type: dict - version_added: 6.1.0 + version_added: 6.4.0 author: - "Jose Delarosa (@jose-delarosa)" - - "Gayathiri Devi Ramasamy (@Gayathirideviramasamy)" - "T S Kushal (@TSKushal)" - - "Varni H P (@varini-hp)" - - "Prativa Nayak (@prativa-n)" ''' EXAMPLES = ''' From 130fd987676363b581412396ad65a938ecef3ba1 Mon Sep 17 00:00:00 2001 From: TSKushal <44438079+TSKushal@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:04:35 +0530 Subject: [PATCH 4/7] Update plugins/modules/redfish_command.py Agreed Co-authored-by: Felix Fontein --- plugins/modules/redfish_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index a8c848e6b35..ac19fb0e2be 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -242,7 +242,7 @@ bios_attributes: required: false description: - - BIOS attributes that needs to be verified in the given server + - BIOS attributes that needs to be verified in the given server. type: dict version_added: 6.4.0 From 63083de5e9962313c69cfca18de6314388ea0f77 Mon Sep 17 00:00:00 2001 From: Kushal Date: Mon, 13 Feb 2023 12:22:14 +0530 Subject: [PATCH 5/7] Adding author as redfish maintainer --- .github/BOTMETA.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml index f8420b2f796..b0e0c8097b8 100644 --- a/.github/BOTMETA.yml +++ b/.github/BOTMETA.yml @@ -1036,8 +1036,8 @@ files: $modules/read_csv.py: maintainers: dagwieers $modules/redfish_: - ignore: jose-delarosa TSKushal - maintainers: $team_redfish + ignore: jose-delarosa + maintainers: $team_redfish TSKushal $modules/redhat_subscription.py: labels: redhat_subscription maintainers: barnabycourt alikins kahowell From d5ca420b91fdd4f161633c03f544550889a6c66f Mon Sep 17 00:00:00 2001 From: Kushal Date: Wed, 15 Feb 2023 23:14:42 +0530 Subject: [PATCH 6/7] Adding changelog fragment --- ...ing-verifybiosattribute-fucntionality-to-redfish-command.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml diff --git a/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml b/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml new file mode 100644 index 00000000000..d536be58561 --- /dev/null +++ b/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_command module - adding VerifyBiosAttributes functionality (https://github.com/ansible-collections/community.general/pull/5900). From 11ad062e4a57fbd9a83c87746aa15180f21ee03a Mon Sep 17 00:00:00 2001 From: TSKushal <44438079+TSKushal@users.noreply.github.com> Date: Thu, 16 Feb 2023 15:27:02 +0530 Subject: [PATCH 7/7] Update changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml Agreed Co-authored-by: Felix Fontein --- ...ing-verifybiosattribute-fucntionality-to-redfish-command.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml b/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml index d536be58561..bbbb4645348 100644 --- a/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml +++ b/changelogs/fragments/5900-adding-verifybiosattribute-fucntionality-to-redfish-command.yml @@ -1,2 +1,2 @@ minor_changes: - - redfish_command module - adding VerifyBiosAttributes functionality (https://github.com/ansible-collections/community.general/pull/5900). + - redfish_command - adding ``VerifyBiosAttributes`` functionality (https://github.com/ansible-collections/community.general/pull/5900).