diff --git a/shade/_tasks.py b/shade/_tasks.py index b6b319048..8b53b1816 100644 --- a/shade/_tasks.py +++ b/shade/_tasks.py @@ -17,11 +17,6 @@ from shade import task_manager -class UserPasswordUpdate(task_manager.Task): - def main(self, client): - return client.keystone_client.users.update_password(**self.args) - - class MachineCreate(task_manager.Task): def main(self, client): return client.ironic_client.node.create(**self.args) diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 270e47a63..a253b8f02 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -44,7 +44,6 @@ from shade import _legacy_clients from shade import _normalize from shade import meta from shade import task_manager -from shade import _tasks from shade import _utils OBJECT_MD5_KEY = 'x-object-meta-x-shade-md5' @@ -1012,10 +1011,12 @@ class OpenStackCloud( with _utils.shade_exceptions( "Error updating password for {user}".format( user=name_or_id)): - # normalized dict won't work - user = self.manager.submit_task(_tasks.UserPasswordUpdate( - user=self.get_user_by_id(user['id'], normalize=False), - password=password)) + error_msg = "Error updating password for user {}".format( + name_or_id) + data = self._identity_client.put( + '/users/{u}/OS-KSADM/password'.format(u=user['id']), + json={'user': {'password': password}}, + error_message=error_msg) # Identity v2.0 implements PUT. v3 PATCH. Both work as PATCH. data = self._identity_client.put( diff --git a/shade/tests/unit/test_users.py b/shade/tests/unit/test_users.py index 4923946a6..8f15c864a 100644 --- a/shade/tests/unit/test_users.py +++ b/shade/tests/unit/test_users.py @@ -98,16 +98,11 @@ class TestUsers(base.RequestsMockTestCase): self.register_uris([ # GET list to find user id - # GET user info with user_id from list # PUT user with password update - # GET user info with id after update # PUT empty update (password change is different than update) # but is always chained together [keystoneclient oddity] - # GET user info after user update dict(method='GET', uri=mock_users_uri, status_code=200, json=self._get_user_list(user_data)), - dict(method='GET', uri=mock_user_resource_uri, status_code=200, - json=user_data.json_response), dict(method='PUT', uri=self._get_keystone_mock_url( resource='users', v3=False, @@ -115,8 +110,6 @@ class TestUsers(base.RequestsMockTestCase): status_code=200, json=user_data.json_response, validate=dict( json={'user': {'password': user_data.password}})), - dict(method='GET', uri=mock_user_resource_uri, status_code=200, - json=user_data.json_response), dict(method='PUT', uri=mock_user_resource_uri, status_code=200, json=user_data.json_response, validate=dict(json={'user': {}}))])