From 331f5bdf24bbd1d9e150c274843e83430167ac7f Mon Sep 17 00:00:00 2001 From: Patrick Pfurtscheller <57419021+PfurtschellerP@users.noreply.github.com> Date: Thu, 16 Sep 2021 22:20:49 +0200 Subject: [PATCH] redfish_utils: adding "Id" to the add user function (#3343) * Adding "Id" to the add user function Some implementations of Redfish (e.g. the one in Cisco's CIMC) seem to require the id of the new user for account creation. I'm not that firm with Python but lines 982 and 983 should fix it. * changed indention * created changelog fragment * Update changelogs/fragments/3343-redfish_utils-addUser-userId.yml Co-authored-by: Felix Fontein * Update change type * supplemented the description of the ID parameter * Update plugins/modules/remote_management/redfish/redfish_command.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- changelogs/fragments/3343-redfish_utils-addUser-userId.yml | 2 ++ plugins/module_utils/redfish_utils.py | 2 ++ plugins/modules/remote_management/redfish/redfish_command.py | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/3343-redfish_utils-addUser-userId.yml diff --git a/changelogs/fragments/3343-redfish_utils-addUser-userId.yml b/changelogs/fragments/3343-redfish_utils-addUser-userId.yml new file mode 100644 index 0000000000..7b8aa0b700 --- /dev/null +++ b/changelogs/fragments/3343-redfish_utils-addUser-userId.yml @@ -0,0 +1,2 @@ +bugfixes: + - redfish_utils module utils - if given, add account ID of user that should be created to HTTP request (https://github.com/ansible-collections/community.general/pull/3343/). diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index b4d0dba015..55686b2f50 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -979,6 +979,8 @@ class RedfishUtils(object): payload['Password'] = user.get('account_password') if user.get('account_roleid'): payload['RoleId'] = user.get('account_roleid') + if user.get('account_id'): + payload['Id'] = user.get('account_id') response = self.post_request(self.root_uri + self.accounts_uri, payload) if not response['ret']: diff --git a/plugins/modules/remote_management/redfish/redfish_command.py b/plugins/modules/remote_management/redfish/redfish_command.py index e79308f2d7..8702e468ca 100644 --- a/plugins/modules/remote_management/redfish/redfish_command.py +++ b/plugins/modules/remote_management/redfish/redfish_command.py @@ -56,7 +56,8 @@ options: required: false aliases: [ account_id ] description: - - ID of account to delete/modify + - ID of account to delete/modify. + - Can also be used in account creation to work around vendor issues where the ID of the new user is required in the POST request. type: str new_username: required: false