Merge "Optionally install all pip into a global venv."
diff --git a/exercise.sh b/exercise.sh
index 15f264f..a0349ce 100755
--- a/exercise.sh
+++ b/exercise.sh
@@ -5,6 +5,9 @@
 # Keep track of the current devstack directory.
 TOP_DIR=$(cd $(dirname "$0") && pwd)
 
+# Import common functions
+source $TOP_DIR/functions
+
 # Load local configuration
 source $TOP_DIR/stackrc
 
diff --git a/files/apts/general b/files/apts/general
index f04f955..3fa07a7 100644
--- a/files/apts/general
+++ b/files/apts/general
@@ -18,3 +18,4 @@
 tcpdump
 euca2ools # only for testing client
 tar
+python-cmd2 # dist:precise
diff --git a/files/horizon_settings.py b/files/horizon_settings.py
index 1a6c17a..487c06e 100644
--- a/files/horizon_settings.py
+++ b/files/horizon_settings.py
@@ -20,6 +20,10 @@
 CACHE_BACKEND = 'dummy://'
 SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
 
+# Set a secure and unique SECRET_KEY (the Django default is '')
+from horizon.utils import secret_key
+SECRET_KEY = secret_key.generate_or_read_from_file(os.path.join(LOCAL_PATH, '.secret_key_store'))
+
 # Send email to the console by default
 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 # Or send them to /dev/null
diff --git a/lib/cinder b/lib/cinder
index 0e42600..49ad4af 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -142,6 +142,8 @@
             if ! sudo vgs $VOLUME_GROUP; then sudo vgcreate $VOLUME_GROUP $DEV; fi
         fi
 
+        mkdir -p $CINDER_DIR/volumes
+
         if sudo vgs $VOLUME_GROUP; then
             if [[ "$os_PACKAGE" = "rpm" ]]; then
                 # RPM doesn't start the service
@@ -171,6 +173,9 @@
 function start_cinder() {
     if is_service_enabled c-vol; then
         if [[ "$os_PACKAGE" = "deb" ]]; then
+            if [[ ! -f /etc/tgt/conf.d/cinder.conf ]]; then
+               echo "include $CINDER_DIR/volumes/*" | sudo tee /etc/tgt/conf.d/cinder.conf
+            fi
             # tgt in oneiric doesn't restart properly if tgtd isn't running
             # do it in two steps
             sudo stop tgt || true
diff --git a/samples/local.sh b/samples/local.sh
index 83637f9..2c54b10 100755
--- a/samples/local.sh
+++ b/samples/local.sh
@@ -13,6 +13,9 @@
 # Keep track of the devstack directory
 TOP_DIR=$(cd $(dirname "$0") && pwd)
 
+# Import common functions
+source $TOP_DIR/functions
+
 # Use openrc + stackrc + localrc for settings
 source $TOP_DIR/stackrc
 
diff --git a/stack.sh b/stack.sh
index 058b250..c1e06cb 100755
--- a/stack.sh
+++ b/stack.sh
@@ -1137,9 +1137,8 @@
     # If needed, move config file from $QUANTUM_DIR/etc/quantum to /etc/quantum
     mkdir -p /$Q_PLUGIN_CONF_PATH
     Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
-    if [[ -e $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE ]]; then
-            sudo mv $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
-    fi
+    cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
+
     sudo sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/$Q_DB_NAME?charset=utf8/g" /$Q_PLUGIN_CONF_FILE
 
     OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-True}
@@ -1166,17 +1165,9 @@
     Q_API_PASTE_FILE=/etc/quantum/api-paste.ini
     Q_POLICY_FILE=/etc/quantum/policy.json
 
-    if [[ -e $QUANTUM_DIR/etc/quantum.conf ]]; then
-      sudo cp $QUANTUM_DIR/etc/quantum.conf $Q_CONF_FILE
-    fi
-
-    if [[ -e $QUANTUM_DIR/etc/api-paste.ini ]]; then
-      sudo cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
-    fi
-
-    if [[ -e $QUANTUM_DIR/etc/policy.json ]]; then
-      sudo cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE
-    fi
+    cp $QUANTUM_DIR/etc/quantum.conf $Q_CONF_FILE
+    cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
+    cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE
 
     if is_service_enabled mysql; then
             mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e "DROP DATABASE IF EXISTS $Q_DB_NAME;"
@@ -1187,8 +1178,17 @@
     fi
 
     # Update either configuration file with plugin
-    sudo sed -i -e "s/^core_plugin =.*$/core_plugin = $Q_PLUGIN_CLASS/g" $Q_CONF_FILE
-    screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $Q_CONF_FILE"
+    iniset $Q_CONF_FILE DEFAULT core_plugin $Q_PLUGIN_CLASS
+
+    iniset $Q_CONF_FILE DEFAULT auth_strategy $Q_AUTH_STRATEGY
+    iniset $Q_API_PASTE_FILE filter:authtoken auth_host $KEYSTONE_SERVICE_HOST
+    iniset $Q_API_PASTE_FILE filter:authtoken auth_port $KEYSTONE_AUTH_PORT
+    iniset $Q_API_PASTE_FILE filter:authtoken auth_protocol $KEYSTONE_SERVICE_PROTOCOL
+    iniset $Q_API_PASTE_FILE filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
+    iniset $Q_API_PASTE_FILE filter:authtoken admin_user $Q_ADMIN_USERNAME
+    iniset $Q_API_PASTE_FILE filter:authtoken admin_password $SERVICE_PASSWORD
+
+    screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
 fi
 
 # Quantum agent (for compute nodes)
@@ -1213,7 +1213,7 @@
        AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py"
     fi
     # Start up the quantum agent
