1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/bin/bash
FORMULA_DIR=$(dirname $0)
ARG0=${0##*/}
if [[ -e $FORMULA_DIR/nova-compute-common ]] ; then
. $FORMULA_DIR/nova-compute-common
else
echo "ERROR: Could not load nova-compute-common from $FORMULA_DIR"
fi
function install_hook {
apt-get -y install python-software-properties || exit 1
add_ppa
apt-get update || exit 1
apt-get -y install $SERVICES || exit 1
# XXX sudo on the ensemble sample AMI doesnt function
# as it should (doesn't include suoders.d/*). do this
# manually until we can use any AMI
echo "nova ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers
nova_ctl all stop
}
function amqp_joined {
ensemble-log "amqp_joined: requesting credentials for $RABBIT_USER"
echo "amqp_joined: requesting credentials for $RABBIT_USER"
relation-set username=$RABBIT_USER
relation-set vhost=$RABBIT_VHOST
}
function amqp_changed {
RABBIT_HOST=`relation-get hostname`
RABBIT_PASSWORD=`relation-get password`
if [[ -z $RABBIT_HOST ]] || [[ -z $RABBIT_PASSWORD ]] ; then
echo "amqp_changed: RABBIT_HOST||RABBIT_PASSWORD not set. Peer not ready? Exit 0 and retry"
exit 0
fi
echo "amqp_changed: Setting rabbit config in nova.conf: $RABBIT_HOST $RABBIT_USER $RABBIT_PASSWORD"
set_or_update rabbit_host $RABBIT_HOST
set_or_update rabbit_user $RABBIT_USER
set_or_update rabbit_password $RABBIT_PASSWORD
set_or_update rabbit_virtual_host $RABBIT_VHOST
nova_ctl all restart
}
function db_joined {
# tell mysql provider which database we want. it will create it and give us
# credentials
ensemble-log "db_joined: requesting database access to $NOVA_DB for $DB_USER@$IP"
relation-set database=$NOVA_DB
relation-set username=$DB_USER
relation-set hostname=$HOSTNAME
}
function db_changed {
DB_HOST=`relation-get db_host`
DB_PASSWORD=`relation-get password`
if [[ -z $DB_HOST ]] || [[ -z $DB_PASSWORD ]] ; then
echo "db_changed: DB_HOST || DB_PASSWORD not yet set. Exit 0 and retry"
exit 0
fi
echo "db_changed: Configuring nova.conf for access to $NOVA_DB"
set_or_update sql_connection "mysql://$DB_USER:$DB_PASSWORD@$DB_HOST/$NOVA_DB"
nova_ctl all restart
}
function nova-network_changed {
MANAGER=`relation-get network_manager`
if [[ -z $MANAGER ]] ; then
echo "nova-network_changed: MANAGER not yet set. Exit 0 and retry"
exit 0
fi
configure_network_manager $MANAGER
nova_ctl all restart
}
function image-service_changed {
GLANCE_API_SERVER=`relation-get glance-api-server`
if [[ -z $GLANCE_API_SERVER ]] ; then
echo "image-service_changed: GLANCE_API_SERVER not yet set. Exit 0 and retry"
exit 0
fi
set_or_update glance_api_servers $GLANCE_API_SERVER
nova_ctl all restart
}
case $ARG0 in
"install") install_hook ;;
"start"|"stop") exit 0 ;;
"amqp-relation-joined") amqp_joined ;;
"amqp-relation-changed") amqp_changed ;;
"shared-db-relation-joined") db_joined ;;
"shared-db-relation-changed") db_changed ;;
"nova-network-relation-joined") exit 0 ;;
"nova-network-relation-changed") nova-network_changed ;;
"image-service-relation-joined") exit 0 ;;
"image-service-relation-changed") image-service_changed ;;
esac
|