Convert heat_keystoneclient user enable/disable logic to v3 API

Migrate the enable_stack_user and disable_stack_user functions
to use the v3 API.

Change-Id: Ieebc94cf09ba952d0ec0499091ba52906d6fe9cb
blueprint: keystone-v3-only
This commit is contained in:
Steven Hardy 2014-01-13 16:57:14 +00:00
parent 72756bef6a
commit d6b777e126
2 changed files with 36 additions and 4 deletions

View File

@ -283,12 +283,10 @@ class KeystoneClient(object):
return self.client_v2.ec2.create(uid, self.context.tenant_id)
def disable_stack_user(self, user_id):
# FIXME : This won't work with the v3 keystone API
self.client_v2.users.update_enabled(user_id, False)
self.client_v3.users.update(user=user_id, enabled=False)
def enable_stack_user(self, user_id):
# FIXME : This won't work with the v3 keystone API
self.client_v2.users.update_enabled(user_id, True)
self.client_v3.users.update(user=user_id, enabled=True)
def url_for(self, **kwargs):
return self.client_v2.service_catalog.url_for(**kwargs)

View File

@ -415,3 +415,37 @@ class KeystoneClientTest(HeatTestCase):
ctx = utils.dummy_context()
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
self.assertIsNone(heat_ks_client.delete_trust(trust_id='atrust123'))
def test_disable_stack_user(self):
"""Test disabling a stack user."""
self._stubs_v3()
ctx = utils.dummy_context()
ctx.trust_id = None
# mock keystone client update function
self.mock_ks_v3_client.users = self.m.CreateMockAnything()
self.mock_ks_v3_client.users.update(user='atestuser', enabled=False
).AndReturn(None)
self.m.ReplayAll()
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
heat_ks_client.disable_stack_user('atestuser')
def test_enable_stack_user(self):
"""Test enabling a stack user."""
self._stubs_v3()
ctx = utils.dummy_context()
ctx.trust_id = None
# mock keystone client update function
self.mock_ks_v3_client.users = self.m.CreateMockAnything()
self.mock_ks_v3_client.users.update(user='atestuser', enabled=True
).AndReturn(None)
self.m.ReplayAll()
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
heat_ks_client.enable_stack_user('atestuser')