Merge "Remove python-netaddr requirement"
diff --git a/README.md b/README.md
index 5fd4291..fbf7b4a 100644
--- a/README.md
+++ b/README.md
@@ -85,30 +85,42 @@
 
 # Swift
 
-Swift is enabled by default configured with only one replica to avoid being IO/memory intensive on a small vm. When running with only one replica the account, container and object services will run directly in screen. The others services like replicator, updaters or auditor runs in background.
+Swift is disabled by default.  When enabled, it is configured with
+only one replica to avoid being IO/memory intensive on a small
+vm. When running with only one replica the account, container and
+object services will run directly in screen. The others services like
+replicator, updaters or auditor runs in background.
 
-If you would like to disable Swift you can add this to your `localrc` :
+If you would like to enable Swift you can add this to your `localrc` :
 
-    disable_service s-proxy s-object s-container s-account
+    enable_service s-proxy s-object s-container s-account
 
-If you want a minimal Swift install with only Swift and Keystone you can have this instead in your `localrc`:
+If you want a minimal Swift install with only Swift and Keystone you
+can have this instead in your `localrc`:
 
     disable_all_services
     enable_service key mysql s-proxy s-object s-container s-account
 
-If you only want to do some testing of a real normal swift cluster with multiple replicas you can do so by customizing the variable `SWIFT_REPLICAS` in your `localrc` (usually to 3).
+If you only want to do some testing of a real normal swift cluster
+with multiple replicas you can do so by customizing the variable
+`SWIFT_REPLICAS` in your `localrc` (usually to 3).
 
 # Swift S3
 
-If you are enabling `swift3` in `ENABLED_SERVICES` devstack will install the swift3 middleware emulation. Swift will be configured to act as a S3 endpoint for Keystone so effectively replacing the `nova-objectstore`.
+If you are enabling `swift3` in `ENABLED_SERVICES` devstack will
+install the swift3 middleware emulation. Swift will be configured to
+act as a S3 endpoint for Keystone so effectively replacing the
+`nova-objectstore`.
 
-Only Swift proxy server is launched in the screen session all other services are started in background and managed by `swift-init` tool.
+Only Swift proxy server is launched in the screen session all other
+services are started in background and managed by `swift-init` tool.
 
 # Neutron
 
 Basic Setup
 
-In order to enable Neutron a single node setup, you'll need the following settings in your `localrc` :
+In order to enable Neutron a single node setup, you'll need the
+following settings in your `localrc` :
 
     disable_service n-net
     enable_service q-svc
diff --git a/files/rpms-suse/cinder b/files/rpms-suse/cinder
index 61b9f25..8f4a5a7 100644
--- a/files/rpms-suse/cinder
+++ b/files/rpms-suse/cinder
@@ -1,3 +1,3 @@
 lvm2
 tgt
-qemu-img
+qemu-tools
diff --git a/functions b/functions
index ba3ce65..eb83dfb 100644
--- a/functions
+++ b/functions
@@ -936,14 +936,35 @@
         PIP_MIRROR_OPT="--use-mirrors"
     fi
 
+    # pip < 1.4 has a bug where it will use an already existing build
+    # directory unconditionally.  Say an earlier component installs
+    # foo v1.1; pip will have built foo's source in
+    # /tmp/$USER-pip-build.  Even if a later component specifies foo <
+    # 1.1, the existing extracted build will be used and cause
+    # confusing errors.  By creating unique build directories we avoid
+    # this problem. See
+    #  https://github.com/pypa/pip/issues/709
+    local pip_build_tmp=$(mktemp --tmpdir -d pip-build.XXXXX)
+
     $SUDO_PIP PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE:-/var/cache/pip} \
         HTTP_PROXY=$http_proxy \
         HTTPS_PROXY=$https_proxy \
         NO_PROXY=$no_proxy \
