Merge "Use 'which pip' rather than /usr/bin/pip"
diff --git a/files/apts/nova b/files/apts/nova
index c16a708..b7d1e92 100644
--- a/files/apts/nova
+++ b/files/apts/nova
@@ -16,6 +16,7 @@
 sudo
 kvm
 libvirt-bin # NOPRIME
+libjs-jquery-tablesorter # Needed for coverage html reports
 vlan
 curl
 rabbitmq-server # NOPRIME
diff --git a/functions b/functions
index bb03c55..294c380 100644
--- a/functions
+++ b/functions
@@ -710,27 +710,6 @@
 }
 
 
-# HTTP and HTTPS proxy servers are supported via the usual environment variables [1]
-# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in
-# ``localrc`` or on the command line if necessary::
-#
-# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html
-#
-#     http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
-
-function re_export_proxy_variables() {
-    if [[ -n "$http_proxy" ]]; then
-        export http_proxy=$http_proxy
-    fi
-    if [[ -n "$https_proxy" ]]; then
-        export https_proxy=$https_proxy
-    fi
-    if [[ -n "$no_proxy" ]]; then
-        export no_proxy=$no_proxy
-    fi
-}
-
-
 # Helper to launch a service in a named screen
 # screen_it service "command-line"
 function screen_it {
diff --git a/lib/baremetal b/lib/baremetal
index 62605fb..112fd6d 100644
--- a/lib/baremetal
+++ b/lib/baremetal
@@ -211,9 +211,7 @@
 
     # ensure dnsmasq is installed but not running
     # because baremetal driver will reconfigure and restart this as needed
-    if [ ! is_package_installed dnsmasq ]; then
-        install_package dnsmasq
-    fi
+    is_package_installed dnsmasq || install_package dnsmasq
     stop_service dnsmasq
 }
 
@@ -256,12 +254,10 @@
     ari=$2
     nova flavor-create $BM_FLAVOR_NAME $BM_FLAVOR_ID \
             $BM_FLAVOR_RAM $BM_FLAVOR_ROOT_DISK $BM_FLAVOR_CPU
-    nova-manage instance_type set_key \
-        --name=$BM_FLAVOR_NAME --key cpu_arch --value $BM_FLAVOR_ARCH
-    nova-manage instance_type set_key \
-        --name=$BM_FLAVOR_NAME --key deploy_kernel_id --value $aki
-    nova-manage instance_type set_key \
-        --name=$BM_FLAVOR_NAME --key deploy_ramdisk_id --value $ari
+    nova flavor-key $BM_FLAVOR_NAME set \
+            cpu_arch=$BM_FLAVOR_ARCH \
+            deploy_kernel_id=$aki \
+            deploy_ramdisk_id=$ari
 }
 
 # pull run-time kernel/ramdisk out of disk image and load into glance
diff --git a/lib/cinder b/lib/cinder
index 701effd..385a5a2 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -173,10 +173,10 @@
 
     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
         # Add color to logging output
-        iniset $CINDER_CONF DEFAULT logging_context_format_string "%(asctime)s %(color)s%(levelname)s %(name)s [%(request_id)s %(user_id)s %(project_id)s%(color)s] %(instance)s%(color)s%(message)s"
-        iniset $CINDER_CONF DEFAULT logging_default_format_string "%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
+        iniset $CINDER_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)d %(color)s%(levelname)s %(name)s [%(request_id)s %(user_id)s %(project_id)s%(color)s] %(instance)s%(color)s%(message)s"
+        iniset $CINDER_CONF DEFAULT logging_default_format_string "%(asctime)s.%(msecs)d %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
         iniset $CINDER_CONF DEFAULT logging_debug_format_suffix "from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
-        iniset $CINDER_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s TRACE %(name)s %(instance)s"
+        iniset $CINDER_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)d TRACE %(name)s %(instance)s"
     fi
 
     if [ "$CINDER_DRIVER" == "XenAPINFS" ]; then
diff --git a/lib/nova b/lib/nova
index 594195e..4fef552 100644
--- a/lib/nova
+++ b/lib/nova
@@ -408,13 +408,13 @@
     fi
     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
         # Add color to logging output
-        add_nova_opt "logging_context_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s%(color)s] %(instance)s%(color)s%(message)s"
-        add_nova_opt "logging_default_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
+        add_nova_opt "logging_context_format_string=%(asctime)s.%(msecs)d %(color)s%(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s%(color)s] %(instance)s%(color)s%(message)s"
+        add_nova_opt "logging_default_format_string=%(asctime)s.%(msecs)d %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
         add_nova_opt "logging_debug_format_suffix=from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
-        add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s TRACE %(name)s %(instance)s"
+        add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s.%(msecs)d TRACE %(name)s %(instance)s"
     else
         # Show user_name and project_name instead of user_id and project_id
-        add_nova_opt "logging_context_format_string=%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
+        add_nova_opt "logging_context_format_string=%(asctime)s.%(msecs) %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
     fi
     if is_service_enabled ceilometer; then
         add_nova_opt "instance_usage_audit=True"
diff --git a/lib/tempest b/lib/tempest
index 190d77f..d08daeb 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -82,30 +82,34 @@
     # first image returned and set ``image_uuid_alt`` to the second,
     # if there is more than one returned...
     # ... Also ensure we only take active images, so we don't get snapshots in process
