Merge "Remove DEFAULT_STACK_USER, just use STACK_USER"
diff --git a/files/swift/rsyncd.conf b/files/swift/rsyncd.conf
index 4e0dcbf..c670531 100644
--- a/files/swift/rsyncd.conf
+++ b/files/swift/rsyncd.conf
@@ -1,79 +1,79 @@
 uid = %USER%
 gid = %GROUP%
-log file = /var/log/rsyncd.log
-pid file = /var/run/rsyncd.pid
+log file = %SWIFT_DATA_DIR%/logs/rsyncd.log
+pid file = %SWIFT_DATA_DIR%/run/rsyncd.pid
 address = 127.0.0.1
 
 [account6012]
 max connections = 25
 path = %SWIFT_DATA_DIR%/1/node/
 read only = false
-lock file = /var/lock/account6012.lock
+lock file = %SWIFT_DATA_DIR%/run/account6012.lock
 
 [account6022]
 max connections = 25
 path = %SWIFT_DATA_DIR%/2/node/
 read only = false
-lock file = /var/lock/account6022.lock
+lock file = %SWIFT_DATA_DIR%/run/account6022.lock
 
 [account6032]
 max connections = 25
 path = %SWIFT_DATA_DIR%/3/node/
 read only = false
-lock file = /var/lock/account6032.lock
+lock file = %SWIFT_DATA_DIR%/run/account6032.lock
 
 [account6042]
 max connections = 25
 path = %SWIFT_DATA_DIR%/4/node/
 read only = false
-lock file = /var/lock/account6042.lock
+lock file = %SWIFT_DATA_DIR%/run/account6042.lock
 
 
 [container6011]
 max connections = 25
 path = %SWIFT_DATA_DIR%/1/node/
 read only = false
-lock file = /var/lock/container6011.lock
+lock file = %SWIFT_DATA_DIR%/run/container6011.lock
 
 [container6021]
 max connections = 25
 path = %SWIFT_DATA_DIR%/2/node/
 read only = false
-lock file = /var/lock/container6021.lock
+lock file = %SWIFT_DATA_DIR%/run/container6021.lock
 
 [container6031]
 max connections = 25
 path = %SWIFT_DATA_DIR%/3/node/
 read only = false
-lock file = /var/lock/container6031.lock
+lock file = %SWIFT_DATA_DIR%/run/container6031.lock
 
 [container6041]
 max connections = 25
 path = %SWIFT_DATA_DIR%/4/node/
 read only = false
-lock file = /var/lock/container6041.lock
+lock file = %SWIFT_DATA_DIR%/run/container6041.lock
 
 
 [object6010]
 max connections = 25
 path = %SWIFT_DATA_DIR%/1/node/
 read only = false
-lock file = /var/lock/object6010.lock
+lock file = %SWIFT_DATA_DIR%/run/object6010.lock
 
 [object6020]
 max connections = 25
 path = %SWIFT_DATA_DIR%/2/node/
 read only = false
-lock file = /var/lock/object6020.lock
+lock file = %SWIFT_DATA_DIR%/run/object6020.lock
 
 [object6030]
 max connections = 25
 path = %SWIFT_DATA_DIR%/3/node/
 read only = false
-lock file = /var/lock/object6030.lock
+lock file = %SWIFT_DATA_DIR%/run/object6030.lock
 
 [object6040]
 max connections = 25
 path = %SWIFT_DATA_DIR%/4/node/
 read only = false
-lock file = /var/lock/object6040.lock
+lock file = %SWIFT_DATA_DIR%/run/object6040.lock
diff --git a/lib/cinder b/lib/cinder
index a730cd6..5f4f979 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -172,7 +172,7 @@
     iniset $CINDER_CONF DEFAULT sql_connection $dburl
     iniset $CINDER_CONF DEFAULT api_paste_config $CINDER_API_PASTE_INI
     iniset $CINDER_CONF DEFAULT root_helper "sudo ${CINDER_ROOTWRAP}"
-    iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.openstack.volume.contrib.standard_extensions
+    iniset $CINDER_CONF DEFAULT osapi_volume_extension cinder.api.contrib.standard_extensions
     iniset $CINDER_CONF DEFAULT state_path $CINDER_STATE_PATH
 
     if is_service_enabled tls-proxy; then
diff --git a/lib/databases/mysql b/lib/databases/mysql
index 9524253..94aedc6 100644
--- a/lib/databases/mysql
+++ b/lib/databases/mysql
@@ -5,7 +5,7 @@
 # DATABASE_{HOST,USER,PASSWORD} must be defined
 
 # Save trace setting
-XTRACE=$(set +o | grep xtrace)
+MY_XTRACE=$(set +o | grep xtrace)
 set +o xtrace
 
 register_database mysql
@@ -121,4 +121,4 @@
 }
 
 # Restore xtrace
-$XTRACE
+$MY_XTRACE
diff --git a/lib/databases/postgresql b/lib/databases/postgresql
index 04db714..2c37f49 100644
--- a/lib/databases/postgresql
+++ b/lib/databases/postgresql
@@ -5,7 +5,7 @@
 # DATABASE_{HOST,USER,PASSWORD} must be defined
 
 # Save trace setting
