Merge "Make python-guestfs NOPRIME & install for libvirt"
diff --git a/functions-common b/functions-common
index 79003fc..4bc3bba 100644
--- a/functions-common
+++ b/functions-common
@@ -222,6 +222,8 @@
     fi
     backtrace 2
     err $line "$*"
+    # Give buffers a second to flush
+    sleep 1
     exit $exitcode
 }
 
diff --git a/lib/databases/mysql b/lib/databases/mysql
index 31e7163..f5ee3c0 100644
--- a/lib/databases/mysql
+++ b/lib/databases/mysql
@@ -21,7 +21,7 @@
     if is_ubuntu; then
         # Get ruthless with mysql
         stop_service $MYSQL
-        sudo aptitude purge -y ~nmysql-server
+        apt_get purge -y mysql*
         sudo rm -rf /var/lib/mysql
         return
     elif is_fedora; then
diff --git a/lib/databases/postgresql b/lib/databases/postgresql
index c459feb..96a5947 100644
--- a/lib/databases/postgresql
+++ b/lib/databases/postgresql
@@ -21,7 +21,7 @@
     stop_service postgresql
     if is_ubuntu; then
         # Get ruthless with mysql
-        sudo aptitude purge -y  ~npostgresql
+        apt_get purge -y postgresql*
         return
     elif is_fedora; then
         uninstall_package postgresql-server
diff --git a/lib/heat b/lib/heat
index af10fa6..972c35c 100644
--- a/lib/heat
+++ b/lib/heat
@@ -207,6 +207,16 @@
         --description "Owns users and projects created by heat" \
         | grep ' id ' | get_field 2)
     iniset $HEAT_CONF DEFAULT stack_user_domain ${D_ID}
+
+    openstack --os-token $OS_TOKEN --os-url=$KS_ENDPOINT_V3 \
+        --os-identity-api-version=3 user create --password $SERVICE_PASSWORD \
+        --domain $D_ID heat_domain_admin \
+        --description "Manages users and projects created by heat"
+    openstack --os-token $OS_TOKEN --os-url=$KS_ENDPOINT_V3 \
+        --os-identity-api-version=3 role add \
+        --user heat_domain_admin --domain ${D_ID} admin
+    iniset $HEAT_CONF DEFAULT stack_domain_admin heat_domain_admin
+    iniset $HEAT_CONF DEFAULT stack_domain_admin_password $SERVICE_PASSWORD
 }
 
 # Restore xtrace
diff --git a/lib/oslo b/lib/oslo
index b089842..516ce1c 100644
--- a/lib/oslo
+++ b/lib/oslo
@@ -24,6 +24,7 @@
 OSLOCFG_DIR=$DEST/oslo.config
 OSLOMSG_DIR=$DEST/oslo.messaging
 OSLORWRAP_DIR=$DEST/oslo.rootwrap
+OSLOVMWARE_DIR=$DEST/oslo.vmware
 PYCADF_DIR=$DEST/pycadf
 STEVEDORE_DIR=$DEST/stevedore
 TASKFLOW_DIR=$DEST/taskflow
@@ -49,6 +50,9 @@
     git_clone $OSLORWRAP_REPO $OSLORWRAP_DIR $OSLORWRAP_BRANCH
     setup_develop $OSLORWRAP_DIR
 
+    git_clone $OSLOVMWARE_REPO $OSLOVMWARE_DIR $OSLOVMWARE_BRANCH
+    setup_develop $OSLOVMWARE_DIR
+
     git_clone $PYCADF_REPO $PYCADF_DIR $PYCADF_BRANCH
     setup_develop $PYCADF_DIR
 
diff --git a/lib/rpc_backend b/lib/rpc_backend
index 3651bc0..34f576f 100644
--- a/lib/rpc_backend
+++ b/lib/rpc_backend
@@ -67,7 +67,7 @@
         sudo killall epmd || sudo killall -9 epmd
         if is_ubuntu; then
             # And the Erlang runtime too
