Merge "Update again and retry a failed package install"
diff --git a/lib/apache b/lib/apache
index 55083e7..baf0fbc 100644
--- a/lib/apache
+++ b/lib/apache
@@ -31,13 +31,13 @@
 # Set up apache name and configuration directory
 if is_ubuntu; then
     APACHE_NAME=apache2
-    APACHE_CONF_DIR=sites-available
+    APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/sites-available}
 elif is_fedora; then
     APACHE_NAME=httpd
-    APACHE_CONF_DIR=conf.d
+    APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/conf.d}
 elif is_suse; then
     APACHE_NAME=apache2
-    APACHE_CONF_DIR=vhosts.d
+    APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/vhosts.d}
 fi
 
 # Functions
@@ -108,14 +108,14 @@
         local apache_version=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
         if [[ "$apache_version" =~ ^2\.2\. ]]; then
             # Ubuntu 12.04 - Apache 2.2
-            echo /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}
+            echo $APACHE_CONF_DIR/${site}
         else
             # Ubuntu 14.04 - Apache 2.4
-            echo /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf
+            echo $APACHE_CONF_DIR/${site}.conf
         fi
     elif is_fedora; then
         # fedora conf.d is only imported if it ends with .conf so this is approx the same
-        local enabled_site_file="/etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf"
+        local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
         if [ -f $enabled_site_file ]; then
             echo ${enabled_site_file}
         else
@@ -130,8 +130,11 @@
     if is_ubuntu; then
         sudo a2ensite ${site}
     elif is_fedora; then
-        # fedora conf.d is only imported if it ends with .conf so this is approx the same
-        sudo mv /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf.disabled /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf
+        local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
+        # Do nothing if site already enabled or no site config exists
+        if [[ -f ${enabled_site_file}.disabled ]] && [[ ! -f ${enabled_site_file} ]]; then
+            sudo mv ${enabled_site_file}.disabled ${enabled_site_file}
+        fi
     fi
 }
 
@@ -141,7 +144,11 @@
     if is_ubuntu; then
         sudo a2dissite ${site}
     elif is_fedora; then
-        sudo mv /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf /etc/$APACHE_NAME/$APACHE_CONF_DIR/${site}.conf.disabled
+        local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
+        # Do nothing if no site config exists
+        if [[ -f ${enabled_site_file} ]]; then
+            sudo mv ${enabled_site_file} ${enabled_site_file}.disabled
+        fi
     fi
 }
 
diff --git a/lib/horizon b/lib/horizon
index 9e4f2f9..02715ce 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -75,6 +75,9 @@
             sudo rm /usr/bin/node
         fi
     fi
+
+    local horizon_conf=$(apache_site_config_for horizon)
+    sudo rm -f $horizon_conf
 }
 
 # configure_horizon() - Set config files, create data dirs, etc
@@ -123,21 +126,6 @@
     fi
 
     local horizon_conf=$(apache_site_config_for horizon)
-    if is_ubuntu; then
-        disable_apache_site 000-default
-        sudo touch $horizon_conf
-        enable_apache_site horizon
-    elif is_fedora; then
-        sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
-    elif is_suse; then
-        : # nothing to do
-    else
-        exit_distro_not_supported "horizon apache configuration"
-    fi
-
-    # Remove old log files that could mess with how devstack detects whether Horizon
-    # has been successfully started (see start_horizon() and functions::screen_it())
-    sudo rm -f /var/log/$APACHE_NAME/horizon_*
 
     # Configure apache to run horizon
     sudo sh -c "sed -e \"
@@ -148,6 +136,23 @@
         s,%DEST%,$DEST,g;
         s,%HORIZON_REQUIRE%,$HORIZON_REQUIRE,g;
     \" $FILES/apache-horizon.template >$horizon_conf"
+
+    if is_ubuntu; then
+        disable_apache_site 000-default
+        sudo touch $horizon_conf
+    elif is_fedora; then
+        sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
+    elif is_suse; then
+        : # nothing to do
+    else
+        exit_distro_not_supported "horizon apache configuration"
+    fi
+    enable_apache_site horizon
+
+    # Remove old log files that could mess with how devstack detects whether Horizon
+    # has been successfully started (see start_horizon() and functions::screen_it())
+    sudo rm -f /var/log/$APACHE_NAME/horizon_*
+
 }
 
 # install_horizon() - Collect source and prepare
diff --git a/lib/nova_plugins/functions-libvirt b/lib/nova_plugins/functions-libvirt
index f435456..a6738e2 100644
--- a/lib/nova_plugins/functions-libvirt
+++ b/lib/nova_plugins/functions-libvirt
@@ -29,19 +29,10 @@
         install_package python-libguestfs
     fi
 
-    # workaround for
-    # https://bugzilla.redhat.com/show_bug.cgi?id=1098376; if we see
-    # the empty Xen proc file then remove the xen/libxl plugin
-    # shared-libraries (yum remove would uninstall libvirt due to
-    # dependencies, so let's avoid that...)
-    if is_fedora && [ -f /proc/xen/capabilities ] && \
-        [ $(stat -c '%s' /proc/xen/capabilities) -eq 0 ]; then
-        sudo rm -f /usr/lib64/libvirt/connection-driver/libvirt_driver_libxl.so
-        sudo rm -f /usr/lib64/libvirt/connection-driver/libvirt_driver_xen.so
-
-        # another bug requires these to be restarted to avoid
-        # potential hang of libvirtd
-        # https://bugzilla.redhat.com/show_bug.cgi?id=1098866
+    # Restart dbus/firewalld after install of libvirt to avoid a
+    # problem with polkit, which libvirtd brings in.  See
+    # https://bugzilla.redhat.com/show_bug.cgi?id=1099031
+    if is_fedora; then
         sudo service dbus restart
         sudo service firewalld restart
     fi
diff --git a/lib/tempest b/lib/tempest
index 79412f9..64b5453 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -336,6 +336,11 @@
     # Large Ops Number
     iniset $TEMPEST_CONFIG scenario large_ops_number ${TEMPEST_LARGE_OPS_NUMBER:-0}
 
+    # Telemetry
+    # Ceilometer API optimization happened in juno that allows to run more tests in tempest.
+    # Once Tempest retires support for icehouse this flag can be removed.
+    iniset $TEMPEST_CONFIG telemetry too_slow_to_test "False"
+
     # Volume
     if ! is_service_enabled c-bak; then
         iniset $TEMPEST_CONFIG volume-feature-enabled backup False
diff --git a/tools/install_pip.sh b/tools/install_pip.sh
index d3f5e78..585112a 100755
--- a/tools/install_pip.sh
+++ b/tools/install_pip.sh
@@ -60,4 +60,6 @@
 
 install_get_pip
 
+pip_install -U setuptools
+
 get_versions