Merge "Add support for GlusterFS Cinder driver"
diff --git a/exercises/euca.sh b/exercises/euca.sh
index 50d4744..d704279 100755
--- a/exercises/euca.sh
+++ b/exercises/euca.sh
@@ -96,7 +96,7 @@
    # Attach volume to an instance
    euca-attach-volume -i $INSTANCE -d $ATTACH_DEVICE $VOLUME || \
        die $LINENO "Failure attaching volume $VOLUME to $INSTANCE"
-   if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q in-use; do sleep 1; done"; then
+   if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -A 1 in-use | grep -q attach; do sleep 1; done"; then
        die $LINENO "Could not attach $VOLUME to $INSTANCE"
    fi
 
diff --git a/exercises/quantum-adv-test.sh b/exercises/quantum-adv-test.sh
index a1fb2ad..fbb1b77 100755
--- a/exercises/quantum-adv-test.sh
+++ b/exercises/quantum-adv-test.sh
@@ -330,7 +330,7 @@
 }
 
 function delete_networks {
-   foreach_tenant_net 'delete_network ${%TENANT%_NAME} ${%NUM%}'
+   foreach_tenant_net 'delete_network ${%TENANT%_NAME} %NUM%'
    #TODO(nati) add secuirty group check after it is implemented
    # source $TOP_DIR/openrc demo1 demo1
    # nova secgroup-delete-rule default icmp -1 -1 0.0.0.0/0
diff --git a/files/apache-horizon.template b/files/apache-horizon.template
index fb98471..af880c4 100644
--- a/files/apache-horizon.template
+++ b/files/apache-horizon.template
@@ -17,6 +17,7 @@
 
     <Directory %HORIZON_DIR%/>
         Options Indexes FollowSymLinks MultiViews
+        %HORIZON_REQUIRE%
         AllowOverride None
         Order allow,deny
         allow from all
diff --git a/functions b/functions
index 88e4a62..02c2b3a 100644
--- a/functions
+++ b/functions
@@ -887,9 +887,18 @@
         SUDO_PIP="sudo"
         CMD_PIP=$(get_pip_command)
     fi
+
+    if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
+        # RHEL6 pip by default doesn't have this (was introduced
+        # around 0.8.1 or so)
+        PIP_USE_MIRRORS=${PIP_USE_MIRRORS:-False}
+    else
+        PIP_USE_MIRRORS=${PIP_USE_MIRRORS:-True}
+    fi
     if [[ "$PIP_USE_MIRRORS" != "False" ]]; then
         PIP_MIRROR_OPT="--use-mirrors"
     fi
+
     $SUDO_PIP PIP_DOWNLOAD_CACHE=${PIP_DOWNLOAD_CACHE:-/var/cache/pip} \
         HTTP_PROXY=$http_proxy \
         HTTPS_PROXY=$https_proxy \
diff --git a/lib/cinder b/lib/cinder
index ead471b..82e7454 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -390,21 +390,20 @@
     setup_develop $CINDERCLIENT_DIR
 }
 
