Merge "Update bashate to 0.5.0"
diff --git a/exercises/euca.sh b/exercises/euca.sh
index c2957e2..60e7d8c 100755
--- a/exercises/euca.sh
+++ b/exercises/euca.sh
@@ -17,7 +17,6 @@
 # an error.  It is also useful for following allowing as the install occurs.
 set -o xtrace
 
-
 # Settings
 # ========
 
@@ -89,7 +88,8 @@
     VOLUME_ZONE=`euca-describe-availability-zones | head -n1 | cut -f2`
     die_if_not_set $LINENO VOLUME_ZONE "Failure to find zone for volume"
 
-    VOLUME=`euca-create-volume -s 1 -z $VOLUME_ZONE | cut -f2`
+    VOLUME=`euca-create-volume -s 1 -z $VOLUME_ZONE` || die $LINENO "Failure to create volume"
+    VOLUME=`echo "$VOLUME" | cut -f2`
     die_if_not_set $LINENO VOLUME "Failure to create volume"
 
     # Test that volume has been created
diff --git a/functions-common b/functions-common
index 2c498a0..9e6fef2 100644
--- a/functions-common
+++ b/functions-common
@@ -380,7 +380,8 @@
         DISTRO="sle${os_RELEASE%.*}"
     elif [[ "$os_VENDOR" =~ (Red.*Hat) || \
         "$os_VENDOR" =~ (CentOS) || \
-        "$os_VENDOR" =~ (OracleLinux) ]]; then
+        "$os_VENDOR" =~ (OracleLinux) || \
+        "$os_VENDOR" =~ (Virtuozzo) ]]; then
         # Drop the . release as we assume it's compatible
         # XXX re-evaluate when we get RHEL10
         DISTRO="rhel${os_RELEASE::1}"
@@ -389,7 +390,26 @@
     elif [[ "$os_VENDOR" =~ (kvmibm) ]]; then
         DISTRO="${os_VENDOR}${os_RELEASE::1}"
     else
-        die $LINENO "Unable to determine DISTRO"
+        # We can't make a good choice here.  Setting a sensible DISTRO
+        # is part of the problem, but not the major issue -- we really
+        # only use DISTRO in the code as a fine-filter.
+        #
+        # The bigger problem is categorising the system into one of
+        # our two big categories as Ubuntu/Debian-ish or
+        # Fedora/CentOS-ish.
+        #
+        # The setting of os_PACKAGE above is only set to "deb" based
+        # on a hard-coded list of vendor names ... thus we will
+        # default to thinking unknown distros are RPM based
+        # (ie. is_ubuntu does not match).  But the platform will then
+        # also not match in is_fedora, because that also has a list of
+        # names.
+        #
+        # So, if you are reading this, getting your distro supported
+        # is really about making sure it matches correctly in these
+        # functions.  Then you can choose a sensible way to construct
+        # DISTRO based on your distros release approach.
+        die $LINENO "Unable to determine DISTRO, can not continue."
     fi
     typeset -xr DISTRO
 }
@@ -421,7 +441,7 @@
 
     [ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || \
         [ "$os_VENDOR" = "CentOS" ] || [ "$os_VENDOR" = "OracleLinux" ] || \
-        [ "$os_VENDOR" = "CloudLinux" ] || [ "$os_VENDOR" = "kvmibm" ]
+        [ "$os_VENDOR" = "Virtuozzo" ] || [ "$os_VENDOR" = "kvmibm" ]
 }
 
 
