Add support for passing optional `requested_roles
` attribute
When passing ``requested_roles`` down the ``identity-service`` relation the Keystone charm will create the listed roles for you. Useful for charm authors implementing charms with specific role requirements. Change-Id: I7c1eedb1e78ffc53ac3e0df81f6b52358dd8dfa5 Closes-Bug: #1813602
This commit is contained in:
parent
1c92403c75
commit
0ec113afb7
@ -119,7 +119,7 @@ class KeystoneRequires(RelationBase):
|
||||
return True
|
||||
|
||||
def register_endpoints(self, service, region, public_url, internal_url,
|
||||
admin_url):
|
||||
admin_url, requested_roles=None):
|
||||
"""
|
||||
Register this service with keystone
|
||||
"""
|
||||
@ -130,6 +130,9 @@ class KeystoneRequires(RelationBase):
|
||||
'admin_url': admin_url,
|
||||
'region': region,
|
||||
}
|
||||
if requested_roles:
|
||||
relation_info.update(
|
||||
{'requested_roles': ','.join(requested_roles)})
|
||||
self.set_local(**relation_info)
|
||||
self.set_remote(**relation_info)
|
||||
|
||||
|
@ -224,6 +224,22 @@ class TestKeystoneRequires(unittest.TestCase):
|
||||
self.set_local.assert_called_once_with(**result)
|
||||
self.set_remote.assert_called_once_with(**result)
|
||||
|
||||
def test_register_endpoints_requested_roles(self):
|
||||
self.patch_kr('set_local')
|
||||
self.patch_kr('set_remote')
|
||||
self.kr.register_endpoints('s', 'r', 'p_url', 'i_url', 'a_url',
|
||||
requested_roles=['role1', 'role2'])
|
||||
result = {
|
||||
'service': 's',
|
||||
'public_url': 'p_url',
|
||||
'internal_url': 'i_url',
|
||||
'admin_url': 'a_url',
|
||||
'region': 'r',
|
||||
'requested_roles': 'role1,role2',
|
||||
}
|
||||
self.set_local.assert_called_once_with(**result)
|
||||
self.set_remote.assert_called_once_with(**result)
|
||||
|
||||
def test_request_keystone_endpoint_information(self):
|
||||
self.patch_kr('set_local')
|
||||
self.patch_kr('set_remote')
|
||||
|
Loading…
x
Reference in New Issue
Block a user