Merge "Source linuxbridge_agent in linuxbridge plugin"
diff --git a/lib/neutron_plugins/nicira b/lib/neutron_plugins/nicira
index 7642be6..9b9dbdc 100644
--- a/lib/neutron_plugins/nicira
+++ b/lib/neutron_plugins/nicira
@@ -42,7 +42,7 @@
     Q_PLUGIN_CONF_PATH=etc/neutron/plugins/nicira
     Q_PLUGIN_CONF_FILENAME=nvp.ini
     Q_DB_NAME="neutron_nvp"
-    Q_PLUGIN_CLASS="neutron.plugins.nicira.nicira_nvp_plugin.NeutronPlugin.NvpPluginV2"
+    Q_PLUGIN_CLASS="neutron.plugins.nicira.NeutronPlugin.NvpPluginV2"
 }
 
 function neutron_plugin_configure_debug_command() {
diff --git a/lib/neutron_plugins/ovs_base b/lib/neutron_plugins/ovs_base
index 0a2765b..0a53bff 100644
--- a/lib/neutron_plugins/ovs_base
+++ b/lib/neutron_plugins/ovs_base
@@ -44,9 +44,9 @@
         # Ensure that the service is started
         restart_service openvswitch
     elif is_suse; then
-        ### FIXME: Find out if package can be pushed to Factory
-        echo "OpenVSwitch packages can be installed from Cloud:OpenStack:Master in OBS"
-        restart_service openvswitch
+        install_package openvswitch
+        restart_service openvswitch-switch
+        restart_service openvswitch-controller
     fi
 }
 
diff --git a/lib/rpc_backend b/lib/rpc_backend
index 4b04053..462e6cc 100644
--- a/lib/rpc_backend
+++ b/lib/rpc_backend
@@ -170,8 +170,9 @@
         # Set MATCHMAKER_REDIS_HOST if running multi-node.
         MATCHMAKER_REDIS_HOST=${MATCHMAKER_REDIS_HOST:-127.0.0.1}
         iniset $file matchmaker_redis host $MATCHMAKER_REDIS_HOST
-    elif is_service_enabled qpid; then
+    elif is_service_enabled qpid || [ -n "$QPID_HOST" ]; then
         iniset $file $section rpc_backend ${package}.openstack.common.rpc.impl_qpid
+        iniset $file $section qpid_hostname $QPID_HOST
         if is_ubuntu; then
             QPID_PASSWORD=`sudo strings /etc/qpid/qpidd.sasldb | grep -B1 admin | head -1`
             iniset $file $section qpid_password $QPID_PASSWORD
diff --git a/lib/swift b/lib/swift
index 36bca4c..f537989 100644
--- a/lib/swift
+++ b/lib/swift
@@ -271,6 +271,34 @@
         sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
     done
 
+    # Set new accounts in tempauth to match keystone tenant/user (to make testing easier)
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swifttenanttest1_swiftusertest1 "testing .admin"
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swifttenanttest2_swiftusertest2 "testing2 .admin"
+    iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:tempauth user_swifttenanttest1_swiftusertest3 "testing3 .admin"
+
+    testfile=${SWIFT_CONF_DIR}/test.conf
+    cp ${SWIFT_DIR}/test/sample.conf ${testfile}
+
+    # Set accounts for functional tests
+    iniset ${testfile} func_test account swifttenanttest1
+    iniset ${testfile} func_test username swiftusertest1
+    iniset ${testfile} func_test username3 swiftusertest3
+    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}
+        iniset ${testfile} func_test auth_port ${KEYSTONE_AUTH_PORT}
+        iniset ${testfile} func_test auth_prefix /v2.0/
+    fi
+
     swift_log_dir=${SWIFT_DATA_DIR}/logs
     rm -rf ${swift_log_dir}
     mkdir -p ${swift_log_dir}/hourly
@@ -329,6 +357,29 @@
         sudo chown -R $USER: ${node}
     done
 }
