Merge "Fix mixin class clients"

This commit is contained in:
Jenkins 2015-10-28 10:14:53 +00:00 committed by Gerrit Code Review
commit 9fcfdf8558
2 changed files with 11 additions and 11 deletions

View File

@ -96,13 +96,13 @@ class KeystoneRoleAssignmentMixin(object):
def _add_role_assignments_to_group(self, group_id, role_assignments): def _add_role_assignments_to_group(self, group_id, role_assignments):
for role_assignment in self._normalize_to_id(role_assignments): for role_assignment in self._normalize_to_id(role_assignments):
if role_assignment.get(self.PROJECT) is not None: if role_assignment.get(self.PROJECT) is not None:
self.client().client.roles.grant( self.client().roles.grant(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
project=role_assignment.get(self.PROJECT), project=role_assignment.get(self.PROJECT),
group=group_id group=group_id
) )
elif role_assignment.get(self.DOMAIN) is not None: elif role_assignment.get(self.DOMAIN) is not None:
self.client().client.roles.grant( self.client().roles.grant(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
domain=role_assignment.get(self.DOMAIN), domain=role_assignment.get(self.DOMAIN),
group=group_id group=group_id
@ -111,13 +111,13 @@ class KeystoneRoleAssignmentMixin(object):
def _add_role_assignments_to_user(self, user_id, role_assignments): def _add_role_assignments_to_user(self, user_id, role_assignments):
for role_assignment in self._normalize_to_id(role_assignments): for role_assignment in self._normalize_to_id(role_assignments):
if role_assignment.get(self.PROJECT) is not None: if role_assignment.get(self.PROJECT) is not None:
self.client().client.roles.grant( self.client().roles.grant(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
project=role_assignment.get(self.PROJECT), project=role_assignment.get(self.PROJECT),
user=user_id user=user_id
) )
elif role_assignment.get(self.DOMAIN) is not None: elif role_assignment.get(self.DOMAIN) is not None:
self.client().client.roles.grant( self.client().roles.grant(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
domain=role_assignment.get(self.DOMAIN), domain=role_assignment.get(self.DOMAIN),
user=user_id user=user_id
@ -126,13 +126,13 @@ class KeystoneRoleAssignmentMixin(object):
def _remove_role_assignments_from_group(self, group_id, role_assignments): def _remove_role_assignments_from_group(self, group_id, role_assignments):
for role_assignment in self._normalize_to_id(role_assignments): for role_assignment in self._normalize_to_id(role_assignments):
if role_assignment.get(self.PROJECT) is not None: if role_assignment.get(self.PROJECT) is not None:
self.client().client.roles.revoke( self.client().roles.revoke(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
project=role_assignment.get(self.PROJECT), project=role_assignment.get(self.PROJECT),
group=group_id group=group_id
) )
elif role_assignment.get(self.DOMAIN) is not None: elif role_assignment.get(self.DOMAIN) is not None:
self.client().client.roles.revoke( self.client().roles.revoke(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
domain=role_assignment.get(self.DOMAIN), domain=role_assignment.get(self.DOMAIN),
group=group_id group=group_id
@ -141,13 +141,13 @@ class KeystoneRoleAssignmentMixin(object):
def _remove_role_assignments_from_user(self, user_id, role_assignments): def _remove_role_assignments_from_user(self, user_id, role_assignments):
for role_assignment in self._normalize_to_id(role_assignments): for role_assignment in self._normalize_to_id(role_assignments):
if role_assignment.get(self.PROJECT) is not None: if role_assignment.get(self.PROJECT) is not None:
self.client().client.roles.revoke( self.client().roles.revoke(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
project=role_assignment.get(self.PROJECT), project=role_assignment.get(self.PROJECT),
user=user_id user=user_id
) )
elif role_assignment.get(self.DOMAIN) is not None: elif role_assignment.get(self.DOMAIN) is not None:
self.client().client.roles.revoke( self.client().roles.revoke(
role=role_assignment.get(self.ROLE), role=role_assignment.get(self.ROLE),
domain=role_assignment.get(self.DOMAIN), domain=role_assignment.get(self.DOMAIN),
user=user_id user=user_id

View File

@ -78,7 +78,7 @@ class KeystoneRoleAssignmentMixinTest(common.HeatTestCase):
self.keystoneclient = mock.MagicMock() self.keystoneclient = mock.MagicMock()
self.test_role_assignment.client = mock.MagicMock() self.test_role_assignment.client = mock.MagicMock()
self.test_role_assignment.client.return_value = self.keystoneclient self.test_role_assignment.client.return_value = self.keystoneclient
self.roles = self.keystoneclient.client.roles self.roles = self.keystoneclient.roles
# Mock client plugin # Mock client plugin
def _side_effect(value): def _side_effect(value):
@ -412,7 +412,7 @@ class KeystoneUserRoleAssignmentTest(common.HeatTestCase):
self.keystoneclient = mock.MagicMock() self.keystoneclient = mock.MagicMock()
self.test_role_assignment.client = mock.MagicMock() self.test_role_assignment.client = mock.MagicMock()
self.test_role_assignment.client.return_value = self.keystoneclient self.test_role_assignment.client.return_value = self.keystoneclient
self.roles = self.keystoneclient.client.roles self.roles = self.keystoneclient.roles
# Mock client plugin # Mock client plugin
def _side_effect(value): def _side_effect(value):
@ -550,7 +550,7 @@ class KeystoneGroupRoleAssignmentTest(common.HeatTestCase):
self.keystoneclient = mock.MagicMock() self.keystoneclient = mock.MagicMock()
self.test_role_assignment.client = mock.MagicMock() self.test_role_assignment.client = mock.MagicMock()
self.test_role_assignment.client.return_value = self.keystoneclient self.test_role_assignment.client.return_value = self.keystoneclient
self.roles = self.keystoneclient.client.roles self.roles = self.keystoneclient.roles
# Mock client plugin # Mock client plugin
def _side_effect(value): def _side_effect(value):