Merge "Use correct class path for token persistence backend"
diff --git a/MAINTAINERS.rst b/MAINTAINERS.rst
index bdd9e78..1e915c7 100644
--- a/MAINTAINERS.rst
+++ b/MAINTAINERS.rst
@@ -55,6 +55,11 @@
 
 * Sergey Lukjanov <slukjanov@mirantis.com>
 
+Swift
+~~~~~
+
+* Chmouel Boudjnah <chmouel@enovance.com>
+
 SUSE
 ~~~~
 
diff --git a/files/apache-keystone.template b/files/apache-keystone.template
index a9d9cc3..e7b2157 100644
--- a/files/apache-keystone.template
+++ b/files/apache-keystone.template
@@ -6,6 +6,7 @@
     WSGIProcessGroup keystone-public
     WSGIScriptAlias / %PUBLICWSGI%
     WSGIApplicationGroup %{GLOBAL}
+    %ERRORLOGFORMAT%
     ErrorLog /var/log/%APACHE_NAME%/keystone.log
     CustomLog /var/log/%APACHE_NAME%/access.log combined
 </VirtualHost>
@@ -15,6 +16,7 @@
     WSGIProcessGroup keystone-admin
     WSGIScriptAlias / %ADMINWSGI%
     WSGIApplicationGroup %{GLOBAL}
+    %ERRORLOGFORMAT%
     ErrorLog /var/log/%APACHE_NAME%/keystone.log
     CustomLog /var/log/%APACHE_NAME%/access.log combined
 </VirtualHost>
diff --git a/files/apts/general b/files/apts/general
index 739fc47..c308c46 100644
--- a/files/apts/general
+++ b/files/apts/general
@@ -7,6 +7,7 @@
 psmisc
 gcc
 git
+graphviz # testonly - docs
 lsof # useful when debugging
 openssh-server
 openssl
diff --git a/files/apts/q-agt b/files/apts/q-agt
new file mode 100644
index 0000000..ea8819e
--- /dev/null
+++ b/files/apts/q-agt
@@ -0,0 +1 @@
+ipset
diff --git a/files/rpms-suse/general b/files/rpms-suse/general
index 82cb09d..0a4746f 100644
--- a/files/rpms-suse/general
+++ b/files/rpms-suse/general
@@ -5,6 +5,7 @@
 euca2ools
 gcc
 git-core
+graphviz # testonly - docs
 iputils
 libopenssl-devel # to rebuild pyOpenSSL if needed
 lsof # useful when debugging
diff --git a/files/rpms-suse/q-agt b/files/rpms-suse/q-agt
new file mode 100644
index 0000000..ea8819e
--- /dev/null
+++ b/files/rpms-suse/q-agt
@@ -0,0 +1 @@
+ipset
diff --git a/files/rpms/general b/files/rpms/general
index 74997a8..7a35961 100644
--- a/files/rpms/general
+++ b/files/rpms/general
@@ -4,6 +4,7 @@
 euca2ools # only for testing client
 gcc
 git-core
+graphviz # testonly - docs
 openssh-server
 openssl
 openssl-devel # to rebuild pyOpenSSL if needed
diff --git a/files/rpms/q-agt b/files/rpms/q-agt
new file mode 100644
index 0000000..ea8819e
--- /dev/null
+++ b/files/rpms/q-agt
@@ -0,0 +1 @@
+ipset
diff --git a/functions-common b/functions-common
index c096664..4e74f5a 100644
--- a/functions-common
+++ b/functions-common
@@ -695,6 +695,13 @@
     echo $host_ip
 }
 
+# Generates hex string from ``size`` byte of pseudo random data
+# generate_hex_string size
+function generate_hex_string {
+    local size=$1
+    hexdump -n "$size" -v -e '/1 "%02x"' /dev/urandom
+}
+
 # Grab a numbered field from python prettytable output
 # Fields are numbered starting with 1
 # Reverse syntax is supported: -1 is the last field, -2 is second to last, etc.
