18
18
DEBIAN_FRONTEND=noninteractive apt-get -y \
19
19
install --no-install-recommends $PACKAGES || exit 1
21
configure_network_manager $(config-get network-manager)
21
configure_network_manager $NET_MANAGER
23
23
# Configure any flags specified in deployment config
31
31
# object-store / s3
33
# Quantum API if configured
34
if [ "$NET_MANAGER" == "Quantum" ]; then
38
# Helpers for creating external and tenant networks
39
cp files/create_ext_net.py /usr/bin/quantum-ext-net
40
cp files/create_tenant_net.py /usr/bin/quantum-tenant-net
34
42
service_ctl all stop
45
function upgrade_charm {
37
50
function config_changed {
39
52
# Determine whether or not we should do an upgrade, based on whether or not
84
102
set_or_update rabbit_userid $rabbit_user
85
103
set_or_update rabbit_password $rabbit_password
86
104
set_or_update rabbit_virtual_host $rabbit_vhost
106
if [ "$(config-get network-manager)" == "Quantum" ]; then
107
set_or_update rabbit_host "$rabbit_host" "$QUANTUM_CONF"
108
set_or_update rabbit_userid "$rabbit_user" "$QUANTUM_CONF"
109
set_or_update rabbit_password "$rabbit_password" "$QUANTUM_CONF"
110
set_or_update rabbit_virtual_host "$rabbit_vhost" "$QUANTUM_CONF"
87
113
service_ctl all restart
95
121
local hostname=$(unit-get private-address)
96
122
juju-log "$CHARM - db_joined: requesting database access to $nova_db for "\
97
123
"$db_user@$hostname"
98
relation-set database=$nova_db username=$db_user hostname=$hostname
124
relation-set nova_database=$nova_db nova_username=$db_user nova_hostname=$hostname
125
if [ "$NET_MANAGER" == "Quantum" ]; then
126
relation-set quantum_database=quantum quantum_username=quantum quantum_hostname=$hostname
101
130
function db_changed {
102
131
local db_host=`relation-get private-address`
103
local db_password=`relation-get password`
132
local db_password=`relation-get nova_password`
105
134
if [[ -z $db_host ]] || [[ -z $db_password ]] ; then
106
135
juju-log "$CHARM - db_changed: db_host||db_password set, will retry."
112
141
juju-log "$CHARM - db_changed: Configuring nova.conf for access to $nova_db"
114
143
set_or_update sql_connection "mysql://$db_user:$db_password@$db_host/$nova_db"
145
if [ "$NET_MANAGER" == "Quantum" ]; then
146
local quantum_db_password=`relation-get quantum_password`
147
set_or_update sql_connection "mysql://quantum:$quantum_db_password@$db_host/quantum?charset=utf8" \
148
$QUANTUM_PLUGIN_CONF "DATABASE"
115
150
service_ctl all stop
116
151
/usr/bin/nova-manage db sync
117
152
service_ctl all start
153
if [ "$NET_MANAGER" == "Quantum" ]; then
154
configure_quantum_networking
118
156
trigger_remote_service_restarts
152
190
s3_admin_url="$s3_url" \
153
191
s3_internal_url="$s3_url"
193
if [ "$(config-get network-manager)" == "Quantum" ]; then
194
quantum_url="http://$(unit-get private-address):9696"
195
relation-set quantum_service="quantum" \
196
quantum_region="RegionOne" \
197
quantum_public_url="$quantum_url" \
198
quantum_admin_url="$quantum_url" \
199
quantum_internal_url="$quantum_url"
155
202
# tack on an endpoint for nova-volume a relation exists.
156
203
if [[ -n "$(relation-ids nova-volume-service)" ]] ; then
157
204
nova_vol_url="http://$(unit-get private-address):8776/v1/\$(tenant_id)s"
185
232
# Update keystone authentication configuration
186
233
keystone_host=$(relation-get private-address)
187
set_or_update "keystone_ec2_url" "http://$(relation-get private-address):5000/v2.0/ec2tokens"
234
set_or_update "keystone_ec2_url" "http://$keystone_host:5000/v2.0/ec2tokens"
189
236
if grep -q use_deprecated_auth $NOVA_CONF ; then
190
237
juju-log "$CHARM - keystone_changed: Disabling '--use_deprecated_auth"
201
248
set_or_update "admin_tenant_name" "$service_tenant" "$API_CONF"
202
249
set_or_update "admin_user" "$service_username" "$API_CONF"
203
250
set_or_update "admin_password" "$service_password" "$API_CONF"
252
if [ "$NET_MANAGER" == "Quantum" ]; then
253
# Configure Nova for quantum
254
keystone_url="http://${keystone_host}:${auth_port}/v2.0"
255
set_or_update "quantum_url" "http://$(unit-get private-address):9696"
256
set_or_update "quantum_admin_tenant_name" "${service_tenant}"
257
set_or_update "quantum_admin_username" "${service_username}"
258
set_or_update "quantum_admin_password" "${service_password}"
259
set_or_update "quantum_admin_auth_url" "${keystone_url}"
260
# Configure API server for quantum
261
set_or_update "admin_tenant_name" "$service_tenant" "$QUANTUM_API_CONF" "filter:authtoken"
262
set_or_update "admin_user" "$service_username" "$QUANTUM_API_CONF" "filter:authtoken"
263
set_or_update "admin_password" "$service_password" "$QUANTUM_API_CONF" "filter:authtoken"
264
set_or_update "auth_host" "$keystone_host" "$QUANTUM_API_CONF" "filter:authtoken"
265
set_or_update "auth_port" "$auth_port" "$QUANTUM_API_CONF" "filter:authtoken"
266
# Save a local copy of the credentials for later use
267
cat > /etc/quantum/novarc << EOF
268
export OS_USERNAME=${service_username}
269
export OS_PASSWORD=${service_password}
270
export OS_TENANT_NAME=${service_tenant}
271
export OS_AUTH_URL=${keystone_url}
204
275
service_ctl all restart
277
if [ "$NET_MANAGER" == "Quantum" ]; then
278
configure_quantum_networking
279
# ripple out changes to identity to connected services
280
# which use cloud-controller as source of information for
282
r_ids="$(relation-ids cloud-compute) $(relation-ids quantum-network-service)"
283
for id in $r_ids ; do
284
relation-set -r $id \
285
keystone_host=$keystone_host \
286
auth_port=$auth_port \
287
service_port=$service_port \
288
service_username=$service_username \
289
service_password=$service_password \
290
service_tenant=$service_tenant
207
295
volume_joined() {
247
335
compute_joined() {
248
# Inform remote unit of the network manager we've been configured to use.
249
# nova-compute should configure itself accordingly.
250
336
relation-set network_manager=$(config-get network-manager)
251
337
relation-set ec2_host=$(unit-get private-address)
338
if [ "$NET_MANAGER" == "Quantum" ]; then
339
rids=$(relation-ids identity-service)
341
for unit in $(relation-list -r $rid); do
342
keystone_host=$(relation-get -r $rid auth_host $unit)
343
if [ -n "$keystone_host" ]; then
345
keystone_host=$keystone_host \
346
auth_port=$(relation-get -r $rid auth_port $unit) \
347
service_port=$(relation-get -r $rid service_port $unit) \
348
service_username=$(relation-get -r $rid service_username $unit) \
349
service_password=$(relation-get -r $rid service_password $unit) \
350
service_tenant=$(relation-get -r $rid service_tenant $unit)
354
relation-set quantum_host=$(unit-get private-address)
355
relation-set quantum_plugin=$(config-get quantum-plugin)
253
358
# Compute's volume driver is dependent on volume service deployed.
254
359
local r_ids=$(relation-ids cinder-volume-service)
368
# Tell quantum service about keystone
369
rids=$(relation-ids identity-service)
371
for unit in $(relation-list -r $rid); do
372
keystone_host=$(relation-get -r $rid auth_host $unit)
373
if [ -n "$keystone_host" ]; then
375
keystone_host=$keystone_host \
376
auth_port=$(relation-get -r $rid auth_port $unit) \
377
service_port=$(relation-get -r $rid service_port $unit) \
378
service_username=$(relation-get -r $rid service_username $unit) \
379
service_password=$(relation-get -r $rid service_password $unit) \
380
service_tenant=$(relation-get -r $rid service_tenant $unit)
384
relation-set quantum_host=$(unit-get private-address)
385
relation-set quantum_plugin=$(config-get quantum-plugin)
262
388
arg0=$(basename $0)
264
390
"start"|"stop") service_ctl all $arg0 ;;
265
391
"install") install_hook ;;
266
392
"config-changed") config_changed ;;
393
"upgrade-charm") upgrade_charm ;;
267
394
"amqp-relation-joined") amqp_joined ;;
268
395
"amqp-relation-changed") amqp_changed ;;
269
396
"shared-db-relation-joined") db_joined ;;
275
402
"cinder-volume-service-relation-joined") volume_joined ;;
276
403
"nova-volume-service-relation-joined") volume_joined ;;
277
404
"cloud-compute-relation-joined") compute_joined ;;
405
"quantum-network-service-relation-joined") quantum_joined ;;