Merge "Set external ID on br-ex"
diff --git a/files/default_catalog.templates b/files/default_catalog.templates
index 990cc0e..1ecf890 100644
--- a/files/default_catalog.templates
+++ b/files/default_catalog.templates
@@ -12,6 +12,12 @@
 catalog.RegionOne.compute.name = Compute Service
 
 
+catalog.RegionOne.computev3.publicURL = http://%SERVICE_HOST%:8774/v3
+catalog.RegionOne.computev3.adminURL = http://%SERVICE_HOST%:8774/v3
+catalog.RegionOne.computev3.internalURL = http://%SERVICE_HOST%:8774/v3
+catalog.RegionOne.computev3.name = Compute Service V3
+
+
 catalog.RegionOne.volume.publicURL = http://%SERVICE_HOST%:8776/v1/$(tenant_id)s
 catalog.RegionOne.volume.adminURL = http://%SERVICE_HOST%:8776/v1/$(tenant_id)s
 catalog.RegionOne.volume.internalURL = http://%SERVICE_HOST%:8776/v1/$(tenant_id)s
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 3a3e28b..f4a3da1 100644
--- a/functions
+++ b/functions
@@ -913,14 +913,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/cinder b/lib/cinder
index 6e7d785..ef7e3dc 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -474,9 +474,13 @@
     fi
 
     screen_it c-api "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-api --config-file $CINDER_CONF"
-    screen_it c-vol "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-volume --config-file $CINDER_CONF"
     screen_it c-sch "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-scheduler --config-file $CINDER_CONF"
     screen_it c-bak "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-backup --config-file $CINDER_CONF"
+    screen_it c-vol "cd $CINDER_DIR && $CINDER_BIN_DIR/cinder-volume --config-file $CINDER_CONF"
+
+    # NOTE(jdg): For cinder, startup order matters.  To ensure that repor_capabilities is received
+    # by the scheduler start the cinder-volume service last (or restart it) after the scheduler
+    # has started.  This is a quick fix for lp bug/1189595
 
     # Start proxies if enabled
     if is_service_enabled c-api && is_service_enabled tls-proxy; then
diff --git a/lib/databases/mysql b/lib/databases/mysql
index 211d797..41e3236 100644
--- a/lib/databases/mysql
+++ b/lib/databases/mysql
@@ -131,7 +131,9 @@
     if is_ubuntu || is_fedora; then
         install_package mysql-server
     elif is_suse; then
-        install_package mysql-community-server
+        if ! is_package_installed mariadb; then
+            install_package mysql-community-server
+        fi
     else
         exit_distro_not_supported "mysql installation"
     fi
diff --git a/lib/keystone b/lib/keystone
index 1b6970d..e7e0544 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -132,6 +132,11 @@
 
     iniset $KEYSTONE_CONF DEFAULT admin_token "$SERVICE_TOKEN"
     iniset $KEYSTONE_CONF signing token_format "$KEYSTONE_TOKEN_FORMAT"
+
+    if [[ "$KEYSTONE_TOKEN_FORMAT" = "UUID" ]]; then
+        iniset $KEYSTONE_CONF token provider keystone.token.providers.uuid.Provider
+    fi
+
     iniset $KEYSTONE_CONF sql connection `database_connection_url keystone`
     iniset $KEYSTONE_CONF ec2 driver "keystone.contrib.ec2.backends.sql.Ec2"
 
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/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/nova b/lib/nova
index db82aa2..617fb08 100644
--- a/lib/nova
+++ b/lib/nova
@@ -407,6 +407,17 @@
                 --publicurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \
                 --adminurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \
                 --internalurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s"
+            NOVA_V3_SERVICE=$(keystone service-create \
+                --name=nova \
+                --type=computev3 \
+                --description="Nova Compute Service V3" \
+                | grep " id " | get_field 2)
+            keystone endpoint-create \
+                --region RegionOne \
+                --service_id $NOVA_V3_SERVICE \
+                --publicurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" \
+                --adminurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" \
+                --internalurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3"
         fi
     fi
 }