-# apply config.d approach (e.g. Oneiric does not have this)
+# apply config.d approach for cinder volumes directory
 function _configure_tgt_for_config_d() {
-    if [[ ! -d /etc/tgt/conf.d/ ]]; then
-        sudo mkdir -p /etc/tgt/conf.d
-        echo "include /etc/tgt/conf.d/*.conf" | sudo tee -a /etc/tgt/targets.conf
+    if [[ ! -d /etc/tgt/stack.d/ ]]; then
+        sudo ln -sf $CINDER_STATE_PATH/volumes /etc/tgt/stack.d
+        echo "include /etc/tgt/stack.d/*" | sudo tee -a /etc/tgt/targets.conf
     fi
 }
 
 # start_cinder() - Start running processes, including screen
 function start_cinder() {
     if is_service_enabled c-vol; then
+        # Delete any old stack.conf
+        sudo rm -f /etc/tgt/conf.d/stack.conf
         _configure_tgt_for_config_d
-        if [[ ! -f /etc/tgt/conf.d/stack.conf ]]; then
-            echo "include $CINDER_STATE_PATH/volumes/*" | sudo tee /etc/tgt/conf.d/stack.conf
-        fi
         if is_ubuntu; then
             # tgt in oneiric doesn't restart properly if tgtd isn't running
             # do it in two steps
diff --git a/lib/horizon b/lib/horizon
index 94aac5c..05bf6d3 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -102,6 +102,7 @@
     sudo mkdir -p $HORIZON_DIR/.blackhole
 
 
+    HORIZON_REQUIRE=''
     if is_ubuntu; then
         APACHE_NAME=apache2
         APACHE_CONF=sites-available/horizon
@@ -115,6 +116,12 @@
     elif is_fedora; then
         APACHE_NAME=httpd
         APACHE_CONF=conf.d/horizon.conf
+
+        if [[ "$os_RELEASE" -ge "18" ]]; then
+            # fedora 18 has Require all denied  in its httpd.conf
+            # and requires explicit Require all granted
+            HORIZON_REQUIRE='Require all granted'
+        fi
         sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
     elif is_suse; then
         APACHE_NAME=apache2
@@ -132,6 +139,7 @@
         s,%HORIZON_DIR%,$HORIZON_DIR,g;
         s,%APACHE_NAME%,$APACHE_NAME,g;
         s,%DEST%,$DEST,g;
+        s,%HORIZON_REQUIRE%,$HORIZON_REQUIRE,g;
     \" $FILES/apache-horizon.template >/etc/$APACHE_NAME/$APACHE_CONF"
 
 }
@@ -156,6 +164,9 @@
         if [[ ! -e "/usr/bin/node" ]]; then
             install_package nodejs-legacy
         fi
+    elif is_fedora && [[ "$os_RELEASE" -ge "18" ]]; then
+        # fedora 18 and higher gets nodejs
+        install_package nodejs
     fi
 
     git_clone $HORIZON_REPO $HORIZON_DIR $HORIZON_BRANCH $HORIZON_TAG
diff --git a/lib/quantum b/lib/quantum
index 34d51f8..96ccf20 100644
--- a/lib/quantum
+++ b/lib/quantum
@@ -539,6 +539,8 @@
     # Specify the default root helper prior to agent configuration to
     # ensure that an agent's configuration can override the default
     iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
+    iniset $QUANTUM_CONF DEFAULT verbose True
+    iniset $QUANTUM_CONF DEFAULT debug True
 
     # Configure agent for plugin
     quantum_plugin_configure_plugin_agent
diff --git a/lib/quantum_plugins/plumgrid b/lib/quantum_plugins/plumgrid
index b49aa92..912aa7e 100644
--- a/lib/quantum_plugins/plumgrid
+++ b/lib/quantum_plugins/plumgrid
@@ -25,8 +25,10 @@
 }
 
 function quantum_plugin_configure_service() {
-    iniset /$Q_PLUGIN_CONF_FILE PLUMgridNOS nos_server localhost
-    iniset /$Q_PLUGIN_CONF_FILE PLUMgridNOS nos_server_port 7766
+    PLUMGRID_NOS_IP=${PLUMGRID_NOS_IP:-localhost}
+    PLUMGRID_NOS_PORT=${PLUMGRID_NOS_PORT:-7766}
+    iniset /$Q_PLUGIN_CONF_FILE PLUMgridNOS nos_server $PLUMGRID_NOS_IP
+    iniset /$Q_PLUGIN_CONF_FILE PLUMgridNOS nos_server_port $PLUMGRID_NOS_PORT
 }
 
 function quantum_plugin_configure_debug_command() {
diff --git a/stack.sh b/stack.sh
index 8c92ea6..497e8a1 100755
--- a/stack.sh
+++ b/stack.sh
@@ -18,6 +18,9 @@
 
 # Learn more and get the most recent version at http://devstack.org
 
+# Make sure custom grep options don't get in the way
+unset GREP_OPTIONS
+
 # Keep track of the devstack directory
 TOP_DIR=$(cd $(dirname "$0") && pwd)