-        $CMD_PIP install $PIP_MIRROR_OPT $@
+        $CMD_PIP install --build=${pip_build_tmp} \
+        $PIP_MIRROR_OPT $@ \
+        && $SUDO_PIP rm -rf ${pip_build_tmp}
 }
 
 
+# Cleanup anything from /tmp on unstack
+# clean_tmp
+function cleanup_tmp {
+    local tmp_dir=${TMPDIR:-/tmp}
+
+    # see comments in pip_install
+    sudo rm -rf ${tmp_dir}/pip-build.*
+}
+
 # Service wrapper to restart services
 # restart_service service-name
 function restart_service() {
diff --git a/lib/ceilometer b/lib/ceilometer
index bd4ab0f..548496e 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -37,12 +37,10 @@
 CEILOMETER_AUTH_CACHE_DIR=${CEILOMETER_AUTH_CACHE_DIR:-/var/cache/ceilometer}
 
 # Support potential entry-points console scripts
-if [[ -d $CEILOMETER_DIR/bin ]]; then
-    CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin
-else
-    CEILOMETER_BIN_DIR=$(get_python_exec_prefix)
-fi
+CEILOMETER_BIN_DIR=$(get_python_exec_prefix)
 
+# Set up database backend
+CEILOMETER_BACKEND=${CEILOMETER_BACKEND:-mongodb}
 
 # Functions
 # ---------
@@ -91,11 +89,13 @@
     iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
     iniset $CEILOMETER_CONF keystone_authtoken signing_dir $CEILOMETER_AUTH_CACHE_DIR
 
-    iniset $CEILOMETER_CONF database connection mongodb://localhost:27017/ceilometer
-
-    configure_mongodb
-
-    cleanup_ceilometer
+    if [[ "$CEILOMETER_BACKEND" = 'mysql' ]]; then
+        iniset $CEILOMETER_CONF database connection `database_connection_url ceilometer`
+    else
+        iniset $CEILOMETER_CONF database connection mongodb://localhost:27017/ceilometer
+        configure_mongodb
+        cleanup_ceilometer
+    fi
 }
 
 function configure_mongodb() {
@@ -113,6 +113,11 @@
     sudo mkdir -p $CEILOMETER_AUTH_CACHE_DIR
     sudo chown $STACK_USER $CEILOMETER_AUTH_CACHE_DIR
     rm -f $CEILOMETER_AUTH_CACHE_DIR/*
+
+    if [[ "$CEILOMETER_BACKEND" = 'mysql' ]]; then
+        recreate_database ceilometer utf8
+        $CEILOMETER_BIN_DIR/ceilometer-dbsync
+    fi
 }
 
 # install_ceilometer() - Collect source and prepare
diff --git a/lib/neutron b/lib/neutron
index e6f5911..835f900 100644
--- a/lib/neutron
+++ b/lib/neutron
@@ -415,7 +415,12 @@
     # Start up the neutron agents if enabled
     screen_it q-agt "cd $NEUTRON_DIR && python $AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE"
     screen_it q-dhcp "cd $NEUTRON_DIR && python $AGENT_DHCP_BINARY --config-file $NEUTRON_CONF --config-file=$Q_DHCP_CONF_FILE"
-    screen_it q-l3 "cd $NEUTRON_DIR && python $AGENT_L3_BINARY --config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE"
+
+    if is_service_enabled q-vpn; then
+        screen_it q-vpn "cd $NEUTRON_DIR && $AGENT_VPN_BINARY --config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE"
+    else
+        screen_it q-l3 "cd $NEUTRON_DIR && python $AGENT_L3_BINARY --config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE"
+    fi
     screen_it q-meta "cd $NEUTRON_DIR && python $AGENT_META_BINARY --config-file $NEUTRON_CONF --config-file=$Q_META_CONF_FILE"
 
     if [ "$VIRT_DRIVER" = 'xenserver' ]; then
@@ -585,7 +590,6 @@
 {
     neutron_vpn_install_agent_packages
     neutron_vpn_configure_common
-    neutron_vpn_configure_agent
 }
 
 # _configure_neutron_plugin_agent() - Set config files for neutron plugin agent
diff --git a/lib/neutron_plugins/nicira b/lib/neutron_plugins/nicira
index 9b9dbdc..eabc417 100644
--- a/lib/neutron_plugins/nicira
+++ b/lib/neutron_plugins/nicira
@@ -47,6 +47,7 @@
 
 function neutron_plugin_configure_debug_command() {
     sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
+    iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT external_network_bridge "$PUBLIC_BRIDGE"
 }
 
 function neutron_plugin_configure_dhcp_agent() {
diff --git a/lib/neutron_plugins/ovs_base b/lib/neutron_plugins/ovs_base
index 0a53bff..2666d8e 100644
--- a/lib/neutron_plugins/ovs_base
+++ b/lib/neutron_plugins/ovs_base
@@ -67,6 +67,7 @@
 
     neutron-ovs-cleanup
     sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
+    sudo ovs-vsctl --no-wait br-set-external-id $PUBLIC_BRIDGE bridge-id $PUBLIC_BRIDGE
     # ensure no IP is configured on the public bridge
     sudo ip addr flush dev $PUBLIC_BRIDGE
 }
diff --git a/lib/neutron_plugins/services/vpn b/lib/neutron_plugins/services/vpn
index 3c030c5..0a79a69 100644
--- a/lib/neutron_plugins/services/vpn
+++ b/lib/neutron_plugins/services/vpn
@@ -6,7 +6,7 @@
 set +o xtrace
 
 
-VPN_BINARY="$NEUTRON_DIR/bin/neutron-vpn-agent"
+AGENT_VPN_BINARY="$NEUTRON_BIN_DIR/neutron-vpn-agent"
 VPN_PLUGIN="neutron.services.vpn.plugin.VPNDriverPlugin"
 
 function neutron_vpn_install_agent_packages() {
@@ -21,9 +21,5 @@
     fi
 }
 
-function neutron_vpn_configure_agent() {
-    AGENT_L3_BINARY="$NEUTRON_DIR/bin/neutron-vpn-agent"
-}
-
 # Restore xtrace
 $MY_XTRACE
diff --git a/lib/tempest b/lib/tempest
index 0e066a8..b4a579b 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -253,7 +253,7 @@
 
     # Network
     if is_service_enabled neutron; then
-        iniset $TEMPEST_CONF network neutron_available "True"
+        iniset $TEMPEST_CONF service_available neutron "True"
     fi
     iniset $TEMPEST_CONF network api_version 2.0
     iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable"
diff --git a/rejoin-stack.sh b/rejoin-stack.sh
index 65ba721..30b7bab 100755
--- a/rejoin-stack.sh
+++ b/rejoin-stack.sh
@@ -17,7 +17,7 @@
         echo "Attaching to already started screen session.."
         exec screen -r stack
     fi
-    exec screen -c $TOP_DIR/stack-screenrc -S $SCREEN_NAME
+    exec screen -c $TOP_DIR/stack-screenrc
 fi
 
 echo "Couldn't find $TOP_DIR/stack-screenrc file; have you run stack.sh yet?"
diff --git a/stack.sh b/stack.sh
index 0a5e1ee..3fa025f 100755
--- a/stack.sh
+++ b/stack.sh
@@ -836,7 +836,7 @@
 # Clear screen rc file
 SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc
 if [[ -e $SCREENRC ]]; then
-    echo -n > $SCREENRC
+    rm -f $SCREENRC
 fi
 
 # Initialize the directory for service status check
diff --git a/unstack.sh b/unstack.sh
index ece06eb..1e80bf3 100755
--- a/unstack.sh
+++ b/unstack.sh
@@ -111,3 +111,5 @@
     stop_neutron_third_party
     cleanup_neutron
 fi
+
+cleanup_tmp