@@ -424,7 +435,7 @@
     iniset $NOVA_CONF DEFAULT allow_resize_to_same_host "True"
     iniset $NOVA_CONF DEFAULT api_paste_config "$NOVA_API_PASTE_INI"
     iniset $NOVA_CONF DEFAULT rootwrap_config "$NOVA_CONF_DIR/rootwrap.conf"
-    iniset $NOVA_CONF DEFAULT compute_scheduler_driver "$SCHEDULER"
+    iniset $NOVA_CONF DEFAULT scheduler_driver "$SCHEDULER"
     iniset $NOVA_CONF DEFAULT dhcpbridge_flagfile "$NOVA_CONF"
     iniset $NOVA_CONF DEFAULT force_dhcp_release "True"
     iniset $NOVA_CONF DEFAULT fixed_range ""
@@ -491,7 +502,6 @@
         iniset $NOVA_CONF DEFAULT instance_usage_audit "True"
         iniset $NOVA_CONF DEFAULT instance_usage_audit_period "hour"
         iniset $NOVA_CONF DEFAULT notify_on_state_change "vm_and_task_state"
-        iniset $NOVA_CONF DEFAULT notify_on_any_change "True"
         iniset_multiline $NOVA_CONF DEFAULT notification_driver "nova.openstack.common.notifier.rpc_notifier" "ceilometer.compute.nova_notifier"
     fi
 
diff --git a/lib/swift b/lib/swift
index 2feae78..e53d674 100644
--- a/lib/swift
+++ b/lib/swift
@@ -133,19 +133,6 @@
         sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
     fi
 
-    if is_service_enabled swift3;then
-        swift_auth_server="s3token "
-    fi
-
-    # By default Swift will be installed with the tempauth middleware
-    # which has some default username and password if you have
-    # configured keystone it will checkout the directory.
-    if is_service_enabled key; then
-        swift_auth_server+="authtoken keystoneauth"
-    else
-        swift_auth_server=tempauth
-    fi
-
     SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONF_DIR}/proxy-server.conf
     cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER}
 
@@ -164,24 +151,22 @@
     iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port
     iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080}
 
-    # By default Swift will be installed with the tempauth middleware
-    # which has some default username and password if you have
-    # configured keystone it will configure swift with it.
-    if is_service_enabled key;then
-        if is_service_enabled swift3;then
-            swift_pipeline=" swift3 s3token "
-        fi
-        swift_pipeline+=" authtoken keystoneauth "
-    else
-        if is_service_enabled swift3;then
-            swift_pipeline=" swift3 "
-        fi
-        swift_pipeline+=" tempauth "
+    # By default Swift will be installed with keystone and tempauth middleware
+    # and add the swift3 middleware if its configured for it. The token for
+    # tempauth would be prefixed with the reseller_prefix setting TEMPAUTH_ the
+    # token for keystoneauth would have the standard reseller_prefix AUTH_
+    if is_service_enabled swift3;then
+        swift_pipeline=" swift3 s3token "
     fi
+    swift_pipeline+=" authtoken keystoneauth tempauth "
     sed -i "/^pipeline/ { s/tempauth/${swift_pipeline} ${SWIFT_EXTRAS_MIDDLEWARE}/ ;}" ${SWIFT_CONFIG_PROXY_SERVER}
 
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth account_autocreate
     iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true
 
+    iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth reseller_prefix
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth reseller_prefix "TEMPAUTH"
+
     # Configure Keystone
     sed -i '/^# \[filter:authtoken\]/,/^# \[filter:keystoneauth\]$/ s/^#[ \t]*//' ${SWIFT_CONFIG_PROXY_SERVER}
     iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_host $KEYSTONE_AUTH_HOST
@@ -223,6 +208,7 @@
         local swift_node_config=$1
         local node_id=$2
         local bind_port=$3