-XTRACE=$(set +o | grep xtrace)
+PG_XTRACE=$(set +o | grep xtrace)
 set +o xtrace
 
 register_database postgresql
@@ -76,4 +76,4 @@
 }
 
 # Restore xtrace
-$XTRACE
+$PG_XTRACE
diff --git a/lib/quantum b/lib/quantum
index 27b3509..c5fc6e8 100644
--- a/lib/quantum
+++ b/lib/quantum
@@ -472,9 +472,8 @@
 # _configure_quantum_plugin_agent() - Set config files for quantum plugin agent
 # It is called when q-agt is enabled.
 function _configure_quantum_plugin_agent() {
-
     # Specify the default root helper prior to agent configuration to
-    # ensure that an agent's configuration can override the default.
+    # ensure that an agent's configuration can override the default
     iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
 
     # Configure agent for plugin
@@ -544,6 +543,9 @@
     chmod 0440 $TEMPFILE
     sudo chown root:root $TEMPFILE
     sudo mv $TEMPFILE /etc/sudoers.d/quantum-rootwrap
+
+    # Update the root_helper
+    iniset $QUANTUM_CONF AGENT root_helper "$Q_RR_COMMAND"
 }
 
 # Configures keystone integration for quantum service and agents
diff --git a/lib/rpc_backend b/lib/rpc_backend
index 4d7f8d2..f35f9db 100644
--- a/lib/rpc_backend
+++ b/lib/rpc_backend
@@ -100,7 +100,7 @@
         iniset $file $section rpc_backend ${package}.openstack.common.rpc.impl_zmq
     elif is_service_enabled qpid; then
         iniset $file $section rpc_backend ${package}.openstack.common.rpc.impl_qpid
-    elif is_service_enabled rabbit; then
+    elif is_service_enabled rabbit || { [ -n "$RABBIT_HOST" ] && [ -n "$RABBIT_PASSWORD" ]; }; then
         iniset $file $section rpc_backend ${package}.openstack.common.rpc.impl_kombu
         iniset $file $section rabbit_host $RABBIT_HOST
         iniset $file $section rabbit_password $RABBIT_PASSWORD
diff --git a/lib/swift b/lib/swift
index a4faf03..5ba7e56 100644
--- a/lib/swift
+++ b/lib/swift
@@ -95,13 +95,13 @@
     setup_develop $SWIFT_DIR
 
     # Make sure to kill all swift processes first
-    swift-init all stop || true
+    swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
 
     # First do a bit of setup by creating the directories and
     # changing the permissions so we can run it as our user.
 
     USER_GROUP=$(id -g)
-    sudo mkdir -p ${SWIFT_DATA_DIR}/{drives,cache}
+    sudo mkdir -p ${SWIFT_DATA_DIR}/{drives,cache,run,logs}
     sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR}
 
     # Create a loopback disk and format it to XFS.
@@ -143,8 +143,8 @@
         sudo chown -R $USER: ${node}
     done
 
-   sudo mkdir -p ${SWIFT_CONFIG_DIR}/{object,container,account}-server /var/run/swift
-   sudo chown -R $USER: ${SWIFT_CONFIG_DIR} /var/run/swift
+   sudo mkdir -p ${SWIFT_CONFIG_DIR}/{object,container,account}-server
+   sudo chown -R $USER: ${SWIFT_CONFIG_DIR}
 
     if [[ "$SWIFT_CONFIG_DIR" != "/etc/swift" ]]; then
         # Some swift tools are hard-coded to use ``/etc/swift`` and are apparently not going to be fixed.
@@ -311,7 +311,7 @@
 function init_swift() {
     local node_number
     # Make sure to kill all swift processes first
-    swift-init all stop || true
+    swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
 
     # This is where we create three different rings for swift with
     # different object servers binding on different ports.
@@ -363,15 +363,15 @@
    # proxy service so we can run it in foreground in screen.
    # ``swift-init ... {stop|restart}`` exits with '1' if no servers are running,
    # ignore it just in case
-   swift-init all restart || true
-   swift-init proxy stop || true
+   swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true
+   swift-init --run-dir=${SWIFT_DATA_DIR}/run proxy stop || true
    screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"
 }
 
 # stop_swift() - Stop running processes (non-screen)
 function stop_swift() {
     # screen normally killed by unstack.sh
-    swift-init all stop || true
+    swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
 }
 
 # Restore xtrace
diff --git a/lib/tempest b/lib/tempest
index 4d91d90..cb172a8 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -55,6 +55,7 @@
 
 # configure_tempest() - Set config files, create data dirs, etc
 function configure_tempest() {
+    setup_develop $TEMPEST_DIR
     local image_lines
     local images
     local num_images
@@ -304,7 +305,7 @@
        echo "Prepare aki/ari/ami Images"
        ( #new namespace
            # tenant:demo ; user: demo
-           source $devstack_dir/accrc/demo/demo
+           source $TOP_DIR/accrc/demo/demo
            euca-bundle-image -i "$kernel" --kernel true -d "$BOTO_MATERIALS_PATH"
            euca-bundle-image -i "$ramdisk" --ramdisk true -d "$BOTO_MATERIALS_PATH"
            euca-bundle-image -i "$disk_image" -d "$BOTO_MATERIALS_PATH"