Merge "Allow configuration of Apache user and group"
diff --git a/files/nova-api-paste.ini b/files/nova-api-paste.ini
deleted file mode 100644
index 76c8aae..0000000
--- a/files/nova-api-paste.ini
+++ /dev/null
@@ -1,20 +0,0 @@
-##########
-# Extras #
-##########
-
-[filter:keystonecontext]
-paste.filter_factory = keystone.middleware.nova_keystone_context:NovaKeystoneContext.factory
-
-[filter:totoken]
-paste.filter_factory = keystone.middleware.ec2_token:EC2Token.factory
-
-[filter:authtoken]
-paste.filter_factory = keystone.middleware.auth_token:filter_factory
-service_protocol = http
-service_host = 127.0.0.1
-service_port = 5000
-auth_host = 127.0.0.1
-auth_port = 35357
-auth_protocol = http
-auth_uri = http://127.0.0.1:5000/
-admin_token = %SERVICE_TOKEN%
diff --git a/stack.sh b/stack.sh
index a35cbba..f2ca9d5 100755
--- a/stack.sh
+++ b/stack.sh
@@ -845,7 +845,7 @@
     # the configuration required for nova to validate keystone tokens.
 
     # First we add a some extra data to the default paste config from nova
-    cat $NOVA_DIR/etc/nova/api-paste.ini $FILES/nova-api-paste.ini > $NOVA_DIR/bin/nova-api-paste.ini
+    cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_DIR/bin/nova-api-paste.ini
 
     # Then we add our own service token to the configuration
     sed -e "s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g" -i $NOVA_DIR/bin/nova-api-paste.ini
@@ -854,9 +854,8 @@
     function replace_pipeline() {
         sed "/\[pipeline:$1\]/,/\[/s/^pipeline = .*/pipeline = $2/" -i $NOVA_DIR/bin/nova-api-paste.ini
     }
-    replace_pipeline "ec2cloud" "ec2faultwrap logrequest totoken authtoken keystonecontext cloudrequest authorizer ec2executor"
+    replace_pipeline "ec2cloud" "ec2faultwrap logrequest totoken authtoken keystonecontext cloudrequest authorizer validator ec2executor"
     replace_pipeline "ec2admin" "ec2faultwrap logrequest totoken authtoken keystonecontext adminrequest authorizer ec2executor"
-    replace_pipeline "openstack_api_v2" "faultwrap authtoken keystonecontext ratelimit osapi_app_v2"
     replace_pipeline "openstack_compute_api_v2" "faultwrap authtoken keystonecontext ratelimit osapi_compute_app_v2"
     replace_pipeline "openstack_volume_api_v1" "faultwrap authtoken keystonecontext ratelimit osapi_volume_app_v1"
 fi
@@ -941,7 +940,7 @@
 
     # Destroy old instances
     instances=`virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
-    if [ ! $instances = "" ]; then
+    if [ ! "$instances" = "" ]; then
         echo $instances | xargs -n1 virsh destroy || true
         echo $instances | xargs -n1 virsh undefine || true
     fi
@@ -1377,6 +1376,7 @@
         apt_get install openvswitch-switch openvswitch-datapath-dkms
         # Create database for the plugin/agent
         if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
+            mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS ovs_quantum;'
             mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS ovs_quantum;'
         else
             echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin."
diff --git a/tools/build_ci_config.sh b/tools/build_ci_config.sh
index 90b8abf..79f6ead 100755
--- a/tools/build_ci_config.sh
+++ b/tools/build_ci_config.sh
@@ -123,6 +123,33 @@
 GLANCE_HOST=$1
 GLANCE_PORT=$2
 
+# Set up downloaded images
+# Defaults to use first image
+
+IMAGE_DIR=""
+for imagedir in $TOP_DIR/files/images/*; do
+    KERNEL=""
+    RAMDISK=""
+    IMAGE=""
+    IMAGE_RAMDISK=""
+    KERNEL=$(for f in "$imagedir/"*-vmlinuz*; do
+        [ -f "$f" ] && echo "$f" && break; done; true)
+    [ -n "$KERNEL" ] && ln -sf $KERNEL $imagedir/kernel
+    RAMDISK=$(for f in "$imagedir/"*-initrd*; do
+        [ -f "$f" ] && echo "$f" && break; done; true)
+    [ -n "$RAMDISK" ] && ln -sf $RAMDISK $imagedir/ramdisk && \
+                         IMAGE_RAMDISK="ari_location = $imagedir/ramdisk"
+    IMAGE=$(for f in "$imagedir/"*.img; do
+        [ -f "$f" ] && echo "$f" && break; done; true)
+    if [ -n "$IMAGE" ]; then
+        ln -sf $IMAGE $imagedir/disk
+        # Save the first image directory that contains a disk image link
+        if [ -z "$IMAGE_DIR" ]; then
+            IMAGE_DIR=$imagedir
+        fi
+    fi
+done
+
 # Create storm.conf
 
 CONFIG_CONF_TMP=$(mktemp $CONFIG_CONF.XXXXXX)
@@ -154,9 +181,9 @@
 if [ "$UPLOAD_LEGACY_TTY" ]; then
     cat >$CONFIG_INI_TMP <<EOF
 [environment]
-aki_location = $DEST/devstack/files/images/aki-tty/image
-ari_location = $DEST/devstack/files/images/ari-tty/image
-ami_location = $DEST/devstack/files/images/ami-tty/image
+aki_location = $TOP_DIR/files/images/aki-tty/image
+ari_location = $TOP_DIR/files/images/ari-tty/image
+ami_location = $TOP_DIR/files/images/ami-tty/image
 image_ref = 3
 image_ref_alt = 3
 flavor_ref = 1
@@ -173,9 +200,9 @@
 else
     cat >$CONFIG_INI_TMP <<EOF
 [environment]
-aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual
-#ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader
-ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img
+aki_location = $IMAGE_DIR/kernel
+ami_location = $IMAGE_DIR/disk
+$IMAGE_RAMDISK
 image_ref = 2
 image_ref_alt = 2
 flavor_ref = 1
@@ -185,8 +212,8 @@
 host = $GLANCE_HOST
 apiver = v1
 port = $GLANCE_PORT
-image_id = 1
-image_id_alt = 1
+image_id = 2
+image_id_alt = 2
 tenant_id = 1
 EOF
 fi