scope from GLOBAL to UNIT and use data from 1 unit (rest is the same)

This commit is contained in:
Alvaro Uría 2016-03-09 10:50:57 +01:00
parent 11069e8eb9
commit f7a29dadb8
1 changed files with 8 additions and 7 deletions

View File

@ -16,7 +16,7 @@ from charms.reactive import scopes
class KeystoneRequires(RelationBase): class KeystoneRequires(RelationBase):
scope = scopes.GLOBAL scope = scopes.UNIT
# These remote data fields will be automatically mapped to accessors # These remote data fields will be automatically mapped to accessors
# with a basic documentation string provided. # with a basic documentation string provided.
@ -29,7 +29,7 @@ class KeystoneRequires(RelationBase):
def changed(self): def changed(self):
conv = self.conversation() conv = self.conversation()
conv.set_state('{relation_name}.connected') conv.set_state('{relation_name}.connected')
if self.auth_data_complete() if self.auth_data_complete():
conv.set_state('{relation_name}.available') conv.set_state('{relation_name}.available')
else: else:
conv.remove_state('{relation_name}.available') conv.remove_state('{relation_name}.available')
@ -44,12 +44,13 @@ class KeystoneRequires(RelationBase):
""" """
Returns a dict of keystone admin credentials Returns a dict of keystone admin credentials
""" """
conv = self.conversation()
return { return {
'service_hostname': self.service_hostname(), 'service_hostname': conv.get_remote('service_hostname'),
'service_port': self.service_port(), 'service_port': conv.get_remote('service_port'),
'service_username': self.service_username(), 'service_username': conv.get_remote('service_username'),
'service_password': self.service_password(), 'service_password': conv.get_remote('service_password'),
'service_tenant_name': self.service_tenant_name() 'service_tenant_name': conv.get_remote('service_tenant_name')
} }
def auth_data_complete(self): def auth_data_complete(self):