Merge "Handle trove service availabilty in tempest."
diff --git a/functions b/functions
index e79e1d5..6f09685 100644
--- a/functions
+++ b/functions
@@ -1364,11 +1364,11 @@
     if [[ $image_url != file* ]]; then
         # Downloads the image (uec ami+aki style), then extracts it.
         if [[ ! -f $FILES/$IMAGE_FNAME || "$(stat -c "%s" $FILES/$IMAGE_FNAME)" = "0" ]]; then
-             wget -c $image_url -O $FILES/$IMAGE_FNAME
-             if [[ $? -ne 0 ]]; then
-                 echo "Not found: $image_url"
-                 return
-             fi
+            wget -c $image_url -O $FILES/$IMAGE_FNAME
+            if [[ $? -ne 0 ]]; then
+                echo "Not found: $image_url"
+                return
+            fi
         fi
         IMAGE="$FILES/${IMAGE_FNAME}"
     else
@@ -1420,7 +1420,7 @@
         vmdk_create_type="${vmdk_create_type%?}"
 
         descriptor_data_pair_msg="Monolithic flat and VMFS disks "`
-                                 `"should use a descriptor-data pair."
+                                    `"should use a descriptor-data pair."
         if [[ "$vmdk_create_type" = "monolithicSparse" ]]; then
             vmdk_disktype="sparse"
         elif [[ "$vmdk_create_type" = "monolithicFlat" || \
@@ -1435,7 +1435,7 @@
             path_len=`expr ${#image_url} - ${#IMAGE_FNAME}`
             flat_url="${image_url:0:$path_len}$flat_fname"
             warn $LINENO "$descriptor_data_pair_msg"`
-                         `" Attempt to retrieve the *-flat.vmdk: $flat_url"
+                            `" Attempt to retrieve the *-flat.vmdk: $flat_url"
             if [[ $flat_url != file* ]]; then
                 if [[ ! -f $FILES/$flat_fname || \
                 "$(stat -c "%s" $FILES/$flat_fname)" = "0" ]]; then
@@ -1474,7 +1474,7 @@
                 flat_path="${image_url:0:$path_len}"
                 descriptor_url=$flat_path$descriptor_fname
                 warn $LINENO "$descriptor_data_pair_msg"`
-                             `" Attempt to retrieve the descriptor *.vmdk: $descriptor_url"
+                                `" Attempt to retrieve the descriptor *.vmdk: $descriptor_url"
                 if [[ $flat_path != file* ]]; then
                     if [[ ! -f $FILES/$descriptor_fname || \
                     "$(stat -c "%s" $FILES/$descriptor_fname)" = "0" ]]; then
@@ -1489,8 +1489,8 @@
                     descriptor_url=$(echo $descriptor_url | sed "s/^file:\/\///g")
                     if [[ ! -f $descriptor_url || \
                     "$(stat -c "%s" $descriptor_url)" == "0" ]]; then
-                         warn $LINENO "Descriptor not found $descriptor_url"
-                         descriptor_found=false
+                        warn $LINENO "Descriptor not found $descriptor_url"
+                        descriptor_found=false
                     fi
                 fi
                 if $descriptor_found; then
@@ -1498,10 +1498,10 @@
                     `"grep -a -F -m 1 'ddb.adapterType =' $descriptor_url)"
                     vmdk_adapter_type="${vmdk_adapter_type#*\"}"
                     vmdk_adapter_type="${vmdk_adapter_type%?}"
-                 fi
-             fi
-             #TODO(alegendre): handle streamOptimized once supported by the VMware driver.
-             vmdk_disktype="preallocated"
+                fi
+            fi
+            #TODO(alegendre): handle streamOptimized once supported by the VMware driver.
+            vmdk_disktype="preallocated"
         else
             #TODO(alegendre): handle streamOptimized once supported by the VMware driver.
             vmdk_disktype="preallocated"
diff --git a/lib/databases/postgresql b/lib/databases/postgresql
index 519479a..60e5a33 100644
--- a/lib/databases/postgresql
+++ b/lib/databases/postgresql
@@ -64,9 +64,13 @@
     sudo sed -i "/^host/s/all\s\+::1\/128\s\+ident/$DATABASE_USER\t::0\/0\tpassword/" $PG_HBA
     restart_service postgresql
 
-    # If creating the role fails, chances are it already existed. Try to alter it.
-    sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'" || \
-    sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
+    # Create the role if it's not here or else alter it.
+    root_roles=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='root'")
+    if [[ ${root_roles} == *HERE ]];then
+        sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
+    else
+        sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
+    fi
 }
 
 function install_database_postgresql {
diff --git a/lib/nova b/lib/nova
index e754341..39685a8 100644
--- a/lib/nova
+++ b/lib/nova
@@ -377,6 +377,7 @@
     iniset $NOVA_CONF DEFAULT osapi_compute_workers "4"
     iniset $NOVA_CONF DEFAULT ec2_workers "4"
     iniset $NOVA_CONF DEFAULT metadata_workers "4"
+    iniset $NOVA_CONF conductor workers "4"
     iniset $NOVA_CONF DEFAULT sql_connection `database_connection_url nova`
     iniset $NOVA_CONF DEFAULT fatal_deprecations "True"
     iniset $NOVA_CONF DEFAULT instance_name_template "${INSTANCE_NAME_PREFIX}%08x"
diff --git a/lib/oslo b/lib/oslo
index 816ae9a..f644ed7 100644
--- a/lib/oslo
+++ b/lib/oslo
@@ -22,6 +22,7 @@
 # --------
 OSLOCFG_DIR=$DEST/oslo.config
 OSLOMSG_DIR=$DEST/oslo.messaging
+OSLORWRAP_DIR=$DEST/oslo.rootwrap
 
 # Entry Points
 # ------------
@@ -37,6 +38,9 @@
 
     git_clone $OSLOMSG_REPO $OSLOMSG_DIR $OSLOMSG_BRANCH
     setup_develop $OSLOMSG_DIR
+
+    git_clone $OSLORWRAP_REPO $OSLORWRAP_DIR $OSLORWRAP_BRANCH
+    setup_develop $OSLORWRAP_DIR
 }
 
 # cleanup_oslo() - purge possibly old versions of oslo
diff --git a/stackrc b/stackrc
index 695bdb1..3fdc566 100644
--- a/stackrc
+++ b/stackrc
@@ -136,6 +136,10 @@
 OSLOMSG_REPO=${OSLOMSG_REPO:-${GIT_BASE}/openstack/oslo.messaging.git}
 OSLOMSG_BRANCH=${OSLOMSG_BRANCH:-master}
 
+# oslo.rootwrap
+OSLORWRAP_REPO=${OSLORWRAP_REPO:-${GIT_BASE}/openstack/oslo.rootwrap.git}
+OSLORWRAP_BRANCH=${OSLORWRAP_BRANCH:-master}
+
 # pbr drives the setuptools configs
 PBR_REPO=${PBR_REPO:-${GIT_BASE}/openstack-dev/pbr.git}
 PBR_BRANCH=${PBR_BRANCH:-master}