-            sudo aptitude purge -y ~nerlang
+            apt_get purge -y erlang*
         fi
     elif is_service_enabled qpid; then
         if is_fedora; then
diff --git a/stack.sh b/stack.sh
index 22a418f..eeb08d5 100755
--- a/stack.sh
+++ b/stack.sh
@@ -194,6 +194,10 @@
         yum_install ${RHEL6_EPEL_RPM} || \
             die $LINENO "Error installing EPEL repo, cannot continue"
     fi
+
+    # ... and also optional to be enabled
+    sudo yum-config-manager --enable rhel-6-server-optional-rpms
+
 fi
 
 
@@ -522,7 +526,7 @@
     exec 3>&1
     if [[ "$VERBOSE" == "True" ]]; then
         # Redirect stdout/stderr to tee to write the log file
-        exec 1> >( awk '
+        exec 1> >( awk -v logfile=${LOGFILE} '
                 /((set \+o$)|xtrace)/ { next }
                 {
                     cmd ="date +\"%Y-%m-%d %H:%M:%S.%3N | \""
@@ -530,8 +534,9 @@
                     close("date +\"%Y-%m-%d %H:%M:%S.%3N | \"")
                     sub(/^/, now)
                     print
-                    fflush()
-                }' | tee "${LOGFILE}" ) 2>&1
+                    print > logfile
+                    fflush("")
+                }' ) 2>&1
         # Set up a second fd for output
         exec 6> >( tee "${SUMFILE}" )
     else
@@ -579,21 +584,24 @@
 # -----------------------
 
 # Kill background processes on exit
-trap clean EXIT
-clean() {
+trap exit_trap EXIT
+function exit_trap {
     local r=$?
-    kill >/dev/null 2>&1 $(jobs -p)
+    echo "exit_trap called, cleaning up child processes"
+    kill 2>&1 $(jobs -p)
     exit $r
 }
 
-
 # Exit on any errors so that errors don't compound
-trap failed ERR
-failed() {
+trap err_trap ERR
+function err_trap {
     local r=$?
-    kill >/dev/null 2>&1 $(jobs -p)
     set +o xtrace
-    [ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE"
+    if [[ -n "$LOGFILE" ]]; then
+        echo "${0##*/} failed: full log in $LOGFILE"
+    else
+        echo "${0##*/} failed"
+    fi
     exit $r
 }
 
diff --git a/stackrc b/stackrc
index 0b081c4..91f5751 100644
--- a/stackrc
+++ b/stackrc
@@ -167,6 +167,10 @@
 OSLORWRAP_REPO=${OSLORWRAP_REPO:-${GIT_BASE}/openstack/oslo.rootwrap.git}
 OSLORWRAP_BRANCH=${OSLORWRAP_BRANCH:-master}
 
+# oslo.vmware
+OSLOVMWARE_REPO=${OSLOVMWARE_REPO:-${GIT_BASE}/openstack/oslo.vmware.git}
+OSLOVMWARE_BRANCH=${OSLOVMWARE_BRANCH:-master}
+
 # pycadf auditing library
 PYCADF_REPO=${PYCADF_REPO:-${GIT_BASE}/openstack/pycadf.git}
 PYCADF_BRANCH=${PYCADF_BRANCH:-master}
diff --git a/tools/fixup_stuff.sh b/tools/fixup_stuff.sh
index 048024a..47b0cd1 100755
--- a/tools/fixup_stuff.sh
+++ b/tools/fixup_stuff.sh
@@ -98,10 +98,6 @@
         sudo setenforce 0
     fi
 
-    # make sure we have the "optional" repo enabled; it provides some
-    # packages like libffi-devel for example
-    sudo yum-config-manager --enable rhel-6-server-optional-rpms
-
     # If the ``dbus`` package was installed by DevStack dependencies the
     # uuid may not be generated because the service was never started (PR#598200),
     # causing Nova to stop later on complaining that ``/var/lib/dbus/machine-id``