Rebase on current ha-support charm.

This commit is contained in:
Adam Gandelman 2013-02-22 13:41:41 -08:00
commit 4fa8f9662d
3 changed files with 39 additions and 33 deletions

View File

@ -494,11 +494,11 @@ is_leader() {
hostname=`hostname` hostname=`hostname`
if [ -x /usr/sbin/crm ]; then if [ -x /usr/sbin/crm ]; then
if crm resource show $1 | grep -q $hostname; then if crm resource show $1 | grep -q $hostname; then
juju-log "$hostname is cluster leader" juju-log "$hostname is cluster leader."
return 0 return 0
fi fi
fi fi
juju-log "$hostname is not cluster leader" juju-log "$hostname is not cluster leader."
return 1 return 1
} }

View File

@ -201,10 +201,11 @@ function keystone_joined {
local host=$(unit-get private-address) local host=$(unit-get private-address)
https && local scheme="https" || local scheme="http" https && local scheme="https" || local scheme="http"
nova_url="$scheme://$host:8774/v1.1/\$(tenant_id)s" local nova_url="$scheme://$host:8774/v1.1/\$(tenant_id)s"
ec2_url="$scheme://$host:8773/services/Cloud" local ec2_url="$scheme://$host:8773/services/Cloud"
s3_url="$scheme://$host:3333" local s3_url="$scheme://$host:3333"
region="$(config-get region)" local region="$(config-get region)"
local quantum_url="$scheme://$host:9696"
# these are the default endpoints # these are the default endpoints
relation-set nova_service="nova" \ relation-set nova_service="nova" \
@ -224,7 +225,6 @@ function keystone_joined {
s3_internal_url="$s3_url" s3_internal_url="$s3_url"
if [ "$(config-get network-manager)" == "Quantum" ]; then if [ "$(config-get network-manager)" == "Quantum" ]; then
quantum_url="$scheme://$host:$quantum_port"
relation-set quantum_service="quantum" \ relation-set quantum_service="quantum" \
quantum_region="$region" \ quantum_region="$region" \
quantum_public_url="$quantum_url" \ quantum_public_url="$quantum_url" \
@ -278,6 +278,7 @@ function keystone_changed {
set_or_update "service_port" "$service_port" "$API_CONF" set_or_update "service_port" "$service_port" "$API_CONF"
set_or_update "auth_host" "$auth_host" "$API_CONF" set_or_update "auth_host" "$auth_host" "$API_CONF"
set_or_update "auth_port" "$auth_port" "$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 "auth_uri" "http://$service_host:$service_port/" "$API_CONF"
set_or_update "admin_token" "$token" "$API_CONF" set_or_update "admin_token" "$token" "$API_CONF"
set_or_update "admin_tenant_name" "$service_tenant" "$API_CONF" set_or_update "admin_tenant_name" "$service_tenant" "$API_CONF"
@ -315,7 +316,7 @@ EOF
# ripple out changes to identity to connected services # ripple out changes to identity to connected services
# which use cloud-controller as source of information for # which use cloud-controller as source of information for
# keystone # keystone
r_ids="$(relation-ids cloud-compute) $(relation-ids quantum-network-service)" local r_ids="$(relation-ids cloud-compute) $(relation-ids quantum-network-service)"
for id in $r_ids ; do for id in $r_ids ; do
relation-set -r $id \ relation-set -r $id \
keystone_host=$auth_host \ keystone_host=$auth_host \
@ -324,7 +325,10 @@ EOF
service_username=$service_username \ service_username=$service_username \
service_password=$service_password \ service_password=$service_password \
service_tenant=$service_tenant \ service_tenant=$service_tenant \
region=$region region=$region \
# XXX http hard-coded
auth_uri="http://$service_host:$service_port/"
done done
fi fi
configure_https configure_https
@ -381,8 +385,9 @@ volume_joined() {
compute_joined() { compute_joined() {
local r_id="$1" local r_id="$1"
[[ -n "$r_id" ]] && r_id="-r $r_id" [[ -n "$r_id" ]] && r_id="-r $r_id"
eligible_leader || return 0 eligible_leader 'res_nova_vip' || return 0
relation-set $r_id network_manager=$(config-get network-manager) relation-set $r_id network_manager=$(config-get network-manager)
# XXX Should point to VIP if clustered, or this may not even be needed.
relation-set $r_id ec2_host=$(unit-get private-address) relation-set $r_id ec2_host=$(unit-get private-address)
local sect="filter:authtoken" local sect="filter:authtoken"
@ -398,14 +403,17 @@ compute_joined() {
service_password=$(local_config_get $API_CONF admin_password $sect) \ service_password=$(local_config_get $API_CONF admin_password $sect) \
service_tenant=$(local_config_get $API_CONF admin_tenant_name $sect) \ service_tenant=$(local_config_get $API_CONF admin_tenant_name $sect) \
auth_uri=$(local_config_get $API_CONF auth_uri $sect) auth_uri=$(local_config_get $API_CONF auth_uri $sect)
fi
fi
is_clustered && local host=$(config-get vip) || is_clustered && local host=$(config-get vip) ||
local host=$(unit-get private-address) local host=$(unit-get private-address)
https && local scheme="https" || local scheme="http" https && local scheme="https" || local scheme="http"
local quantum_url="$scheme:$host:9696" local quantum_url="$scheme:$host:9696"
relation-set $r_id quantum_url=$quantum_url \ relation-set $r_id quantum_url=$quantum_url \
quantum_plugin=$(config-get quantum-plugin) quantum_plugin=$(config-get quantum-plugin) \
region=$(config-get region)
fi fi
# must pass on the keystone CA certficiate, if it exists. # must pass on the keystone CA certficiate, if it exists.
@ -464,17 +472,15 @@ function quantum_joined() {
auth_uri=$(local_config_get $API_CONF auth_uri $sect) auth_uri=$(local_config_get $API_CONF auth_uri $sect)
fi fi
if is_clustered; then is_clustered && local host=$(config-get vip) ||
quantum_host=$(config-get vip) local host=$(unit-get private-address)
quantum_port=19696 https && local scheme="https" || local scheme="http"
else local quantum_url="$scheme:$host:9696"
quantum_host=$(unit-get private-address)
quantum_port=9696 relation-set $r_id quantum_url=$quantum_url \
fi quantum_plugin=$(config-get quantum-plugin) \
relation-set quantum_host=$quantum_host \ region=$(config-get region)
quantum_port=$quantum_port \
quantum_plugin=$(config-get quantum-plugin) \
region=$(config-get region)
} }
function cluster_changed() { function cluster_changed() {
@ -540,10 +546,13 @@ function ha_relation_changed() {
if [ -n "$clustered" ] && is_leader 'res_nova_vip'; then if [ -n "$clustered" ] && is_leader 'res_nova_vip'; then
https && local scheme="https" || local scheme="http" https && local scheme="https" || local scheme="http"
for r_id in `relation-ids identity-service`; do for r_id in `relation-ids identity-service`; do
address=$(config-get vip) local address=$(config-get vip)
nova_url="$scheme://$address:8774/v1.1/\$(tenant_id)s" local nova_url="$scheme://$address:8774/v1.1/\$(tenant_id)s"
ec2_url="$scheme://$address:8773/services/Cloud" local ec2_url="$scheme://$address:8773/services/Cloud"
s3_url="$scheme://$address:3333" local s3_url="$scheme://$address:3333"
local quantum_url="$scheme://$address:9696"
local nova_vol_url="$scheme://$address:8776/v1/\$(tenant_id)s"
relation-set -r $r_id \ relation-set -r $r_id \
nova_public_url="$nova_url" \ nova_public_url="$nova_url" \
nova_admin_url="$nova_url" \ nova_admin_url="$nova_url" \
@ -556,7 +565,6 @@ function ha_relation_changed() {
s3_internal_url="$s3_url" s3_internal_url="$s3_url"
if [ "$(config-get network-manager)" == "Quantum" ]; then if [ "$(config-get network-manager)" == "Quantum" ]; then
quantum_url="$scheme://$address:9696"
relation-set -r $r_id \ relation-set -r $r_id \
quantum_public_url="$quantum_url" \ quantum_public_url="$quantum_url" \
quantum_admin_url="$quantum_url" \ quantum_admin_url="$quantum_url" \
@ -564,7 +572,6 @@ function ha_relation_changed() {
fi fi
if [[ -n "$(relation-ids nova-volume-service)" ]] ; then if [[ -n "$(relation-ids nova-volume-service)" ]] ; then
nova_vol_url="$scheme://$address:8776/v1/\$(tenant_id)s"
relation-set -r $r_id \ relation-set -r $r_id \
nova-volume_public_url="$nova_vol_url" \ nova-volume_public_url="$nova_vol_url" \
nova-volume_admin_url="$nova_vol_url" \ nova-volume_admin_url="$nova_vol_url" \
@ -572,12 +579,11 @@ function ha_relation_changed() {
fi fi
done done
if [ "$(config-get network-manager)" == "Quantum" ]; then if [ "$(config-get network-manager)" == "Quantum" ]; then
# Let gateway nodes use the new HA address for the # Let gateway nodes use the new HA address for the
# quantum API server # quantum API server
for r_id in `relation-ids quantum-network-service`; do for r_id in `relation-ids quantum-network-service`; do
relation-set -r $r_id \ relation-set -r $r_id \
quantum_host=$address quantum_url="$quantum_url"
quantum_port=9696
done done
fi fi
fi fi

View File

@ -1 +1 @@
222 223