+# create_swift_accounts() - Set up common required swift accounts for tests we
+# are all attach names since we want to make it compatible with tempauth which
+# use underscores for separators.
+
+# Tenant               User       Roles
+# ------------------------------------------------------------------
+# swifttenanttest1   swiftusertest1     admin
+# swifttenanttest1   swiftusertest3     anotherrole
+# swifttenanttest2   swiftusertest2     admin
+
+# Migrated from keystone_data.sh
+function create_swift_accounts() {
+    SWIFT_TENANT_TEST1=$(keystone tenant-create --name=swifttenanttest1 | grep " id " | get_field 2)
+    SWIFT_USER_TEST1=$(keystone user-create --name=swiftusertest1 --pass=testing --email=test@example.com | grep " id " | get_field 2)
+    keystone user-role-add --user_id $SWIFT_USER_TEST1 --role_id $ADMIN_ROLE --tenant_id $SWIFT_TENANT_TEST1
+
+    SWIFT_USER_TEST3=$(keystone user-create --name=swiftusertest3 --pass=testing3 --email=test3@example.com | grep " id " | get_field 2)
+    keystone user-role-add --user_id $SWIFT_USER_TEST3 --role_id $ANOTHER_ROLE --tenant_id $SWIFT_TENANT_TEST1
+
+    SWIFT_TENANT_TEST2=$(keystone tenant-create --name=swifttenanttest2 | grep " id " | get_field 2)
+    SWIFT_USER_TEST2=$(keystone user-create --name=swiftusertest2 --pass=testing2 --email=test2@example.com | grep " id " | get_field 2)
+    keystone user-role-add --user_id $SWIFT_USER_TEST2 --role_id $ADMIN_ROLE --tenant_id $SWIFT_TENANT_TEST2
+}
 
 # init_swift() - Initialize rings
 function init_swift() {
diff --git a/stack.sh b/stack.sh
index c4f7944..e2cdb7b 100755
--- a/stack.sh
+++ b/stack.sh
@@ -878,6 +878,7 @@
     export OS_SERVICE_ENDPOINT=$SERVICE_ENDPOINT
     create_keystone_accounts
     create_nova_accounts
+    create_swift_accounts
     create_cinder_accounts
     create_neutron_accounts
 
diff --git a/tools/xen/functions b/tools/xen/functions
index 4e37554..261f14f 100644
--- a/tools/xen/functions
+++ b/tools/xen/functions
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 function xapi_plugin_location {
-    for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/"; do
+    for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" "/usr/lib/xapi/plugins"; do
         if [ -d $PLUGIN_DIR ]; then
             echo $PLUGIN_DIR
             return 0
@@ -40,11 +40,11 @@
     local LOCAL_ZIPBALL=$(mktemp)
     local EXTRACTED_FILES=$(mktemp -d)
 
-    (
+    {
         wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate
         unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES
         rm -f $LOCAL_ZIPBALL
-    ) >&2
+    } >&2
 
     echo "$EXTRACTED_FILES"
 }
diff --git a/tools/xen/mocks b/tools/xen/mocks
index 6da6acb..94b0ca4 100644
--- a/tools/xen/mocks
+++ b/tools/xen/mocks
@@ -34,6 +34,9 @@
 }
 
 function wget {
+    if [[ $@ =~ "failurl" ]]; then
+        exit 1
+    fi
     echo "wget $@" >> $LIST_OF_ACTIONS
 }
 
diff --git a/tools/xen/scripts/manage-vdi b/tools/xen/scripts/manage-vdi
index 05c4b07..381e671 100755
--- a/tools/xen/scripts/manage-vdi
+++ b/tools/xen/scripts/manage-vdi
@@ -32,7 +32,7 @@
   vbd_uuid=$1
 
   dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
-  if [[ "$dev" =~ "sm/" ]]; then
+  if [[ "$dev" =~ "sm/" || "$dev" =~ "blktap-2/" ]]; then
     DEBIAN_FRONTEND=noninteractive \
         apt-get --option "Dpkg::Options::=--force-confold" --assume-yes \
         install kpartx &> /dev/null || true
@@ -49,7 +49,7 @@
 
 function clean_dev_mappings() {
   dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
-  if [[ "$dev" =~ "sm/" ]]; then
+  if [[ "$dev" =~ "sm/" || "$dev" =~ "blktap-2/" ]]; then
     kpartx -dv "/dev/$dev"
   fi
 }
diff --git a/tools/xen/test_functions.sh b/tools/xen/test_functions.sh
index 410df5f..5347238 100755
--- a/tools/xen/test_functions.sh
+++ b/tools/xen/test_functions.sh
@@ -173,6 +173,15 @@
     [ "$RESULT" = "tempdir" ]
 }
 
+function test_extract_remote_zipball_wget_fail {
+    set +e
+
+    local IGNORE
+    IGNORE=$(. mocks && extract_remote_zipball "failurl")
+
+    assert_previous_command_failed
+}
+
 function test_find_nova_plugins {
     local tmpdir=$(mktemp -d)