+        local server_type=$4
 
         log_facility=$[ node_id - 1 ]
         node_path=${SWIFT_DATA_DIR}/${node_number}
@@ -242,6 +228,9 @@
         iniuncomment ${swift_node_config} DEFAULT log_facility
         iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
 
+        iniuncomment ${swift_node_config} DEFAULT disable_fallocate
+        iniset ${swift_node_config} DEFAULT disable_fallocate true
+
         iniuncomment ${swift_node_config} DEFAULT mount_check
         iniset ${swift_node_config} DEFAULT mount_check false
 
@@ -252,7 +241,7 @@
     for node_number in ${SWIFT_REPLICAS_SEQ}; do
         swift_node_config=${SWIFT_CONF_DIR}/object-server/${node_number}.conf
         cp ${SWIFT_DIR}/etc/object-server.conf-sample ${swift_node_config}
-        generate_swift_config ${swift_node_config} ${node_number} $[OBJECT_PORT_BASE + 10 * (node_number - 1)]
+        generate_swift_config ${swift_node_config} ${node_number} $[OBJECT_PORT_BASE + 10 * (node_number - 1)] object
         iniset ${swift_node_config} filter:recon recon_cache_path  ${SWIFT_DATA_DIR}/cache
         # Using a sed and not iniset/iniuncomment because we want to a global
         # modification and make sure it works for new sections.
@@ -260,14 +249,14 @@
 
         swift_node_config=${SWIFT_CONF_DIR}/container-server/${node_number}.conf
         cp ${SWIFT_DIR}/etc/container-server.conf-sample ${swift_node_config}
-        generate_swift_config ${swift_node_config} ${node_number} $[CONTAINER_PORT_BASE + 10 * (node_number - 1)]
+        generate_swift_config ${swift_node_config} ${node_number} $[CONTAINER_PORT_BASE + 10 * (node_number - 1)] container
         iniuncomment ${swift_node_config} app:container-server allow_versions
         iniset ${swift_node_config} app:container-server allow_versions  "true"
         sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
 
         swift_node_config=${SWIFT_CONF_DIR}/account-server/${node_number}.conf
         cp ${SWIFT_DIR}/etc/account-server.conf-sample ${swift_node_config}
-        generate_swift_config ${swift_node_config} ${node_number} $[ACCOUNT_PORT_BASE + 10 * (node_number - 1)]
+        generate_swift_config ${swift_node_config} ${node_number} $[ACCOUNT_PORT_BASE + 10 * (node_number - 1)] account
         sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
     done
 
@@ -286,12 +275,6 @@
     iniset ${testfile} func_test account2 swifttenanttest2
     iniset ${testfile} func_test username2 swiftusertest2
 
-    # Set maximum file size to 10000 bytes or our vm will fill up quickly with
-    # the default 5gb size.
-    iniuncomment ${testfile} func_test max_file_size
-    iniset ${testfile} func_test max_file_size 10000
-
-
     if is_service_enabled key;then
         iniuncomment ${testfile} func_test auth_version
         iniset ${testfile} func_test auth_host ${KEYSTONE_SERVICE_HOST}
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 f2054d9..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
@@ -878,10 +878,13 @@
     export OS_SERVICE_ENDPOINT=$SERVICE_ENDPOINT
     create_keystone_accounts
     create_nova_accounts
-    create_swift_accounts
     create_cinder_accounts
     create_neutron_accounts
 
+    if is_service_enabled swift || is_service_enabled s-proxy; then
+        create_swift_accounts
+    fi
+
     # ``keystone_data.sh`` creates services, admin and demo users, and roles.
     ADMIN_PASSWORD=$ADMIN_PASSWORD SERVICE_TENANT_NAME=$SERVICE_TENANT_NAME SERVICE_PASSWORD=$SERVICE_PASSWORD \
     SERVICE_TOKEN=$SERVICE_TOKEN SERVICE_ENDPOINT=$SERVICE_ENDPOINT SERVICE_HOST=$SERVICE_HOST \
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