-
-
Save gtmanfred/498bf1b2dfe75dc36c94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_user(self, name_or_id, **kwargs): | |
self.list_users.invalidate(self) | |
user = self.get_user(name_or_id) | |
# normalized dict won't work | |
kwargs['user'] = self.get_user_by_id(user['id'], normalize=False) | |
password = None | |
if self.cloud_config.get_api_version('identity') != '3': | |
# Do not pass v3 args to a v2 keystone. | |
kwargs.pop('domain_id', None) | |
password = kwargs.pop('password', None) | |
kwargs.pop('description', None) | |
kwargs.pop('default_project', None) | |
elif 'domain_id' in kwargs: | |
# The incoming parameter is domain_id in order to match the | |
# parameter name in create_user(), but UserUpdate() needs it | |
# to be domain. | |
kwargs['domain'] = kwargs.pop('domain_id') | |
with _utils.shade_exceptions("Error in updating user {user}".format( | |
user=name_or_id)): | |
user = self.manager.submitTask(_tasks.UserUpdate(**kwargs)) | |
if password is not None: | |
with _utils.shade_exceptions( | |
"Error updating password for {user}".format( | |
user=name_or_id)): | |
user = self.manager.submitTask(_tasks.UserPasswordUpdate( | |
user=user.id, password=password)) | |
self.list_users.invalidate(self) | |
return _utils.normalize_users([user])[0] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment