Merge "XenAPI: Always add latest Cirros euc image"
diff --git a/files/apache-keystone.template b/files/apache-keystone.template
index 919452a..805e7b8 100644
--- a/files/apache-keystone.template
+++ b/files/apache-keystone.template
@@ -20,3 +20,7 @@
     LogLevel debug
     CustomLog /var/log/%APACHE_NAME%/access.log combined
 </VirtualHost>
+
+# Workaround for missing path on RHEL6, see
+#  https://bugzilla.redhat.com/show_bug.cgi?id=1121019
+WSGISocketPrefix /var/run/%APACHE_NAME%
diff --git a/functions-common b/functions-common
index 44225ab..9093952 100644
--- a/functions-common
+++ b/functions-common
@@ -435,7 +435,9 @@
         else
             DISTRO="sle${os_RELEASE}sp${os_UPDATE}"
         fi
-    elif [[ "$os_VENDOR" =~ (Red Hat) || "$os_VENDOR" =~ (CentOS) ]]; then
+    elif [[ "$os_VENDOR" =~ (Red Hat) || \
+        "$os_VENDOR" =~ (CentOS) || \
+        "$os_VENDOR" =~ (OracleServer) ]]; then
         # Drop the . release as we assume it's compatible
         DISTRO="rhel${os_RELEASE::1}"
     elif [[ "$os_VENDOR" =~ (XenServer) ]]; then
@@ -463,7 +465,8 @@
         GetOSVersion
     fi
 
-    [ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || [ "$os_VENDOR" = "CentOS" ]
+    [ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || \
+        [ "$os_VENDOR" = "CentOS" ] || [ "$os_VENDOR" = "OracleServer" ]
 }
 
 
diff --git a/lib/apache b/lib/apache
index c0d32df..f4f82a1 100644
--- a/lib/apache
+++ b/lib/apache
@@ -150,7 +150,12 @@
 
 # restart_apache_server
 function restart_apache_server {
-    restart_service $APACHE_NAME
+    # Apache can be slow to stop, doing an explicit stop, sleep, start helps
+    # to mitigate issues where apache will claim a port it's listening on is
+    # still in use and fail to start.
+    stop_service $APACHE_NAME
+    sleep 3
+    start_service $APACHE_NAME
 }
 
 # Restore xtrace
diff --git a/lib/cinder b/lib/cinder
index ce2a5c9..3965687 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -246,13 +246,13 @@
                 configure_cinder_backend_${BE_TYPE} ${BE_NAME}
             fi
             if [[ -z "$default_type" ]]; then
-                default_type=$BE_TYPE}
+                default_type=$BE_TYPE
             fi
             enabled_backends+=$BE_NAME,
         done
         iniset $CINDER_CONF DEFAULT enabled_backends ${enabled_backends%,*}
         if [[ -n "$default_type" ]]; then
-            iniset $CINDER_CONF DEFAULT default_volume_type ${enabled_backends%,*}
+            iniset $CINDER_CONF DEFAULT default_volume_type ${default_type}
         fi
     fi
 
diff --git a/lib/ironic b/lib/ironic
index c24780f..ef136bc 100644
--- a/lib/ironic
+++ b/lib/ironic
@@ -53,12 +53,7 @@
 IRONIC_VM_SSH_ADDRESS=${IRONIC_VM_SSH_ADDRESS:-$HOST_IP}
 IRONIC_VM_COUNT=${IRONIC_VM_COUNT:-1}
 IRONIC_VM_SPECS_CPU=${IRONIC_VM_SPECS_CPU:-1}
-# NOTE(adam_g): Kernels 3.12 and newer user tmpfs by default for initramfs.
-#               DIB produced ramdisks tend to be ~250MB but tmpfs will only allow
-#               use of 50% of available memory before ENOSPC.  Set minimum 1GB
-#               for nodes to avoid (LP: #1311987) and ensure consistency across
-#               older and newer kernels.
-IRONIC_VM_SPECS_RAM=${IRONIC_VM_SPECS_RAM:-1024}
+IRONIC_VM_SPECS_RAM=${IRONIC_VM_SPECS_RAM:-512}
 IRONIC_VM_SPECS_DISK=${IRONIC_VM_SPECS_DISK:-10}
 IRONIC_VM_EPHEMERAL_DISK=${IRONIC_VM_EPHEMERAL_DISK:-0}
 IRONIC_VM_EMULATOR=${IRONIC_VM_EMULATOR:-/usr/bin/qemu-system-x86_64}
diff --git a/lib/tls b/lib/tls
index 02906b7..a84bb76 100644
--- a/lib/tls
+++ b/lib/tls
@@ -18,6 +18,9 @@
 # - configure_proxy
 # - start_tls_proxy
 
+# - stop_tls_proxy
+# - cleanup_CA
+
 # - make_root_CA
 # - make_int_CA
 # - make_cert ca-dir cert-name "common-name" ["alt-name" ...]
@@ -372,6 +375,22 @@
 }
 
 
+# Cleanup Functions
+# ===============
+
+
+# Stops all stud processes. This should be done only after all services
+# using tls configuration are down.
+function stop_tls_proxy {
+    killall stud
+}
+
+
+# Remove CA along with configuration, as well as the local server certificate
+function cleanup_CA {
+    rm -rf "$DATA_DIR/CA" "$DEVSTACK_CERT"
+}
+
 # Tell emacs to use shell-script-mode
 ## Local variables:
 ## mode: shell-script
diff --git a/stack.sh b/stack.sh
index 6d81691..94b90d1 100755
--- a/stack.sh
+++ b/stack.sh
@@ -530,6 +530,12 @@
     echo $@ >&3
 }
 
+if [[ is_fedora && $DISTRO =~ (rhel) ]]; then
+    # poor old python2.6 doesn't have argparse by default, which
+    # outfilter.py uses
+    is_package_installed python-argparse || install_package python-argparse
+fi
+
 # Set up logging for ``stack.sh``
 # Set ``LOGFILE`` to turn on logging
 # Append '.xxxxxxxx' to the given name to maintain history
diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh
index 44e8dc1..12e861e 100755
--- a/tools/xen/install_os_domU.sh
+++ b/tools/xen/install_os_domU.sh
@@ -207,6 +207,8 @@
             -e "s,\(d-i mirror/http/hostname string\).*,\1 $UBUNTU_INST_HTTP_HOSTNAME,g" \
             -e "s,\(d-i mirror/http/directory string\).*,\1 $UBUNTU_INST_HTTP_DIRECTORY,g" \
             -e "s,\(d-i mirror/http/proxy string\).*,\1 $UBUNTU_INST_HTTP_PROXY,g" \
+            -e "s,\(d-i passwd/root-password password\).*,\1 $GUEST_PASSWORD,g" \
+            -e "s,\(d-i passwd/root-password-again password\).*,\1 $GUEST_PASSWORD,g" \
             -i "${HTTP_SERVER_LOCATION}/devstackubuntupreseed.cfg"
     fi
 
@@ -382,10 +384,16 @@
     while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "service devstack status | grep -q running"; do
         sleep 10
     done
-    echo -n "devstack is running"
+    echo -n "devstack service is running, waiting for stack.sh to start logging..."
+
+    while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "test -e /tmp/devstack/log/stack.log"; do
+        sleep 10
+    done
     set -x
 
-    # Watch devstack's output
+    # Watch devstack's output (which doesn't start until stack.sh is running,
+    # but wait for run.sh (which starts stack.sh) to exit as that is what
+    # hopefully writes the succeded cookie.
     pid=`ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS pgrep run.sh`
     ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "tail --pid $pid -n +1 -f /tmp/devstack/log/stack.log"
 
diff --git a/unstack.sh b/unstack.sh
index a5e7b87..fe5fc77 100755
--- a/unstack.sh
+++ b/unstack.sh
@@ -122,9 +122,10 @@
     stop_horizon
 fi
 
-# Kill TLS proxies
+# Kill TLS proxies and cleanup certificates
 if is_service_enabled tls-proxy; then
-    killall stud
+    stop_tls_proxy
+    cleanup_CA
 fi
 
 SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*