diff --git a/hooks/cluster-relation-departed b/hooks/cluster-relation-departed new file mode 120000 index 0000000..8623fba --- /dev/null +++ b/hooks/cluster-relation-departed @@ -0,0 +1 @@ +swift_hooks.py \ No newline at end of file diff --git a/hooks/swift_hooks.py b/hooks/swift_hooks.py index 5f260e2..b809d18 100755 --- a/hooks/swift_hooks.py +++ b/hooks/swift_hooks.py @@ -54,7 +54,8 @@ from charmhelpers.contrib.openstack.ip import ( ) from charmhelpers.contrib.network.ip import ( get_iface_for_address, - get_netmask_for_address + get_netmask_for_address, + get_address_in_network ) extra_pkgs = [ @@ -208,10 +209,19 @@ def config_changed(): do_openstack_upgrade(CONFIGS) for r_id in relation_ids('identity-service'): keystone_joined(relid=r_id) + [cluster_joined(rid) for rid in relation_ids('cluster')] + + +@hooks.hook('cluster-relation-joined') +def cluster_joined(relation_id=None): + address = get_address_in_network(config('os-internal-network'), + unit_get('private-address')) + relation_set(relation_id=relation_id, + relation_settings={'private-address': address}) @hooks.hook('cluster-relation-changed', - 'cluster-relation-joined') + 'cluster-relation-departed') @restart_on_change(restart_map()) def cluster_changed(): CONFIGS.write_all()