Skip to content

Commit 9484806

Browse files
committed
Add UpdateUserAccountTypes command to redfish_command
ansible-collections#9058
1 parent ccf7f62 commit 9484806

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

plugins/module_utils/redfish_utils.py

+24
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,30 @@ def update_accountservice_properties(self, user):
15571557
resp['msg'] = 'Modified account service'
15581558
return resp
15591559

1560+
def update_user_accounttypes(self, user):
1561+
account_types = user.get('account_accounttypes')
1562+
oemaccount_types = user.get('account_oemaccounttypes')
1563+
if account_types is None and oemaccount_types is None:
1564+
return {'ret': False, 'msg':
1565+
'Must provide account_accounttypes or account_oemaccounttypes for UpdateUserAccountTypes command'}
1566+
1567+
response = self._find_account_uri(username=user.get('account_username'),
1568+
acct_id=user.get('account_id'))
1569+
if not response['ret']:
1570+
return response
1571+
1572+
uri = response['uri']
1573+
payload = {}
1574+
if user.get('account_accounttypes'):
1575+
payload['AccountTypes'] = user.get('account_accounttypes')
1576+
if user.get('account_oemaccounttypes'):
1577+
payload['OEMAccountTypes'] = user.get('account_oemaccounttypes')
1578+
1579+
resp = self.patch_request(self.root_uri + uri, payload, check_pyld=True)
1580+
if resp['ret'] and resp['changed']:
1581+
resp['msg'] = 'Modified user account'
1582+
return resp
1583+
15601584
def check_password_change_required(self, return_data):
15611585
"""
15621586
Checks a response if a user needs to change their password

plugins/modules/redfish_command.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,18 @@
549549
AccountLockoutThreshold: 5
550550
AccountLockoutDuration: 600
551551
552+
- name: Update user AccountTypes
553+
community.general.redfish_command:
554+
category: Accounts
555+
command: UpdateUserAccountTypes
556+
baseuri: "{{ baseuri }}"
557+
username: "{{ username }}"
558+
password: "{{ password }}"
559+
account_username: "{{ account_username }}"
560+
account_types:
561+
- Redfish
562+
- WebUI
563+
552564
- name: Clear Manager Logs with a timeout of 20 seconds
553565
community.general.redfish_command:
554566
category: Manager
@@ -810,7 +822,7 @@
810822
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
811823
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
812824
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
813-
"UpdateAccountServiceProperties"],
825+
"UpdateUserAccountTypes", "UpdateAccountServiceProperties"],
814826
"Sessions": ["ClearSessions", "CreateSession", "DeleteSession"],
815827
"Manager": ["GracefulRestart", "ClearLogs", "VirtualMediaInsert",
816828
"ResetToDefaults",
@@ -978,6 +990,7 @@ def main():
978990
"UpdateUserRole": rf_utils.update_user_role,
979991
"UpdateUserPassword": rf_utils.update_user_password,
980992
"UpdateUserName": rf_utils.update_user_name,
993+
"UpdateUserAccountTypes": rf_utils.update_user_accounttypes,
981994
"UpdateAccountServiceProperties": rf_utils.update_accountservice_properties
982995
}
983996

0 commit comments

Comments
 (0)