diff --git a/lib/apache b/lib/apache
index f4f82a1..6d22290 100644
--- a/lib/apache
+++ b/lib/apache
@@ -61,6 +61,28 @@
     fi
 }
 
+# get_apache_version() - return the version of Apache installed
+# This function is used to determine the Apache version installed. There are
+# various differences between Apache 2.2 and 2.4 that warrant special handling.
+function get_apache_version {
+    if is_ubuntu; then
+        local version_str=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
+    elif is_fedora; then
+        local version_str=$(rpm -qa --queryformat '%{VERSION}' httpd)
+    elif is_suse; then
+        local version_str=$(rpm -qa --queryformat '%{VERSION}' apache2)
+    else
+        exit_distro_not_supported "cannot determine apache version"
+    fi
+    if [[ "$version_str" =~ ^2\.2\. ]]; then
+        echo "2.2"
+    elif [[ "$version_str" =~ ^2\.4\. ]]; then
+        echo "2.4"
+    else
+        exit_distro_not_supported "apache version not supported"
+    fi
+}
+
 # apache_site_config_for() - The filename of the site's configuration file.
 # This function uses the global variables APACHE_NAME and APACHE_CONF_DIR.
 #
@@ -87,8 +109,8 @@
 function apache_site_config_for {
     local site=$@
     if is_ubuntu; then
-        local apache_version=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
-        if [[ "$apache_version" =~ ^2\.2\. ]]; then
+        local apache_version=$(get_apache_version)
+        if [[ "$apache_version" == "2.2" ]]; then
             # Ubuntu 12.04 - Apache 2.2
             echo $APACHE_CONF_DIR/${site}
         else
diff --git a/lib/cinder_backends/glusterfs b/lib/cinder_backends/glusterfs
new file mode 100644
index 0000000..dd772a8
--- /dev/null
+++ b/lib/cinder_backends/glusterfs
@@ -0,0 +1,46 @@
+# lib/cinder_backends/glusterfs
+# Configure the glusterfs backend
+
+# Enable with:
+#
+#   CINDER_ENABLED_BACKENDS+=,glusterfs:<volume-type-name>
+
+# Dependencies:
+#
+# - ``functions`` file
+# - ``cinder`` configurations
+
+# CINDER_CONF
+# CINDER_CONF_DIR
+# CINDER_GLUSTERFS_SHARES - Contents of glusterfs shares config file
+
+# configure_cinder_backend_glusterfs - Configure Cinder for GlusterFS backends
+
+# Save trace setting
+GLUSTERFS_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+
+# Entry Points
+# ------------
+
+# configure_cinder_backend_glusterfs - Set config files, create data dirs, etc
+function configure_cinder_backend_glusterfs {
+    local be_name=$1
+    iniset $CINDER_CONF $be_name volume_backend_name $be_name
+    iniset $CINDER_CONF $be_name volume_driver "cinder.volume.drivers.glusterfs.GlusterfsDriver"
+    iniset $CINDER_CONF $be_name glusterfs_shares_config "$CINDER_CONF_DIR/glusterfs-shares-$be_name.conf"
+
+    if [[ -n "$CINDER_GLUSTERFS_SHARES" ]]; then
+        CINDER_GLUSTERFS_SHARES=$(echo $CINDER_GLUSTERFS_SHARES | tr ";" "\n")
+        echo "$CINDER_GLUSTERFS_SHARES" | tee "$CINDER_CONF_DIR/glusterfs-shares-$be_name.conf"
+    fi
+}
+
+
+# Restore xtrace
+$GLUSTERFS_XTRACE
+
+# Local variables:
+# mode: shell-script
+# End:
diff --git a/lib/heat b/lib/heat
index bd99d6b..14094a9 100644
--- a/lib/heat
+++ b/lib/heat
@@ -98,7 +98,7 @@
     iniset $HEAT_CONF DEFAULT heat_waitcondition_server_url http://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1/waitcondition
     iniset $HEAT_CONF DEFAULT heat_watch_server_url http://$HEAT_API_CW_HOST:$HEAT_API_CW_PORT
     iniset $HEAT_CONF database connection `database_connection_url heat`
-    iniset $HEAT_CONF DEFAULT auth_encryption_key `hexdump -n 16 -v -e '/1 "%02x"' /dev/urandom`
+    iniset $HEAT_CONF DEFAULT auth_encryption_key $(generate_hex_string 16)
 
     iniset $HEAT_CONF DEFAULT region_name_for_services "$REGION_NAME"
 
diff --git a/lib/keystone b/lib/keystone
index a3e7267..c1b0b87 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -123,6 +123,13 @@
     sudo mkdir -p $KEYSTONE_WSGI_DIR
 
     local keystone_apache_conf=$(apache_site_config_for keystone)
+    local apache_version=$(get_apache_version)
+
+    if [[ ${apache_version#*\.} -ge 4 ]]; then
+        # Apache 2.4 supports custom error log formats
+        # this should mirror the original log formatting.
+        local errorlogformat='ErrorLogFormat "%{cu}t %M"'
+    fi
 
     # copy proxy vhost and wsgi file
     sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/main
@@ -136,6 +143,7 @@
         s|%PUBLICWSGI%|$KEYSTONE_WSGI_DIR/main|g;
         s|%ADMINWSGI%|$KEYSTONE_WSGI_DIR/admin|g;
         s|%USER%|$STACK_USER|g
+        s|%ERRORLOGFORMAT%|$errorlogformat|g;
     " -i $keystone_apache_conf
     enable_apache_site keystone
 }
diff --git a/lib/neutron_plugins/ovs_base b/lib/neutron_plugins/ovs_base
index 8375bb6..d913f7c 100644
--- a/lib/neutron_plugins/ovs_base
+++ b/lib/neutron_plugins/ovs_base
@@ -51,6 +51,7 @@
     install_package $(get_packages "openvswitch")
     if is_ubuntu; then
         _neutron_ovs_base_install_ubuntu_dkms
+        restart_service openvswitch-switch
     elif is_fedora; then
         restart_service openvswitch
     elif is_suse; then
diff --git a/lib/nova_plugins/functions-libvirt b/lib/nova_plugins/functions-libvirt
index 258e1a4..f722836 100644
--- a/lib/nova_plugins/functions-libvirt
+++ b/lib/nova_plugins/functions-libvirt
@@ -57,7 +57,7 @@
 EOF
     fi
 
-    if is_ubuntu; then
+    if [ "$os_VENDOR" = "Ubuntu" ]; then
         LIBVIRT_DAEMON=libvirt-bin
     else
         LIBVIRT_DAEMON=libvirtd
diff --git a/stack.sh b/stack.sh
index 1661b36..9a25bc0 100755
--- a/stack.sh
+++ b/stack.sh
@@ -426,7 +426,7 @@
             echo "Invalid chars in password.  Try again:"
         done
         if [ ! $pw ]; then
-            pw=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 20)
+            pw=$(generate_hex_string 10)
         fi
         eval "$var=$pw"
         echo "$var=$pw" >> $localrc
@@ -1211,11 +1211,7 @@
 
 # Create a randomized default value for the keymgr's fixed_key
 if is_service_enabled nova; then
-    FIXED_KEY=""
-    for i in $(seq 1 64); do
-        FIXED_KEY+=$(echo "obase=16; $(($RANDOM % 16))" | bc);
-    done;
-    iniset $NOVA_CONF keymgr fixed_key "$FIXED_KEY"
+    iniset $NOVA_CONF keymgr fixed_key $(generate_hex_string 32)
 fi
 
 if is_service_enabled zeromq; then
diff --git a/tools/xen/functions b/tools/xen/functions
index ab0be84..4317796 100644
--- a/tools/xen/functions
+++ b/tools/xen/functions
@@ -93,7 +93,7 @@
     echo $pbd_path
 }
 
-function find_ip_by_name() {
+function find_ip_by_name {
     local guest_name="$1"
     local interface="$2"
 
@@ -121,7 +121,7 @@
     done
 }
 
-function _vm_uuid() {
+function _vm_uuid {
     local vm_name_label
 
     vm_name_label="$1"
@@ -129,14 +129,14 @@
     xe vm-list name-label="$vm_name_label" --minimal
 }
 
-function _create_new_network() {
+function _create_new_network {
     local name_label
     name_label=$1
 
     xe network-create name-label="$name_label"
 }
 
-function _multiple_networks_with_name() {
+function _multiple_networks_with_name {
     local name_label
     name_label=$1
 
@@ -144,21 +144,21 @@
     xe network-list name-label="$name_label" --minimal | grep -q ","
 }
 
-function _network_exists() {
+function _network_exists {
     local name_label
     name_label=$1
 
     ! [ -z "$(xe network-list name-label="$name_label" --minimal)" ]
 }
 
-function _bridge_exists() {
+function _bridge_exists {
     local bridge
     bridge=$1
 
     ! [ -z "$(xe network-list bridge="$bridge" --minimal)" ]
 }
 
-function _network_uuid() {
+function _network_uuid {
     local bridge_or_net_name
     bridge_or_net_name=$1
 
@@ -169,7 +169,7 @@
     fi
 }
 
-function add_interface() {
+function add_interface {
     local vm_name_label
     local bridge_or_network_name
 
@@ -185,7 +185,7 @@
     xe vif-create network-uuid=$net vm-uuid=$vm device=$device_number
 }
 
-function setup_network() {
+function setup_network {
     local bridge_or_net_name
     bridge_or_net_name=$1
 
@@ -204,7 +204,7 @@
     fi
 }
 
-function bridge_for() {
+function bridge_for {
     local bridge_or_net_name
     bridge_or_net_name=$1
 
@@ -215,29 +215,28 @@
     fi
 }
 
-function xenapi_ip_on() {
+function xenapi_ip_on {
     local bridge_or_net_name
     bridge_or_net_name=$1
 
     ifconfig $(bridge_for "$bridge_or_net_name") | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"
 }
 
-function xenapi_is_listening_on() {
+function xenapi_is_listening_on {
     local bridge_or_net_name
     bridge_or_net_name=$1
 
     ! [ -z $(xenapi_ip_on "$bridge_or_net_name") ]
 }
 
-function parameter_is_specified() {
+function parameter_is_specified {
     local parameter_name
     parameter_name=$1
 
     compgen -v | grep "$parameter_name"
 }
 
-function append_kernel_cmdline()
-{
+function append_kernel_cmdline {
     local vm_name_label
     local kernel_args
 
@@ -252,8 +251,7 @@
     xe vm-param-set PV-args="$pv_args $kernel_args" uuid=$vm
 }
 
-function destroy_all_vifs_of()
-{
+function destroy_all_vifs_of {
     local vm_name_label
 
     vm_name_label="$1"
@@ -268,11 +266,11 @@
     unset IFS
 }
 
-function have_multiple_hosts() {
+function have_multiple_hosts {
     xe host-list --minimal | grep -q ","
 }
 
-function attach_network() {
+function attach_network {
     local bridge_or_net_name
 
     bridge_or_net_name="$1"
@@ -286,7 +284,7 @@
     xe network-attach uuid=$net host-uuid=$host
 }
 
-function set_vm_memory() {
+function set_vm_memory {
     local vm_name_label
     local memory
 
@@ -305,7 +303,7 @@
         uuid=$vm
 }
 
-function max_vcpus() {
+function max_vcpus {
     local vm_name_label
 
     vm_name_label="$1"
@@ -337,7 +335,7 @@
     xe vm-param-set uuid=$vm VCPUs-at-startup=$cpu_count
 }
 
-function get_domid() {
+function get_domid {
     local vm_name_label
 
     vm_name_label="$1"