mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Redfish: Added support for displaying and setting account types (#6871)
* Redfish: Added support for displaying and setting account types Signed-off-by: Mike Raineri <michael.raineri@dell.com> * Update 6823-redfish-add-account-type-management.yml * CI fixes Signed-off-by: Mike Raineri <michael.raineri@dell.com> --------- Signed-off-by: Mike Raineri <michael.raineri@dell.com>
This commit is contained in:
parent
0ae8f9d631
commit
9adc82d5d1
3 changed files with 55 additions and 7 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
minor_changes:
|
||||||
|
- redfish_info - add ``AccountTypes`` and ``OEMAccountTypes`` to the output of ``ListUsers`` (https://github.com/ansible-collections/community.general/issues/6823, https://github.com/ansible-collections/community.general/pull/6871).
|
||||||
|
- redfish_command - add ``account_types`` and ``oem_account_types`` as optional inputs to ``AddUser`` (https://github.com/ansible-collections/community.general/issues/6823, https://github.com/ansible-collections/community.general/pull/6871).
|
|
@ -1140,7 +1140,8 @@ class RedfishUtils(object):
|
||||||
user_list = []
|
user_list = []
|
||||||
users_results = []
|
users_results = []
|
||||||
# Get these entries, but does not fail if not found
|
# Get these entries, but does not fail if not found
|
||||||
properties = ['Id', 'Name', 'UserName', 'RoleId', 'Locked', 'Enabled']
|
properties = ['Id', 'Name', 'UserName', 'RoleId', 'Locked', 'Enabled',
|
||||||
|
'AccountTypes', 'OEMAccountTypes']
|
||||||
|
|
||||||
response = self.get_request(self.root_uri + self.accounts_uri)
|
response = self.get_request(self.root_uri + self.accounts_uri)
|
||||||
if response['ret'] is False:
|
if response['ret'] is False:
|
||||||
|
@ -1191,6 +1192,10 @@ class RedfishUtils(object):
|
||||||
payload['Password'] = user.get('account_password')
|
payload['Password'] = user.get('account_password')
|
||||||
if user.get('account_roleid'):
|
if user.get('account_roleid'):
|
||||||
payload['RoleId'] = user.get('account_roleid')
|
payload['RoleId'] = user.get('account_roleid')
|
||||||
|
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)
|
return self.patch_request(self.root_uri + uri, payload, check_pyld=True)
|
||||||
|
|
||||||
def add_user(self, user):
|
def add_user(self, user):
|
||||||
|
@ -1221,6 +1226,10 @@ class RedfishUtils(object):
|
||||||
payload['Password'] = user.get('account_password')
|
payload['Password'] = user.get('account_password')
|
||||||
if user.get('account_roleid'):
|
if user.get('account_roleid'):
|
||||||
payload['RoleId'] = user.get('account_roleid')
|
payload['RoleId'] = user.get('account_roleid')
|
||||||
|
if user.get('account_accounttypes'):
|
||||||
|
payload['AccountTypes'] = user.get('account_accounttypes')
|
||||||
|
if user.get('account_oemaccounttypes'):
|
||||||
|
payload['OEMAccountTypes'] = user.get('account_oemaccounttypes')
|
||||||
if user.get('account_id'):
|
if user.get('account_id'):
|
||||||
payload['Id'] = user.get('account_id')
|
payload['Id'] = user.get('account_id')
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,22 @@ options:
|
||||||
description:
|
description:
|
||||||
- Role of account to add/modify.
|
- Role of account to add/modify.
|
||||||
type: str
|
type: str
|
||||||
|
account_types:
|
||||||
|
required: false
|
||||||
|
aliases: [ account_accounttypes ]
|
||||||
|
description:
|
||||||
|
- Array of account types to apply to a user account.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
version_added: '7.2.0'
|
||||||
|
oem_account_types:
|
||||||
|
required: false
|
||||||
|
aliases: [ account_oemaccounttypes ]
|
||||||
|
description:
|
||||||
|
- Array of OEM account types to apply to a user account.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
version_added: '7.2.0'
|
||||||
bootdevice:
|
bootdevice:
|
||||||
required: false
|
required: false
|
||||||
description:
|
description:
|
||||||
|
@ -380,6 +396,20 @@ EXAMPLES = '''
|
||||||
new_password: "{{ new_password }}"
|
new_password: "{{ new_password }}"
|
||||||
roleid: "{{ roleid }}"
|
roleid: "{{ roleid }}"
|
||||||
|
|
||||||
|
- name: Add user with specified account types
|
||||||
|
community.general.redfish_command:
|
||||||
|
category: Accounts
|
||||||
|
command: AddUser
|
||||||
|
baseuri: "{{ baseuri }}"
|
||||||
|
username: "{{ username }}"
|
||||||
|
password: "{{ password }}"
|
||||||
|
new_username: "{{ new_username }}"
|
||||||
|
new_password: "{{ new_password }}"
|
||||||
|
roleid: "{{ roleid }}"
|
||||||
|
account_types:
|
||||||
|
- Redfish
|
||||||
|
- WebUI
|
||||||
|
|
||||||
- name: Add user using new option aliases
|
- name: Add user using new option aliases
|
||||||
community.general.redfish_command:
|
community.general.redfish_command:
|
||||||
category: Accounts
|
category: Accounts
|
||||||
|
@ -747,6 +777,8 @@ def main():
|
||||||
new_username=dict(aliases=["account_username"]),
|
new_username=dict(aliases=["account_username"]),
|
||||||
new_password=dict(aliases=["account_password"], no_log=True),
|
new_password=dict(aliases=["account_password"], no_log=True),
|
||||||
roleid=dict(aliases=["account_roleid"]),
|
roleid=dict(aliases=["account_roleid"]),
|
||||||
|
account_types=dict(type='list', elements='str', aliases=["account_accounttypes"]),
|
||||||
|
oem_account_types=dict(type='list', elements='str', aliases=["account_oemaccounttypes"]),
|
||||||
update_username=dict(type='str', aliases=["account_updatename"]),
|
update_username=dict(type='str', aliases=["account_updatename"]),
|
||||||
account_properties=dict(type='dict', default={}),
|
account_properties=dict(type='dict', default={}),
|
||||||
bootdevice=dict(),
|
bootdevice=dict(),
|
||||||
|
@ -806,12 +838,16 @@ def main():
|
||||||
'token': module.params['auth_token']}
|
'token': module.params['auth_token']}
|
||||||
|
|
||||||
# user to add/modify/delete
|
# user to add/modify/delete
|
||||||
user = {'account_id': module.params['id'],
|
user = {
|
||||||
|
'account_id': module.params['id'],
|
||||||
'account_username': module.params['new_username'],
|
'account_username': module.params['new_username'],
|
||||||
'account_password': module.params['new_password'],
|
'account_password': module.params['new_password'],
|
||||||
'account_roleid': module.params['roleid'],
|
'account_roleid': module.params['roleid'],
|
||||||
|
'account_accounttypes': module.params['account_types'],
|
||||||
|
'account_oemaccounttypes': module.params['oem_account_types'],
|
||||||
'account_updatename': module.params['update_username'],
|
'account_updatename': module.params['update_username'],
|
||||||
'account_properties': module.params['account_properties']}
|
'account_properties': module.params['account_properties'],
|
||||||
|
}
|
||||||
|
|
||||||
# timeout
|
# timeout
|
||||||
timeout = module.params['timeout']
|
timeout = module.params['timeout']
|
||||||
|
|
Loading…
Reference in a new issue