Add UpdateUserAccountTypes command to redfish_command (#9059)

* Add UpdateUserAccountTypes command to redfish_command

https://github.com/ansible-collections/community.general/issues/9058

* Add changelog fragment

* Update changelogs/fragments/9059-redfish_command-updateuseraccounttypes.yml

Update changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
pull/9073/head
Scott Seekamp 2024-10-28 14:10:48 -06:00 committed by GitHub
parent d0b4e91cac
commit 3506f73da1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,2 @@
minor_changes:
- redfish_command - add ``UpdateUserAccountTypes`` command (https://github.com/ansible-collections/community.general/issues/9058, https://github.com/ansible-collections/community.general/pull/9059).

View File

@ -1557,6 +1557,27 @@ class RedfishUtils(object):
resp['msg'] = 'Modified account service'
return resp
def update_user_accounttypes(self, user):
account_types = user.get('account_accounttypes')
oemaccount_types = user.get('account_oemaccounttypes')
if account_types is None and oemaccount_types is None:
return {'ret': False, 'msg':
'Must provide account_accounttypes or account_oemaccounttypes for UpdateUserAccountTypes command'}
response = self._find_account_uri(username=user.get('account_username'),
acct_id=user.get('account_id'))
if not response['ret']:
return response
uri = response['uri']
payload = {}
if user.get('account_accounttypes'):
payload['AccountTypes'] = user.get('account_accounttypes')
if user.get('account_oemaccounttypes'):
payload['OEMAccountTypes'] = user.get('account_oemaccounttypes')
return self.patch_request(self.root_uri + uri, payload, check_pyld=True)
def check_password_change_required(self, return_data):
"""
Checks a response if a user needs to change their password

View File

@ -549,6 +549,18 @@ EXAMPLES = '''
AccountLockoutThreshold: 5
AccountLockoutDuration: 600
- name: Update user AccountTypes
community.general.redfish_command:
category: Accounts
command: UpdateUserAccountTypes
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
account_types:
- Redfish
- WebUI
- name: Clear Manager Logs with a timeout of 20 seconds
community.general.redfish_command:
category: Manager
@ -810,7 +822,7 @@ CATEGORY_COMMANDS_ALL = {
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
"UpdateAccountServiceProperties"],
"UpdateUserAccountTypes", "UpdateAccountServiceProperties"],
"Sessions": ["ClearSessions", "CreateSession", "DeleteSession"],
"Manager": ["GracefulRestart", "ClearLogs", "VirtualMediaInsert",
"ResetToDefaults",
@ -978,6 +990,7 @@ def main():
"UpdateUserRole": rf_utils.update_user_role,
"UpdateUserPassword": rf_utils.update_user_password,
"UpdateUserName": rf_utils.update_user_name,
"UpdateUserAccountTypes": rf_utils.update_user_accounttypes,
"UpdateAccountServiceProperties": rf_utils.update_accountservice_properties
}