-    image_lines=`glance image-list`
-    IFS=$'\n\r'
-    images=""
-    for line in $image_lines; do
-        if [ -z $DEFAULT_IMAGE_NAME ]; then
-            images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`"
-        else
-            images="$images `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | grep "$DEFAULT_IMAGE_NAME" | cut -d' ' -f2`"
+    declare -a images
+
+    while read -r IMAGE_NAME IMAGE_UUID; do
+        if [ "$IMAGE_NAME" = "$DEFAULT_IMAGE_NAME" ]; then
+            image_uuid="$IMAGE_UUID"
+            image_uuid_alt="$IMAGE_UUID"
         fi
-    done
-    # Create array of image UUIDs...
-    IFS=" "
-    images=($images)
-    num_images=${#images[*]}
-    echo "Found $num_images images"
-    if [[ $num_images -eq 0 ]]; then
-        echo "Found no valid images to use!"
-        exit 1
-    fi
-    image_uuid=${images[0]}
-    image_uuid_alt=$image_uuid
-    if [[ $num_images -gt 1 ]]; then
-        image_uuid_alt=${images[1]}
-    fi
+        images+=($IMAGE_UUID)
+    done < <(glance image-list --status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
+
+    case "${#images[*]}" in
+        0)
+            echo "Found no valid images to use!"
+            exit 1
+            ;;
+        1)
+            if [ -z "$image_uuid" ]; then
+                image_uuid=${images[0]}
+                image_uuid_alt=${images[0]}
+            fi
+            ;;
+        *)
+            if [ -z "$image_uuid" ]; then
+                image_uuid=${images[0]}
+                image_uuid_alt=${images[1]}
+            fi
+            ;;
+    esac
 
     # Create tempest.conf from tempest.conf.sample
     # copy every time, because the image UUIDS are going to change
diff --git a/stack.sh b/stack.sh
index 7306b58..9f734b9 100755
--- a/stack.sh
+++ b/stack.sh
@@ -648,7 +648,25 @@
 
 # Install package requirements
 echo_summary "Installing package prerequisites"
-$TOP_DIR/tools/install_prereqs.sh
+if is_ubuntu; then
+    install_package $(get_packages $FILES/apts)
+elif is_fedora; then
+    install_package $(get_packages $FILES/rpms)
+elif is_suse; then
+    install_package $(get_packages $FILES/rpms-suse)
+else
+    exit_distro_not_supported "list of packages"
+fi
+
+if [[ $SYSLOG != "False" ]]; then
+    if is_ubuntu || is_fedora; then
+        install_package rsyslog-relp
+    elif is_suse; then
+        install_package rsyslog-module-relp
+    else
+        exit_distro_not_supported "rsyslog-relp installation"
+    fi
+fi
 
 if is_service_enabled rabbit; then
     # Install rabbitmq-server
diff --git a/tools/install_prereqs.sh b/tools/install_prereqs.sh
deleted file mode 100755
index 0bf217b..0000000
--- a/tools/install_prereqs.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env bash
-
-# **install_prereqs.sh**
-
-# Install system package prerequisites
-#
-# install_prereqs.sh [-f]
-#
-# -f        Force an install run now
-
-
-if [[ -n "$1" &&  "$1" = "-f" ]]; then
-    FORCE=1
-fi
-
-# Keep track of the devstack directory
-TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
-
-# Import common functions
-source $TOP_DIR/functions
-
-# Determine what system we are running on.  This provides ``os_VENDOR``,
-# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
-# and ``DISTRO``
-GetDistro
-
-# Needed to get ``ENABLED_SERVICES``
-source $TOP_DIR/stackrc
-
-# Prereq dirs are here
-FILES=$TOP_DIR/files
-
-# Minimum wait time
-PREREQ_RERUN_MARKER=${PREREQ_RERUN_MARKER:-$TOP_DIR/.prereqs}
-PREREQ_RERUN_HOURS=${PREREQ_RERUN_HOURS:-2}
-PREREQ_RERUN_SECONDS=$((60*60*$PREREQ_RERUN_HOURS))
-
-NOW=$(date "+%s")
-LAST_RUN=$(head -1 $PREREQ_RERUN_MARKER 2>/dev/null || echo "0")
-DELTA=$(($NOW - $LAST_RUN))
-if [[ $DELTA -lt $PREREQ_RERUN_SECONDS && -z "$FORCE" ]]; then
-    echo "Re-run time has not expired ($(($PREREQ_RERUN_SECONDS - $DELTA)) seconds remaining); exiting..."
-    exit 0
-fi
-
-# Make sure the proxy config is visible to sub-processes
-re_export_proxy_variables
-
-# Install Packages
-# ================
-
-# Install package requirements
-if is_ubuntu; then
-    install_package $(get_packages $FILES/apts)
-elif is_fedora; then
-    install_package $(get_packages $FILES/rpms)
-elif is_suse; then
-    install_package $(get_packages $FILES/rpms-suse)
-else
-    exit_distro_not_supported "list of packages"
-fi
-
-if [[ -n "$SYSLOG" && "$SYSLOG" != "False" ]]; then
-    if is_ubuntu || is_fedora; then
-        install_package rsyslog-relp
-    elif is_suse; then
-        install_package rsyslog-module-relp
-    else
-        exit_distro_not_supported "rsyslog-relp installation"
-    fi
-fi
-
-
-# Mark end of run
-# ---------------
-
-date "+%s" >$PREREQ_RERUN_MARKER
-date >>$PREREQ_RERUN_MARKER