Merge "Move Nova to lib/nova"
diff --git a/exercises/volumes.sh b/exercises/volumes.sh
index 5db10d3..1c6320c 100755
--- a/exercises/volumes.sh
+++ b/exercises/volumes.sh
@@ -154,10 +154,16 @@
     echo "Failure creating volume $VOL_NAME"
     exit 1
 fi
+
+start_time=`date +%s`
 if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME | grep available; do sleep 1; done"; then
     echo "Volume $VOL_NAME not created"
+    end_time=`date +%s`
+    echo "Failed volume-create after $((end_time - start_time)) seconds"
     exit 1
 fi
+end_time=`date +%s`
+echo "Completed volume-create in $((end_time - start_time)) seconds"
 
 # Get volume ID
 VOL_ID=`nova volume-list | grep $VOL_NAME | head -1 | get_field 1`
@@ -165,12 +171,17 @@
 
 # Attach to server
 DEVICE=/dev/vdb
+start_time=`date +%s`
 nova volume-attach $VM_UUID $VOL_ID $DEVICE || \
     die "Failure attaching volume $VOL_NAME to $NAME"
 if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME | grep in-use; do sleep 1; done"; then
     echo "Volume $VOL_NAME not attached to $NAME"
+    end_time=`date +%s`
+    echo "Failed volume-attach after $((end_time - start_time)) seconds"
     exit 1
 fi
+end_time=`date +%s`
+echo "Completed volume-attach in $((end_time - start_time)) seconds"
 
 VOL_ATTACH=`nova volume-list | grep $VOL_NAME | head -1 | get_field -1`
 die_if_not_set VOL_ATTACH "Failure retrieving $VOL_NAME status"
@@ -180,18 +191,28 @@
 fi
 
 # Detach volume
+start_time=`date +%s`
 nova volume-detach $VM_UUID $VOL_ID || die "Failure detaching volume $VOL_NAME from $NAME"
 if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME | grep available; do sleep 1; done"; then
     echo "Volume $VOL_NAME not detached from $NAME"
+    end_time=`date +%s`
+    echo "Failed volume-detach after $((end_time - start_time)) seconds"
     exit 1
 fi
+end_time=`date +%s`
+echo "Completed volume-detach in $((end_time - start_time)) seconds"
 
 # Delete volume
+start_time=`date +%s`
 nova volume-delete $VOL_ID || die "Failure deleting volume $VOL_NAME"
 if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME; do sleep 1; done"; then
     echo "Volume $VOL_NAME not deleted"
+    end_time=`date +%s`
+    echo "Failed volume-delete after $((end_time - start_time)) seconds"
     exit 1
 fi
+end_time=`date +%s`
+echo "Completed volume-delete in $((end_time - start_time)) seconds"
 
 # Shutdown the server
 nova delete $VM_UUID || die "Failure deleting instance $NAME"
diff --git a/lib/ceilometer b/lib/ceilometer
index 35d2507..bea68ed 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -6,6 +6,9 @@
 
 # Dependencies:
 # - functions
+# - OS_USERNAME, OS_PASSWORD, OS_TENANT_NAME, OS_AUTH_URL set for admin credentials
+# - DEST set to the destination directory
+# - NOVA_CONF_DIR, NOVA_CONF set to the nova configuration directory & file
 
 # stack.sh
 # ---------
@@ -57,6 +60,7 @@
     # ceilometer confs are copy of /etc/nova/nova.conf which must exist first
     grep -v format_string $NOVA_CONF_DIR/$NOVA_CONF > $CEILOMETER_AGENT_CONF
     grep -v format_string $NOVA_CONF_DIR/$NOVA_CONF > $CEILOMETER_COLLECTOR_CONF
+    iniset $CEILOMETER_COLLECTOR_CONF DEFAULT notification_topics 'notifications,glance_notifications'
 }
 
 # install_ceilometer() - Collect source and prepare
@@ -67,7 +71,7 @@
 # start_ceilometer() - Start running processes, including screen
 function start_ceilometer() {
     screen_it ceilometer-acompute "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-compute --config-file $CEILOMETER_AGENT_CONF"
-    screen_it ceilometer-acentral "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-central --config-file $CEILOMETER_AGENT_CONF"
+    screen_it ceilometer-acentral "export OS_USERNAME=$OS_USERNAME OS_PASSWORD=$OS_PASSWORD OS_TENANT_NAME=$OS_TENANT_NAME OS_AUTH_URL=$OS_AUTH_URL && cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-agent-central --config-file $CEILOMETER_AGENT_CONF"
     screen_it ceilometer-collector "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-collector --config-file $CEILOMETER_COLLECTOR_CONF"
     screen_it ceilometer-api "cd $CEILOMETER_DIR && $CEILOMETER_BIN_DIR/ceilometer-api -d -v --log-dir=$CEILOMETER_API_LOG_DIR"
 }
diff --git a/lib/glance b/lib/glance
index 4cc6253..070c80d 100644
--- a/lib/glance
+++ b/lib/glance
@@ -107,6 +107,13 @@
     iniset $GLANCE_API_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
     iniset $GLANCE_API_CONF keystone_authtoken admin_user glance
     iniset $GLANCE_API_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
+    if is_service_enabled qpid; then
+        iniset $GLANCE_API_CONF DEFAULT notifier_strategy qpid
+    elif [ -n "$RABBIT_HOST" ] &&  [ -n "$RABBIT_PASSWORD" ]; then
+        iniset $GLANCE_API_CONF DEFAULT notifier_strategy rabbit
+        iniset $GLANCE_API_CONF DEFAULT rabbit_host $RABBIT_HOST
+        iniset $GLANCE_API_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
+    fi
 
     cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI
 
diff --git a/stack.sh b/stack.sh
index 9e6ca75..d05de6a 100755
--- a/stack.sh
+++ b/stack.sh
@@ -339,7 +339,7 @@
 Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
 Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP=:-True}
 # Meta data IP
-Q_META_DATA_IP=${Q_META_DATA_IP:-}
+Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
 
 # Name of the LVM volume group to use/create for iscsi volumes
 VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
@@ -1890,10 +1890,12 @@
         EXT_NET_ID=$(quantum net-create ext_net -- --router:external=True | grep ' id ' | get_field 2)
         EXT_GW_IP=$(quantum subnet-create --ip_version 4 $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
         quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
-        if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
+        if [[ "$Q_PLUGIN" = "openvswitch" ]] && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
             CIDR_LEN=${FLOATING_RANGE#*/}
             sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
             sudo ip link set $PUBLIC_BRIDGE up
+            ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
+            sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
         fi
         if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
             # Explicitly set router id in l3 agent configuration