Merge "Begin is_service_enabled() cleanup"
diff --git a/extras.d/50-ironic.sh b/extras.d/50-ironic.sh
new file mode 100644
index 0000000..f68a146
--- /dev/null
+++ b/extras.d/50-ironic.sh
@@ -0,0 +1,33 @@
+# ironic.sh - Devstack extras script to install ironic
+
+if is_service_enabled ir-api ir-cond; then
+    if [[ "$1" == "source" ]]; then
+        # Initial source
+        source $TOP_DIR/lib/ironic
+    elif [[ "$1" == "stack" && "$2" == "install" ]]; then
+        echo_summary "Installing Ironic"
+        install_ironic
+        install_ironicclient
+        cleanup_ironic
+    elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
+        echo_summary "Configuring Ironic"
+        configure_ironic
+
+        if is_service_enabled key; then
+            create_ironic_accounts
+        fi
+
+    elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
+        # Initialize ironic
+        init_ironic
+
+        # Start the ironic API and ironic taskmgr components
+        echo_summary "Starting Ironic"
+        start_ironic
+    fi
+
+    if [[ "$1" == "unstack" ]]; then
+        stop_ironic
+        cleanup_ironic
+    fi
+fi
diff --git a/lib/horizon b/lib/horizon
index c64d850..2f5795d 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -81,9 +81,6 @@
 
 # init_horizon() - Initialize databases, etc.
 function init_horizon() {
-    # Remove stale session database.
-    rm -f $HORIZON_DIR/openstack_dashboard/local/dashboard_openstack.sqlite3
-
     # ``local_settings.py`` is used to override horizon default settings.
     local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py
     cp $HORIZON_SETTINGS $local_settings
@@ -106,12 +103,6 @@
         _horizon_config_set $local_settings OPENSTACK_NEUTRON_NETWORK enable_vpn True
     fi
 
-    # Initialize the horizon database (it stores sessions and notices shown to
-    # users).  The user system is external (keystone).
-    cd $HORIZON_DIR
-    python manage.py syncdb --noinput
-    cd $TOP_DIR
-
     # Create an empty directory that apache uses as docroot
     sudo mkdir -p $HORIZON_DIR/.blackhole
 
diff --git a/lib/ironic b/lib/ironic
index b8838f5..0b9df57 100644
--- a/lib/ironic
+++ b/lib/ironic
@@ -49,6 +49,13 @@
 # Functions
 # ---------
 
+# Test if any Ironic services are enabled
+# is_ironic_enabled
+function is_ironic_enabled {
+    [[ ,${ENABLED_SERVICES} =~ ,"ir-" ]] && return 0
+    return 1
+}
+
 # install_ironic() - Collect source and prepare
 function install_ironic() {
     git_clone $IRONIC_REPO $IRONIC_DIR $IRONIC_BRANCH
diff --git a/lib/neutron_plugins/embrane b/lib/neutron_plugins/embrane
new file mode 100644
index 0000000..4206a20
--- /dev/null
+++ b/lib/neutron_plugins/embrane
@@ -0,0 +1,40 @@
+# Neutron Embrane plugin
+# ---------------------------
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+source $TOP_DIR/lib/neutron_plugins/openvswitch
+
+save_function() {
+    local ORIG_FUNC=$(declare -f $1)
+    local NEW_FUNC="$2${ORIG_FUNC#$1}"
+    eval "$NEW_FUNC"
+}
+
+save_function neutron_plugin_configure_service _neutron_plugin_configure_service
+
+function neutron_plugin_configure_common() {
+    Q_PLUGIN_CONF_PATH=etc/neutron/plugins/embrane
+    Q_PLUGIN_CONF_FILENAME=heleos_conf.ini
+    Q_DB_NAME="ovs_neutron"
+    Q_PLUGIN_CLASS="neutron.plugins.embrane.plugins.embrane_ovs_plugin.EmbraneOvsPlugin"
+}
+
+function neutron_plugin_configure_service() {
+    _neutron_plugin_configure_service
+    iniset /$Q_PLUGIN_CONF_FILE heleos esm_mgmt $HELEOS_ESM_MGMT
+    iniset /$Q_PLUGIN_CONF_FILE heleos admin_username $HELEOS_ADMIN_USERNAME
+    iniset /$Q_PLUGIN_CONF_FILE heleos admin_password $HELEOS_ADMIN_PASSWORD
+    iniset /$Q_PLUGIN_CONF_FILE heleos router_image $HELEOS_ROUTER_IMAGE
+    iniset /$Q_PLUGIN_CONF_FILE heleos mgmt_id $HELEOS_MGMT_ID
+    iniset /$Q_PLUGIN_CONF_FILE heleos inband_id $HELEOS_INBAND_ID
+    iniset /$Q_PLUGIN_CONF_FILE heleos oob_id $HELEOS_OOB_ID
+    iniset /$Q_PLUGIN_CONF_FILE heleos dummy_utif_id $HELEOS_DUMMY_UTIF_ID
+    iniset /$Q_PLUGIN_CONF_FILE heleos resource_pool_id $HELEOS_RESOURCE_POOL_ID
+    iniset /$Q_PLUGIN_CONF_FILE heleos async_requests $HELEOS_ASYNC_REQUESTS
+}
+
+# Restore xtrace
+$MY_XTRACE
\ No newline at end of file
diff --git a/lib/nova b/lib/nova
index c6d9936..eaaaa62 100644
--- a/lib/nova
+++ b/lib/nova
@@ -403,6 +403,10 @@
     fi
 
     if is_service_enabled n-api; then
+        if is_service_enabled n-api-meta; then
+            # If running n-api-meta as a separate service
+            NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/,metadata//")
+        fi
         iniset $NOVA_CONF DEFAULT enabled_apis "$NOVA_ENABLED_APIS"
         if is_service_enabled tls-proxy; then
             # Set the service port for a proxy to take the original
@@ -456,7 +460,7 @@
         iniset $NOVA_CONF DEFAULT instance_usage_audit "True"
         iniset $NOVA_CONF DEFAULT instance_usage_audit_period "hour"
         iniset $NOVA_CONF DEFAULT notify_on_state_change "vm_and_task_state"
-        iniset $NOVA_CONF DEFAULT notification_driver "nova.openstack.common.notifier.rpc_notifier"
+        iniset $NOVA_CONF DEFAULT notification_driver "messaging"
     fi
 
     # Provide some transition from ``EXTRA_FLAGS`` to ``EXTRA_OPTS``
diff --git a/lib/swift b/lib/swift
index 197c01b..0febb00 100644
--- a/lib/swift
+++ b/lib/swift
@@ -348,7 +348,7 @@
 # NOTE(chmou): s3token middleware is not updated yet to use only
 # username and password.
 [filter:s3token]
-paste.filter_factory = keystone.middleware.s3_token:filter_factory
+paste.filter_factory = keystoneclient.middleware.s3_token:filter_factory
 auth_port = ${KEYSTONE_AUTH_PORT}
 auth_host = ${KEYSTONE_AUTH_HOST}
 auth_protocol = ${KEYSTONE_AUTH_PROTOCOL}
diff --git a/lib/tempest b/lib/tempest
index 06183b1..76da170 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -251,6 +251,7 @@
 
     # Identity
     iniset $TEMPEST_CONFIG identity uri "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v2.0/"
+    iniset $TEMPEST_CONFIG identity uri_v3 "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v3/"
     iniset $TEMPEST_CONFIG identity password "$password"
     iniset $TEMPEST_CONFIG identity alt_username $ALT_USERNAME
     iniset $TEMPEST_CONFIG identity alt_password "$password"
@@ -266,11 +267,6 @@
 
     # Compute
     iniset $TEMPEST_CONFIG compute change_password_available False
-    # Note(nati) current tempest don't create network for each tenant
-    # so reuse same tenant for now
-    if is_service_enabled neutron; then
-        TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-False}
-    fi
     iniset $TEMPEST_CONFIG compute allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
     iniset $TEMPEST_CONFIG compute ssh_user ${DEFAULT_INSTANCE_USER:-cirros} # DEPRECATED
     iniset $TEMPEST_CONFIG compute network_for_ssh $PRIVATE_NETWORK_NAME
@@ -323,7 +319,7 @@
     fi
     CINDER_MULTI_LVM_BACKEND=$(trueorfalse False $CINDER_MULTI_LVM_BACKEND)
     if [ $CINDER_MULTI_LVM_BACKEND == "True" ]; then
-        iniset $TEMPEST_CONFIG volume multi_backend_enabled "True"
+        iniset $TEMPEST_CONFIG volume-feature-enabled multi_backend "True"
         iniset $TEMPEST_CONFIG volume backend1_name "LVM_iSCSI"
         iniset $TEMPEST_CONFIG volume backend2_name "LVM_iSCSI_2"
     fi
diff --git a/stack.sh b/stack.sh
index d379d51..67e137c 100755
--- a/stack.sh
+++ b/stack.sh
@@ -336,7 +336,6 @@
 source $TOP_DIR/lib/neutron
 source $TOP_DIR/lib/baremetal
 source $TOP_DIR/lib/ldap
-source $TOP_DIR/lib/ironic
 
 # Extras Source
 # --------------
@@ -363,7 +362,11 @@
     var=$1; msg=$2
     pw=${!var}
 
-    localrc=$TOP_DIR/localrc
+    if [[ -f $RC_DIR/localrc ]]; then
+        localrc=$TOP_DIR/localrc
+    else
+        localrc=$TOP_DIR/.localrc.auto
+    fi
 
     # If the password is not defined yet, proceed to prompt user for a password.
     if [ ! $pw ]; then
@@ -746,11 +749,6 @@
     # don't be naive and add to existing line!
 fi
 
-if is_service_enabled ir-api ir-cond; then
-    install_ironic
-    install_ironicclient
-    configure_ironic
-fi
 
 # Extras Install
 # --------------
@@ -966,15 +964,6 @@
 fi
 
 
-# Ironic
-# ------
-
-if is_service_enabled ir-api ir-cond; then
-    echo_summary "Configuring Ironic"
-    init_ironic
-fi
-
-
 # Neutron
 # -------
 
@@ -1101,12 +1090,6 @@
     start_glance
 fi
 
-# Launch the Ironic services
-if is_service_enabled ir-api ir-cond; then
-    echo_summary "Starting Ironic"
-    start_ironic
-fi
-
 # Create an access key and secret key for nova ec2 register image
 if is_service_enabled key && is_service_enabled swift3 && is_service_enabled nova; then
     NOVA_USER_ID=$(keystone user-list | grep ' nova ' | get_field 1)
diff --git a/stackrc b/stackrc
index 2527b0a..9166a17 100644
--- a/stackrc
+++ b/stackrc
@@ -171,7 +171,7 @@
 # storage service
 SWIFT_REPO=${SWIFT_REPO:-${GIT_BASE}/openstack/swift.git}
 SWIFT_BRANCH=${SWIFT_BRANCH:-master}
-SWIFT3_REPO=${SWIFT3_REPO:-${GIT_BASE}/fujita/swift3.git}
+SWIFT3_REPO=${SWIFT3_REPO:-http://github.com/fujita/swift3.git}
 SWIFT3_BRANCH=${SWIFT3_BRANCH:-master}
 
 # python swift client library
diff --git a/tools/build_tempest.sh b/tools/build_tempest.sh
deleted file mode 100755
index 6c527f5..0000000
--- a/tools/build_tempest.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env bash
-#
-# **build_tempest.sh**
-
-# Checkout and prepare a Tempest repo: git://git.openstack.org/openstack/tempest.git
-
-function usage {
-    echo "$0 - Check out and prepare a Tempest repo"
-    echo ""
-    echo "Usage: $0"
-    exit 1
-}
-
-if [ "$1" = "-h" ]; then
-    usage
-fi
-
-# Clean up any resources that may be in use
-cleanup() {
-    set +o errexit
-
-    # Kill ourselves to signal any calling process
-    trap 2; kill -2 $$
-}
-
-trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
-
-# Keep track of the current directory
-TOOLS_DIR=$(cd $(dirname "$0") && pwd)
-TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
-
-# Import common functions
-. $TOP_DIR/functions
-
-# Abort if localrc is not set
-if [ ! -e $TOP_DIR/localrc ]; then
-    echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
-    echo "See stack.sh for required passwords."
-    exit 1
-fi
-
-# Source params
-source ./stackrc
-
-# Where Openstack code lives
-DEST=${DEST:-/opt/stack}
-
-TEMPEST_DIR=$DEST/tempest
-
-# Install tests and prerequisites
-git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH
-
-trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT
diff --git a/tools/xen/build_xva.sh b/tools/xen/build_xva.sh
index 958102b..fbbfd6f 100755
--- a/tools/xen/build_xva.sh
+++ b/tools/xen/build_xva.sh
@@ -21,9 +21,19 @@
 # This directory
 TOP_DIR=$(cd $(dirname "$0") && pwd)
 
+# Source lower level functions
+. $TOP_DIR/../../functions
+
 # Include onexit commands
 . $TOP_DIR/scripts/on_exit.sh
 
+# xapi functions
+. $TOP_DIR/functions
+
+# Determine what system we are running on.
+# Might not be XenServer if we're using xenserver-core
+GetDistro
+
 # Source params - override xenrc params in your localrc to suite your taste
 source xenrc
 
diff --git a/tools/xen/prepare_guest_template.sh b/tools/xen/prepare_guest_template.sh
index 546ac99..4fa70d3 100755
--- a/tools/xen/prepare_guest_template.sh
+++ b/tools/xen/prepare_guest_template.sh
@@ -22,9 +22,19 @@
 # This directory
 TOP_DIR=$(cd $(dirname "$0") && pwd)
 
+# Source lower level functions
+. $TOP_DIR/../../functions
+
 # Include onexit commands
 . $TOP_DIR/scripts/on_exit.sh
 
+# xapi functions
+. $TOP_DIR/functions
+
+# Determine what system we are running on.
+# Might not be XenServer if we're using xenserver-core
+GetDistro
+
 # Source params - override xenrc params in your localrc to suite your taste
 source xenrc
 
diff --git a/tools/xen/xenrc b/tools/xen/xenrc
index cd28234..278bb9b 100644
--- a/tools/xen/xenrc
+++ b/tools/xen/xenrc
@@ -35,7 +35,7 @@
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
 
 # Extracted variables for OpenStack VM network device numbers.
-# Make sure, they form a continous sequence starting from 0
+# Make sure they form a continuous sequence starting from 0
 MGT_DEV_NR=0
 VM_DEV_NR=1
 PUB_DEV_NR=2
@@ -91,4 +91,7 @@
 # Set the size to 0 to avoid creation of additional disk.
 XEN_XVDB_SIZE_GB=0
 
+restore_nounset=`set +o | grep nounset`
+set +u
 source ../../stackrc
+$restore_nounset
diff --git a/unstack.sh b/unstack.sh
index c233f93..6351fe0 100755
--- a/unstack.sh
+++ b/unstack.sh
@@ -55,7 +55,6 @@
 source $TOP_DIR/lib/neutron
 source $TOP_DIR/lib/baremetal
 source $TOP_DIR/lib/ldap
-source $TOP_DIR/lib/ironic
 
 # Extras Source
 # --------------
@@ -118,12 +117,6 @@
     cleanup_swift
 fi
 
-# Ironic runs daemons
-if is_service_enabled ir-api ir-cond; then
-    stop_ironic
-    cleanup_ironic
-fi
-
 # Apache has the WSGI processes
 if is_service_enabled horizon; then
     stop_horizon