From ed71ab066c67ad675d4b576520497c677d0a8fd1 Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Thu, 10 Oct 2013 09:04:40 -0700 Subject: [PATCH] Updates, checkin link.s --- .../charmhelpers/contrib/openstack/context.py | 43 +++++++++++-------- hooks/nova-vmware-relation-changed | 1 + hooks/nova-vmware-relation-joined | 1 + hooks/nova_cc_hooks.py | 6 +++ 4 files changed, 32 insertions(+), 19 deletions(-) create mode 120000 hooks/nova-vmware-relation-changed create mode 120000 hooks/nova-vmware-relation-joined diff --git a/hooks/charmhelpers/contrib/openstack/context.py b/hooks/charmhelpers/contrib/openstack/context.py index 5ff45258..7044947b 100644 --- a/hooks/charmhelpers/contrib/openstack/context.py +++ b/hooks/charmhelpers/contrib/openstack/context.py @@ -490,27 +490,32 @@ class SubordinateConfigContext(OSContextGenerator): def __call__(self): ctxt = {} for rid in relation_ids(self.interface): - sub_config = relation_get('subordinate_config', relaton_id=rid) - if sub_config and sub_config != '': - try: - sub_config = json.loads(sub_config) - except: - log('Could not parse JSON from subordinate_config setting ' - 'from %s' % rid, level=ERROR) + for unit in related_units(rid): + sub_config = relation_get('subordinate_config', + relaton_id=rid, unit=unit) + if sub_config and sub_config != '': + try: + sub_config = json.loads(sub_config) + except: + log('Could not parse JSON from subordinate_config ' + 'setting from %s' % rid, level=ERROR) - if self.service not in sub_config: - log('Found subordinate_config on %s but it contained' - 'nothing for %s service' % (rid, self.service)) - continue + if self.service not in sub_config: + log('Found subordinate_config on %s but it contained' + 'nothing for %s service' % (rid, self.service)) + continue - sub_config = sub_config[self.service] - if self.config_file not in sub_config: - log('Found subordinate_config on %s but it contained' - 'nothing for %s' % (rid, self.config_file)) - continue + sub_config = sub_config[self.service] + if self.config_file not in sub_config: + log('Found subordinate_config on %s but it contained' + 'nothing for %s' % (rid, self.config_file)) + continue - sub_config = sub_config[self.config_file] - for k, v in sub_config.iteritems(): - ctxt[k] = v + sub_config = sub_config[self.config_file] + for k, v in sub_config.iteritems(): + ctxt[k] = v + + if not ctxt: + ctxt['sections'] = {} return ctxt diff --git a/hooks/nova-vmware-relation-changed b/hooks/nova-vmware-relation-changed new file mode 120000 index 00000000..f6702415 --- /dev/null +++ b/hooks/nova-vmware-relation-changed @@ -0,0 +1 @@ +nova_cc_hooks.py \ No newline at end of file diff --git a/hooks/nova-vmware-relation-joined b/hooks/nova-vmware-relation-joined new file mode 120000 index 00000000..f6702415 --- /dev/null +++ b/hooks/nova-vmware-relation-joined @@ -0,0 +1 @@ +nova_cc_hooks.py \ No newline at end of file diff --git a/hooks/nova_cc_hooks.py b/hooks/nova_cc_hooks.py index 287f3a91..7bd8cdd1 100755 --- a/hooks/nova_cc_hooks.py +++ b/hooks/nova_cc_hooks.py @@ -401,6 +401,12 @@ def nova_vmware_relation_joined(): relation_set(network_manager=network_manager()) +@hooks.hook() +@restart_on_change(restart_map()) +def nova_vmware_relation_changed(): + CONFIGS.write('/etc/nova/nova.conf') + + def main(): try: hooks.execute(sys.argv)