-    screen_it q-agt "sudo python $AGENT_BINARY /$Q_PLUGIN_CONF_FILE -v"
+    screen_it q-agt "sudo python $AGENT_BINARY --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
 fi
 
 # Quantum DHCP
@@ -1763,6 +1763,9 @@
             start_service tgtd
         fi
 
+        # Setup tgtd configuration files
+        mkdir -p $NOVA_DIR/volumes
+
         # Remove nova iscsi targets
         sudo tgtadm --op show --mode target | grep $VOLUME_NAME_PREFIX | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true
         # Clean out existing volumes
@@ -1775,6 +1778,12 @@
     fi
 
     if [[ "$os_PACKAGE" = "deb" ]]; then
+
+        # Setup the tgt configuration file
+        if [[ ! -f /etc/tgt/conf.d/nova.conf ]]; then
+           echo "include $NOVA_DIR/volumes/*" | sudo tee /etc/tgt/conf.d/nova.conf
+        fi
+
         # tgt in oneiric doesn't restart properly if tgtd isn't running
         # do it in two steps
         sudo stop tgt || true
@@ -2133,10 +2142,10 @@
         TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
 
         # Create a small network
-        NET_ID=$(quantum net-create --os_token $Q_ADMIN_USERNAME --os_url http://$Q_HOST:$Q_PORT --tenant_id $TENANT_ID net1 | grep ' id ' | get_field 2)
-
-        # Create a subnet
-        quantum subnet-create --os_token $Q_ADMIN_USERNAME --os_url http://$Q_HOST:$Q_PORT --tenant_id $TENANT_ID --ip_version 4 --gateway  $NETWORK_GATEWAY $NET_ID $FIXED_RANGE
+        # Since quantum command is executed in admin context at this point,
+        # --tenant_id needs to be specified.
+        NET_ID=$(quantum net-create --tenant_id $TENANT_ID net1 | grep ' id ' | get_field 2)
+        quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE
     fi
 fi
 
diff --git a/stackrc b/stackrc
index d2bb151..3bbc475 100644
--- a/stackrc
+++ b/stackrc
@@ -1,6 +1,9 @@
 # Find the other rc files
 RC_DIR=$(cd $(dirname "$BASH_SOURCE") && pwd)
 
+# Destination path for installation
+DEST=/opt/stack
+
 # Specify which services to launch.  These generally correspond to
 # screen tabs. If you like to add other services that are not enabled
 # by default you can append them in your ENABLED_SERVICES variable in
@@ -10,9 +13,9 @@
 #
 # If you like to explicitly remove services you can add a -$service in
 # ENABLED_SERVICES, for example in your localrc to install all defaults but not
-# nova-volume you would just need to set this :
-# ENABLED_SERVICES+=,-n-vol
-ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,mysql,rabbit
+# cinder you would just need to set this :
+# ENABLED_SERVICES+=,-cinder
+ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,cinder,c-sch,c-api,c-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,mysql,rabbit
 
 # Set the default Nova APIs to enable
 NOVA_ENABLED_APIS=ec2,osapi_compute,osapi_volume,metadata
diff --git a/tools/build_bm.sh b/tools/build_bm.sh
index b2d4c36..ab0ba0e 100755
--- a/tools/build_bm.sh
+++ b/tools/build_bm.sh
@@ -5,6 +5,13 @@
 # Build an OpenStack install on a bare metal machine.
 set +x
 
+# Keep track of the current directory
+TOOLS_DIR=$(cd $(dirname "$0") && pwd)
+TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
+
+# Import common functions
+source $TOP_DIR/functions
+
 # Source params
 source ./stackrc
 
diff --git a/tools/configure_tempest.sh b/tools/configure_tempest.sh
index 22a8c43..456b3c0 100755
--- a/tools/configure_tempest.sh
+++ b/tools/configure_tempest.sh
@@ -135,6 +135,7 @@
 COMPUTE_CREATE_IMAGE_ENABLED=True
 COMPUTE_ALLOW_TENANT_ISOLATION=True
 COMPUTE_RESIZE_AVAILABLE=False  # not supported with QEMU...
+COMPUTE_CHANGE_PASSWORD_AVAILABLE=False  # not supported with QEMU...
 COMPUTE_LOG_LEVEL=ERROR
 BUILD_INTERVAL=3
 BUILD_TIMEOUT=400
@@ -154,6 +155,9 @@
 NETWORK_CATALOG_TYPE=network
 NETWORK_API_VERSION=2.0
 
+# Volume API test configuration
+VOLUME_CATALOG_TYPE=volume
+
 sed -e "
     s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
     s,%IDENTITY_HOST%,$IDENTITY_HOST,g;
@@ -172,6 +176,7 @@
     s,%COMPUTE_ALLOW_TENANT_ISOLATION%,$COMPUTE_ALLOW_TENANT_ISOLATION,g;
     s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g;
     s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g;
+    s,%COMPUTE_CHANGE_PASSWORD_AVAILABLE%,$COMPUTE_CHANGE_PASSWORD_AVAILABLE,g;
     s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g;
     s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g;
     s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g;
@@ -196,6 +201,7 @@
     s,%IDENTITY_ADMIN_TENANT_NAME%,$IDENTITY_ADMIN_TENANT_NAME,g;
     s,%NETWORK_CATALOG_TYPE%,$NETWORK_CATALOG_TYPE,g;
     s,%NETWORK_API_VERSION%,$NETWORK_API_VERSION,g;
+    s,%VOLUME_CATALOG_TYPE%,$VOLUME_CATALOG_TYPE,g;
 " -i $TEMPEST_CONF
 
 echo "Created tempest configuration file:"