Added opportunity to set extra user options.
Change-Id: I191eca8806f92c84896e776ddc8b9263f00947ae
Related-PROD: PROD-28027
(cherry picked from commit a0b79e20af97a54a24e64724d3a3feb81ef28791)
diff --git a/_states/keystoneng.py b/_states/keystoneng.py
index 82ce494..36a0d52 100644
--- a/_states/keystoneng.py
+++ b/_states/keystoneng.py
@@ -105,6 +105,7 @@
profile=None,
password_reset=True,
project=None,
+ options=None,
**connection_args):
'''
Ensure that the keystone user is present with the specified properties.
@@ -138,6 +139,9 @@
enabled
Availability state for this user
+ options
+ Dictionary of extra user options.
+
roles
The roles the user should have under given tenants.
Passed as a dictionary mapping tenant names to a list
@@ -182,6 +186,7 @@
change_enabled = False
change_tenant = False
change_password = False
+ change_options = False
if user[name].get('email', None) != email:
change_email = True
@@ -200,7 +205,15 @@
**connection_args)):
change_password = True
- if __opts__.get('test') and (change_email or change_enabled or change_tenant or change_password):
+ if options:
+ options_to_update = {option: options[option] for option in options
+ if (option not in user[name]['options'])
+ or (options[option] != user[name]['options'][option])}
+
+ if len(options_to_update):
+ change_options = True
+
+ if __opts__.get('test') and (change_email or change_enabled or change_tenant or change_password or change_options):
ret['result'] = None
ret['comment'] = 'User "{0}" will be updated'.format(name)
if change_email is True:
@@ -211,6 +224,8 @@
ret['changes']['Tenant'] = 'Will be added to "{0}" tenant'.format(tenant)
if change_password is True:
ret['changes']['Password'] = 'Will be updated'
+ if change_options is True:
+ ret['changes']['Options'] = 'Will be updated'
return ret
ret['comment'] = 'User "{0}" is already present'.format(name)
@@ -236,6 +251,11 @@
ret['comment'] = 'User "{0}" has been updated'.format(name)
ret['changes']['Password'] = 'Updated'
+ if change_options:
+ __salt__['keystoneng.user_update'](name=name, options=options_to_update, profile=profile, **connection_args)
+ ret['comment'] = 'Options has been updated'
+ ret['changes']['Options'] = options_to_update
+
if roles:
for tenant in roles:
args = dict({'user_name': name, 'tenant_name':
@@ -283,6 +303,7 @@
email=email,
tenant_id=tenant_id,
enabled=enabled,
+ options=options,
profile=profile,
**connection_args)
if roles: