diff --git a/hooks/lib/openstack-common b/hooks/lib/openstack-common index 7483b650..1b1b0f8d 100644 --- a/hooks/lib/openstack-common +++ b/hooks/lib/openstack-common @@ -417,3 +417,31 @@ is_leader() { return 1 } +########################################################################## +# Description: Print the value for a given config option in an OpenStack +# .ini style configuration file. +# Parameters: File path, option to retrieve, optional +# section name (default=DEFAULT) +# Returns: Prints value if set, prints nothing otherwise. +########################################################################## +local_config_get() { + # return config values set in openstack .ini config files. + # default placeholders starting (eg, %AUTH_HOST%) treated as + # unset values. + local file="$1" + local option="$2" + local section="$3" + [[ -z "$section" ]] && section="DEFAULT" + python -c " +import ConfigParser +config = ConfigParser.RawConfigParser() +config.read('$file') +try: + value = config.get('$section', '$option') +except: + print '' + exit(0) +if value.startswith('%'): exit(0) +print value +" +} diff --git a/hooks/nova-cloud-controller-relations b/hooks/nova-cloud-controller-relations index 8abc8ce7..f3034711 100755 --- a/hooks/nova-cloud-controller-relations +++ b/hooks/nova-cloud-controller-relations @@ -286,6 +286,7 @@ function keystone_changed { set_or_update "service_port" "$service_port" "$API_CONF" set_or_update "auth_host" "$auth_host" "$API_CONF" set_or_update "auth_port" "$auth_port" "$API_CONF" + # XXX http hard-coded set_or_update "auth_uri" "http://$service_host:$service_port/" "$API_CONF" set_or_update "admin_token" "$token" "$API_CONF" set_or_update "admin_tenant_name" "$service_tenant" "$API_CONF" @@ -332,7 +333,10 @@ EOF service_username=$service_username \ service_password=$service_password \ service_tenant=$service_tenant \ - region=$region + region=$region \ + # XXX http hard-coded + auth_uri="http://$service_host:$service_port/" + done fi } @@ -390,24 +394,24 @@ compute_joined() { # Clustered and not current leader - do nothing return 0 fi + relation-set network_manager=$(config-get network-manager) relation-set ec2_host=$(unit-get private-address) + + local sect="filter:authtoken" + keystone_host=$(local_config_get $API_CONF auth_host $sect) if [ "$NET_MANAGER" == "Quantum" ]; then - rids=$(relation-ids identity-service) - for rid in $rids; do - for unit in $(relation-list -r $rid); do - keystone_host=$(relation-get -r $rid auth_host $unit) - if [ -n "$keystone_host" ]; then - relation-set \ - keystone_host=$keystone_host \ - auth_port=$(relation-get -r $rid auth_port $unit) \ - service_port=$(relation-get -r $rid service_port $unit) \ - service_username=$(relation-get -r $rid service_username $unit) \ - service_password=$(relation-get -r $rid service_password $unit) \ - service_tenant=$(relation-get -r $rid service_tenant $unit) - fi - done - done + if [ -n "$keystone_host" ]; then + relation-set \ + keystone_host=$keystone_host \ + auth_port=$(local_config_get $API_CONF auth_port $sect) \ + service_port=$(local_config_get $API_CONF service_port $sect) \ + service_username=$(local_config_get $API_CONF admin_user $sect) \ + service_password=$(local_config_get $API_CONF admin_password $sect) \ + service_tenant=$(local_config_get $API_CONF admin_tenant_name $sect) \ + auth_uri=$(local_config_get $API_CONF auth_uri $sect) + fi + if is_clustered; then quantum_host=$(config-get vip) quantum_port=19696 @@ -415,6 +419,7 @@ compute_joined() { quantum_host=$(unit-get private-address) quantum_port=9696 fi + relation-set quantum_host=$quantum_host \ quantum_port=$quantum_port \ quantum_plugin=$(config-get quantum-plugin) @@ -457,21 +462,20 @@ function quantum_joined() { # Clustered and not current leader - do nothing return 0 fi - rids=$(relation-ids identity-service) - for rid in $rids; do - for unit in $(relation-list -r $rid); do - keystone_host=$(relation-get -r $rid auth_host $unit) - if [ -n "$keystone_host" ]; then - relation-set \ - keystone_host=$keystone_host \ - auth_port=$(relation-get -r $rid auth_port $unit) \ - service_port=$(relation-get -r $rid service_port $unit) \ - service_username=$(relation-get -r $rid service_username $unit) \ - service_password=$(relation-get -r $rid service_password $unit) \ - service_tenant=$(relation-get -r $rid service_tenant $unit) - fi - done - done + + local sect="filter:authtoken" + keystone_host=$(local_config_get $API_CONF auth_host $sect) + if [ -n "$keystone_host" ]; then + relation-set \ + keystone_host=$keystone_host \ + auth_port=$(local_config_get $API_CONF auth_port $sect) \ + service_port=$(local_config_get $API_CONF service_port $sect) \ + service_username=$(local_config_get $API_CONF admin_user $sect) \ + service_password=$(local_config_get $API_CONF admin_password $sect) \ + service_tenant=$(local_config_get $API_CONF admin_tenant_name $sect) \ + auth_uri=$(local_config_get $API_CONF auth_uri $sect) + fi + if is_clustered; then quantum_host=$(config-get vip) quantum_port=19696 @@ -479,6 +483,7 @@ function quantum_joined() { quantum_host=$(unit-get private-address) quantum_port=9696 fi + relation-set quantum_host=$quantum_host \ quantum_port=$quantum_port \ quantum_plugin=$(config-get quantum-plugin) \ @@ -552,7 +557,7 @@ function ha_relation_changed() { quantum_admin_url="$quantum_url" \ quantum_internal_url="$quantum_url" fi - + if [[ -n "$(relation-ids nova-volume-service)" ]] ; then nova_vol_url="http://$address:18776/v1/\$(tenant_id)s" relation-set -r $r_id \ diff --git a/revision b/revision index cd7da05e..0d389107 100644 --- a/revision +++ b/revision @@ -1 +1 @@ -210 +212