Complete move of relations_get_dict into helpers
This commit is contained in:
parent
13754af380
commit
1ee652cbb4
@ -12,7 +12,6 @@ from keystone_utils import (
|
||||
update_config_block,
|
||||
set_admin_token,
|
||||
ensure_initial_admin,
|
||||
relation_get_dict,
|
||||
create_service_entry,
|
||||
create_endpoint_template,
|
||||
create_role,
|
||||
@ -140,7 +139,7 @@ def db_joined():
|
||||
|
||||
|
||||
def db_changed():
|
||||
relation_data = relation_get_dict()
|
||||
relation_data = utils.relation_get_dict()
|
||||
if ('password' not in relation_data or
|
||||
'db_host' not in relation_data):
|
||||
utils.juju_log('INFO',
|
||||
@ -209,8 +208,8 @@ def identity_changed(relation_id=None, remote_unit=None):
|
||||
'Deferring identity_changed() to service leader.')
|
||||
return
|
||||
|
||||
settings = relation_get_dict(relation_id=relation_id,
|
||||
remote_unit=remote_unit)
|
||||
settings = utils.relation_get_dict(relation_id=relation_id,
|
||||
remote_unit=remote_unit)
|
||||
|
||||
# Allow the remote service to request creation of any additional roles.
|
||||
# Currently used by Swift.
|
||||
@ -440,7 +439,7 @@ def cluster_changed():
|
||||
|
||||
|
||||
def ha_relation_changed():
|
||||
relation_data = relation_get_dict()
|
||||
relation_data = utils.relation_get_dict()
|
||||
if ('clustered' in relation_data and
|
||||
cluster.is_leader(CLUSTER_RES)):
|
||||
utils.juju_log('INFO',
|
||||
|
@ -82,25 +82,6 @@ def config_get():
|
||||
return config
|
||||
|
||||
|
||||
def relation_get_dict(relation_id=None, remote_unit=None):
|
||||
"""Obtain all relation data as dict by way of JSON"""
|
||||
cmd = 'relation-get --format=json'
|
||||
if relation_id:
|
||||
cmd += ' -r %s' % relation_id
|
||||
if remote_unit:
|
||||
remote_unit_orig = os.getenv('JUJU_REMOTE_UNIT', None)
|
||||
os.environ['JUJU_REMOTE_UNIT'] = remote_unit
|
||||
j = execute(cmd, die=True)[0]
|
||||
if remote_unit and remote_unit_orig:
|
||||
os.environ['JUJU_REMOTE_UNIT'] = remote_unit_orig
|
||||
d = json.loads(j)
|
||||
settings = {}
|
||||
# convert unicode to strings
|
||||
for k, v in d.iteritems():
|
||||
settings[str(k)] = str(v)
|
||||
return settings
|
||||
|
||||
|
||||
def get_local_endpoint():
|
||||
""" Returns the URL for the local end-point bypassing haproxy/ssl """
|
||||
local_endpoint = 'http://localhost:{}/v2.0/'.format(
|
||||
@ -478,8 +459,8 @@ def do_openstack_upgrade(install_src, packages):
|
||||
'Configuring new keystone.conf for '
|
||||
'database access on existing database'
|
||||
' relation to %s' % unit)
|
||||
relation_data = relation_get_dict(relation_id=rid,
|
||||
remote_unit=unit)
|
||||
relation_data = utils.relation_get_dict(relation_id=rid,
|
||||
remote_unit=unit)
|
||||
|
||||
update_config_block('sql', connection="mysql://%s:%s@%s/%s" %
|
||||
(config["database-user"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user