From eded6ebf648bc0ff76bcff5ddaf1d99ee4384636 Mon Sep 17 00:00:00 2001 From: D Honig Date: Sun, 11 Feb 2024 07:16:07 -0500 Subject: [PATCH] Add redfish_config command to set service identification (#7917) * Update redfish_utils.py * Update redfish_utils.py * Update redfish_config.py * Update redfish_config.py * Update redfish_config.py * Update redfish_utils.py * Create 7916-add-redfish-set-service-identification.yml * fix lint * Update redfish_utils.py * add service_id docs * Update redfish_info.py * Update plugins/modules/redfish_info.py Co-authored-by: Felix Fontein * fix conflict * fix conflict * fix conflict * fix conflict * Update redfish_utils.py * Update redfish_info.py * Update redfish_info.py * Update plugins/modules/redfish_config.py Co-authored-by: Felix Fontein --------- Co-authored-by: dh Co-authored-by: Felix Fontein --- ...add-redfish-set-service-identification.yml | 2 ++ plugins/module_utils/redfish_utils.py | 5 ++++ plugins/modules/redfish_config.py | 23 ++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/7916-add-redfish-set-service-identification.yml diff --git a/changelogs/fragments/7916-add-redfish-set-service-identification.yml b/changelogs/fragments/7916-add-redfish-set-service-identification.yml new file mode 100644 index 0000000000..2b1f2ca7b3 --- /dev/null +++ b/changelogs/fragments/7916-add-redfish-set-service-identification.yml @@ -0,0 +1,2 @@ +minor_changes: + - redfish_config - add command ``SetServiceIdentification`` to set service identification (https://github.com/ansible-collections/community.general/issues/7916). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 0d6609f8cc..262b2774d2 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -3408,6 +3408,11 @@ class RedfishUtils(object): result['ret'] = True return result + def set_service_identification(self, service_id): + data = {"ServiceIdentification": service_id} + resp = self.patch_request(self.root_uri + '/redfish/v1/Managers/' + self.resource_id, data, check_pyld=True) + return resp + def set_session_service(self, sessions_config): if sessions_config is None: return {'ret': False, 'msg': diff --git a/plugins/modules/redfish_config.py b/plugins/modules/redfish_config.py index 13b495df58..1fea9e7cd1 100644 --- a/plugins/modules/redfish_config.py +++ b/plugins/modules/redfish_config.py @@ -88,6 +88,12 @@ options: - ID of the System, Manager or Chassis to modify. type: str version_added: '0.2.0' + service_id: + required: false + description: + - ID of the manager to update. + type: str + version_added: '8.4.0' nic_addr: required: false description: @@ -334,6 +340,15 @@ EXAMPLES = ''' RAIDType: "RAID0" Drives: - "/redfish/v1/Systems/1/Storage/DE00B000/Drives/1" + + - name: Set service identification to {{ service_id }} + community.general.redfish_config: + category: Manager + command: SetServiceIdentification + service_id: "{{ service_id }}" + baseuri: "{{ baseuri }}" + username: "{{ username }}" + password: "{{ password }}" ''' RETURN = ''' @@ -353,7 +368,7 @@ from ansible.module_utils.common.text.converters import to_native CATEGORY_COMMANDS_ALL = { "Systems": ["SetBiosDefaultSettings", "SetBiosAttributes", "SetBootOrder", "SetDefaultBootOrder", "EnableSecureBoot", "SetSecureBoot", "DeleteVolumes", "CreateVolume"], - "Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface"], + "Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface", "SetServiceIdentification"], "Sessions": ["SetSessionService"], } @@ -376,6 +391,7 @@ def main(): default={} ), resource_id=dict(), + service_id=dict(), nic_addr=dict(default='null'), nic_config=dict( type='dict', @@ -445,6 +461,9 @@ def main(): # HostInterface instance ID hostinterface_id = module.params['hostinterface_id'] + # Service Identification + service_id = module.params['service_id'] + # Sessions config options sessions_config = module.params['sessions_config'] @@ -512,6 +531,8 @@ def main(): result = rf_utils.set_manager_nic(nic_addr, nic_config) elif command == "SetHostInterface": result = rf_utils.set_hostinterface_attributes(hostinterface_config, hostinterface_id) + elif command == "SetServiceIdentification": + result = rf_utils.set_service_identification(service_id) elif category == "Sessions": # execute only if we find a Sessions resource