Merge "Keystone updates"
diff --git a/exercises/bundle.sh b/exercises/bundle.sh
new file mode 100755
index 0000000..ca35c9a
--- /dev/null
+++ b/exercises/bundle.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+# we will use the ``euca2ools`` cli tool that wraps the python boto
+# library to test ec2 compatibility
+#
+
+# This script exits on an error so that errors don't compound and you see
+# only the first error that occured.
+set -o errexit
+
+# Print the commands being run so that we can see the command that triggers
+# an error.  It is also useful for following allowing as the install occurs.
+set -o xtrace
+
+# Settings
+# ========
+
+# Use openrc + stackrc + localrc for settings
+pushd $(cd $(dirname "$0")/.. && pwd)
+source ./openrc
+
+# Remove old certificates
+rm -f cacert.pem
+rm -f cert.pem
+rm -f pk.pem
+
+# Get Certificates
+nova x509-get-root-cert
+nova x509-create-cert
+popd
+
+# Max time to wait for image to be registered
+REGISTER_TIMEOUT=${REGISTER_TIMEOUT:-15}
+
+BUCKET=testbucket
+IMAGE=bundle.img
+truncate -s 5M /tmp/$IMAGE
+euca-bundle-image -i /tmp/$IMAGE
+
+
+euca-upload-bundle -b $BUCKET -m /tmp/$IMAGE.manifest.xml
+AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2`
+
+# Wait for the image to become available
+if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep '$AMI' | grep 'available'; do sleep 1; done"; then
+    echo "Image $AMI not available within $REGISTER_TIMEOUT seconds"
+    exit 1
+fi
diff --git a/openrc b/openrc
index 0f327d2..9c94141 100644
--- a/openrc
+++ b/openrc
@@ -49,6 +49,20 @@
 # Secret key is set in the initial keystone data to the admin password
 export EC2_SECRET_KEY=${ADMIN_PASSWORD:-secrete}
 
+# Euca2ools Certificate stuff for uploading bundles
+# You can get your certs using ./tools/get_certs.sh
+NOVARC=$(readlink -f "${BASH_SOURCE:-${0}}" 2>/dev/null) ||
+        NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' "${BASH_SOURCE:-${0}}")
+NOVA_KEY_DIR=${NOVARC%/*}
+export S3_URL=http://$SERVICE_HOST:3333
+export EC2_USER_ID=42 # nova does not use user id, but bundling requires it
+export EC2_PRIVATE_KEY=${NOVA_KEY_DIR}/pk.pem
+export EC2_CERT=${NOVA_KEY_DIR}/cert.pem
+export NOVA_CERT=${NOVA_KEY_DIR}/cacert.pem
+export EUCALYPTUS_CERT=${NOVA_CERT} # euca-bundle-image seems to require this set
+alias ec2-bundle-image="ec2-bundle-image --cert ${EC2_CERT} --privatekey ${EC2_PRIVATE_KEY} --user 42 --ec2cert ${NOVA_CERT}"
+alias ec2-upload-bundle="ec2-upload-bundle -a ${EC2_ACCESS_KEY} -s ${EC2_SECRET_KEY} --url ${S3_URL} --ec2cert ${NOVA_CERT}"
+
 # set log level to DEBUG (helps debug issues)
 # export NOVACLIENT_DEBUG=1
 
diff --git a/stack.sh b/stack.sh
index 21195fc..776279a 100755
--- a/stack.sh
+++ b/stack.sh
@@ -184,6 +184,7 @@
 SWIFT_DIR=$DEST/swift
 SWIFT_KEYSTONE_DIR=$DEST/swift-keystone2
 QUANTUM_DIR=$DEST/quantum
+QUANTUM_CLIENT_DIR=$DEST/python-quantumclient
 
 # Default Quantum Plugin
 Q_PLUGIN=${Q_PLUGIN:-openvswitch}
@@ -193,7 +194,7 @@
 Q_HOST=${Q_HOST:-localhost}
 
 # Specify which services to launch.  These generally correspond to screen tabs
-ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-novnc,n-xvnc,n-cauth,horizon,mysql,rabbit,openstackx}
+ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-sch,n-novnc,n-xvnc,n-cauth,horizon,mysql,rabbit,openstackx}
 
 # Name of the lvm volume group to use/create for iscsi volumes
 VOLUME_GROUP=${VOLUME_GROUP:-nova-volumes}
@@ -624,6 +625,7 @@
 if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
     # quantum
     git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH
+    git_clone $QUANTUM_CLIENT_REPO $QUANTUM_CLIENT_DIR $QUANTUM_CLIENT_BRANCH
 fi
 
 # Initialization
@@ -743,12 +745,9 @@
     # Install apache2, which is NOPRIME'd
     apt_get install apache2 libapache2-mod-wsgi
 
-    # Horizon currently imports quantum even if you aren't using it.  Instead
-    # of installing quantum we can create a simple module that will pass the
-    # initial imports
-    mkdir -p  $HORIZON_DIR/openstack-dashboard/quantum || true
-    touch $HORIZON_DIR/openstack-dashboard/quantum/__init__.py
-    touch $HORIZON_DIR/openstack-dashboard/quantum/client.py
+    # Link to quantum client directory.
+    rm -fr ${HORIZON_DIR}/openstack-dashboard/quantum
+    ln -s ${QUANTUM_CLIENT_DIR}/quantum ${HORIZON_DIR}/openstack-dashboard/quantum
 
 
     # ``local_settings.py`` is used to override horizon default settings.
@@ -1154,6 +1153,9 @@
 add_nova_flag "--scheduler_driver=$SCHEDULER"
 add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
 add_nova_flag "--fixed_range=$FIXED_RANGE"
+if [[ "$ENABLED_SERVICES" =~ "n-obj" ]]; then
+    add_nova_flag "--s3_host=$SERVICE_HOST"
+fi
 if [[ "$ENABLED_SERVICES" =~ "quantum" ]]; then
     add_nova_flag "--network_manager=nova.network.quantum.manager.QuantumManager"
     add_nova_flag "--quantum_connection_host=$Q_HOST"
@@ -1390,7 +1392,7 @@
         # Make sure we're using the openvswitch plugin
         sed -i -e "s/^provider =.*$/provider = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin/g" $QUANTUM_PLUGIN_INI_FILE
     fi
-    screen_it q-svc "cd $QUANTUM_DIR && PYTHONPATH=.:$PYTHONPATH python $QUANTUM_DIR/bin/quantum-server $QUANTUM_DIR/etc/quantum.conf"
+   screen_it q-svc "cd $QUANTUM_DIR && PYTHONPATH=.:$QUANTUM_CLIENT_DIR:$PYTHONPATH python $QUANTUM_DIR/bin/quantum-server $QUANTUM_DIR/etc/quantum.conf"
 fi
 
 # Quantum agent (for compute nodes)
@@ -1433,6 +1435,8 @@
 # within the context of our original shell (so our groups won't be updated).
 # Use 'sg' to execute nova-compute as a member of the libvirtd group.
 screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute"
+screen_it n-crt "cd $NOVA_DIR && $NOVA_DIR/bin/nova-cert"
+screen_it n-obj "cd $NOVA_DIR && $NOVA_DIR/bin/nova-objectstore"
 screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume"
 screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network"
 screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler"
diff --git a/stackrc b/stackrc
index 6a84469..9cc93ff 100644
--- a/stackrc
+++ b/stackrc
@@ -43,6 +43,10 @@
 QUANTUM_REPO=https://github.com/openstack/quantum
 QUANTUM_BRANCH=master
 
+# quantum client
+QUANTUM_CLIENT_REPO=https://github.com/openstack/python-quantumclient
+QUANTUM_CLIENT_BRANCH=master
+
 # CI test suite
 CITEST_REPO=https://github.com/openstack/tempest.git
 CITEST_BRANCH=master