diff --git a/lib/databases/postgresql b/lib/databases/postgresql
index 852bac4..14425a5 100644
--- a/lib/databases/postgresql
+++ b/lib/databases/postgresql
@@ -47,7 +47,7 @@
 }
 
 function configure_database_postgresql {
-    local pg_conf pg_dir pg_hba root_roles
+    local pg_conf pg_dir pg_hba root_roles version
     echo_summary "Configuring and starting PostgreSQL"
     if is_fedora; then
         pg_hba=/var/lib/pgsql/data/pg_hba.conf
@@ -56,6 +56,13 @@
             sudo postgresql-setup initdb
         fi
     elif is_ubuntu; then
+        version=`psql --version | cut -d ' ' -f3 | cut -d. -f1-2`
+        if vercmp $version '>=' 9.3; then
+            if [ -z "`pg_lsclusters -h`" ]; then
+                echo 'No PostgreSQL clusters exist; will create one'
+                sudo pg_createcluster $version main --start
+            fi
+        fi
         pg_dir=`find /etc/postgresql -name pg_hba.conf|xargs dirname`
         pg_hba=$pg_dir/pg_hba.conf
         pg_conf=$pg_dir/postgresql.conf
diff --git a/lib/neutron-legacy b/lib/neutron-legacy
index 7d6e881..e06a020 100644
--- a/lib/neutron-legacy
+++ b/lib/neutron-legacy
@@ -486,8 +486,7 @@
 }
 
 function create_nova_conf_neutron {
-    iniset $NOVA_CONF DEFAULT network_api_class "nova.network.neutronv2.api.API"
-
+    iniset $NOVA_CONF DEFAULT use_neutron True
     iniset $NOVA_CONF neutron auth_type "password"
     iniset $NOVA_CONF neutron auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v3"
     iniset $NOVA_CONF neutron username "$Q_ADMIN_USERNAME"
@@ -502,7 +501,6 @@
     if [[ "$Q_USE_SECGROUP" == "True" ]]; then
         LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
         iniset $NOVA_CONF DEFAULT firewall_driver $LIBVIRT_FIREWALL_DRIVER
-        iniset $NOVA_CONF DEFAULT security_group_api neutron
     fi
 
     # optionally set options in nova_conf
diff --git a/lib/tempest b/lib/tempest
index 4fb3e5e..3b8a888 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -414,12 +414,15 @@
         if [[ ! -z "$HEAT_CFN_IMAGE_URL" ]]; then
             iniset $TEMPEST_CONFIG orchestration image_ref $(basename "${HEAT_CFN_IMAGE_URL%.*}")
         fi
-        # build a specialized heat flavor
-        available_flavors=$(nova flavor-list)
-        if [[ ! ( $available_flavors =~ 'm1.heat' ) ]]; then
-            nova flavor-create m1.heat 451 512 0 1
+        # Nova might not be enabled, especially when we want to test tempest scenario/API that only create Neutron resources
+        if is_service_enabled nova; then
+            # build a specialized heat flavor
+            available_flavors=$(nova flavor-list)
+            if [[ ! ( $available_flavors =~ 'm1.heat' ) ]]; then
+                nova flavor-create m1.heat 451 512 0 1
+            fi
+            iniset $TEMPEST_CONFIG orchestration instance_type "m1.heat"
         fi
-        iniset $TEMPEST_CONFIG orchestration instance_type "m1.heat"
         iniset $TEMPEST_CONFIG orchestration build_timeout 900
         iniset $TEMPEST_CONFIG orchestration stack_owner_role "_member_"
     fi
diff --git a/tests/test_package_ordering.sh b/tests/test_package_ordering.sh
index a568abf..bfc2a19 100755
--- a/tests/test_package_ordering.sh
+++ b/tests/test_package_ordering.sh
@@ -7,6 +7,7 @@
 
 source $TOP/tests/unittest.sh
 
+export LC_ALL=en_US.UTF-8
 PKG_FILES=$(find $TOP/files/debs $TOP/files/rpms $TOP/files/rpms-suse -type f)
 
 TMPDIR=$(mktemp -d)
diff --git a/tools/generate-devstack-plugins-list.sh b/tools/generate-devstack-plugins-list.sh
index 8a1f743..be3f60a 100644
--- a/tools/generate-devstack-plugins-list.sh
+++ b/tools/generate-devstack-plugins-list.sh
@@ -41,7 +41,9 @@
 (
 declare -A plugins
 
-test -r data/devstack-plugins-registry.header && cat data/devstack-plugins-registry.header
+if [[ -r data/devstack-plugins-registry.header ]]; then
+    cat data/devstack-plugins-registry.header
+fi
 
 sorted_plugins=$(python tools/generate-devstack-plugins-list.py)
 
@@ -52,7 +54,9 @@
     printf "+----------------------------+-------------------------------------------------------------------------+\n"
 done
 
-test -r data/devstack-plugins-registry.footer && cat data/devstack-plugins-registry.footer
+if [[ -r data/devstack-plugins-registry.footer ]]; then
+    cat data/devstack-plugins-registry.footer
+fi
 ) > doc/source/plugin-registry.rst
 
 if [[ -n ${1} ]]; then
diff --git a/tools/worlddump.py b/tools/worlddump.py
index 01f601c..72a257f 100755
--- a/tools/worlddump.py
+++ b/tools/worlddump.py
@@ -58,8 +58,8 @@
     try:
         subprocess.check_call(cmd, shell=True)
         print
-    except subprocess.CalledProcessError:
-        print "*** Failed to run: %s" % cmd
+    except subprocess.CalledProcessError as e:
+        print "*** Failed to run '%(cmd)s': %(err)s" % {'cmd': cmd, 'err': e}
 
 
 def _find_cmd(cmd):