Merge "clean up ubuntu versions"
diff --git a/exercises/neutron-adv-test.sh b/exercises/neutron-adv-test.sh
index 0a100c0..0c0d42f 100755
--- a/exercises/neutron-adv-test.sh
+++ b/exercises/neutron-adv-test.sh
@@ -400,10 +400,10 @@
     echo Description
     echo
     echo Copyright 2012, Cisco Systems
-    echo Copyright 2012, Nicira Networks, Inc.
+    echo Copyright 2012, VMware, Inc.
     echo Copyright 2012, NTT MCL, Inc.
     echo
-    echo Please direct any questions to dedutta@cisco.com, dan@nicira.com, nachi@nttmcl.com
+    echo Please direct any questions to dedutta@cisco.com, dwendlandt@vmware.com, nachi@nttmcl.com
     echo
 
 
diff --git a/files/apts/neutron b/files/apts/neutron
index 5760113..648716a 100644
--- a/files/apts/neutron
+++ b/files/apts/neutron
@@ -20,6 +20,6 @@
 dnsmasq-base
 dnsmasq-utils # for dhcp_release only available in dist:precise
 rabbitmq-server # NOPRIME
-qpid # NOPRIME
+qpidd # NOPRIME
 sqlite3
 vlan
diff --git a/functions b/functions
index 6f09685..92b61ed 100644
--- a/functions
+++ b/functions
@@ -1132,10 +1132,39 @@
             sleep 1.5
 
             NL=`echo -ne '\015'`
-            screen -S $SCREEN_NAME -p $1 -X stuff "$2 || echo \"$1 failed to start\" | tee \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL"
+            # This fun command does the following:
+            # - the passed server command is backgrounded
+            # - the pid of the background process is saved in the usual place
+            # - the server process is brought back to the foreground
+            # - if the server process exits prematurely the fg command errors
+            #   and a message is written to stdout and the service failure file
+            # The pid saved can be used in screen_stop() as a process group
+            # id to kill off all child processes
+            screen -S $SCREEN_NAME -p $1 -X stuff "$2 & echo \$! >$SERVICE_DIR/$SCREEN_NAME/$1.pid; fg || echo \"$1 failed to start\" | tee \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL"
         else
             # Spawn directly without screen
-            run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$service.pid
+            run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$1.pid
+        fi
+    fi
+}
+
+
+# Stop a service in screen
+# screen_stop service
+function screen_stop() {
+    SCREEN_NAME=${SCREEN_NAME:-stack}
+    SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
+    USE_SCREEN=$(trueorfalse True $USE_SCREEN)
+
+    if is_service_enabled $1; then
+        # Kill via pid if we have one available
+        if [[ -r $SERVICE_DIR/$SCREEN_NAME/$1.pid ]]; then
+            pkill -TERM -P $(cat $SERVICE_DIR/$SCREEN_NAME/$1.pid)
+            rm $SERVICE_DIR/$SCREEN_NAME/$1.pid
+        fi
+        if [[ "$USE_SCREEN" = "True" ]]; then
+            # Clean up the screen window
+            screen -S $SCREEN_NAME -p $1 -X kill
         fi
     fi
 }
diff --git a/lib/ceilometer b/lib/ceilometer
index fac3be1..211303f 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -162,7 +162,7 @@
 function stop_ceilometer() {
     # Kill the ceilometer screen windows
     for serv in ceilometer-acompute ceilometer-acentral ceilometer-anotification ceilometer-collector ceilometer-api ceilometer-alarm-notifier ceilometer-alarm-evaluator; do
-        screen -S $SCREEN_NAME -p $serv -X kill
+        screen_stop $serv
     done
 }
 
diff --git a/lib/cinder b/lib/cinder
index cbe732e..111b974 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -163,15 +163,8 @@
     fi
 }
 
-# configure_cinder() - Set config files, create data dirs, etc
-function configure_cinder() {
-    if [[ ! -d $CINDER_CONF_DIR ]]; then
-        sudo mkdir -p $CINDER_CONF_DIR
-    fi
-    sudo chown $STACK_USER $CINDER_CONF_DIR
-
-    cp -p $CINDER_DIR/etc/cinder/policy.json $CINDER_CONF_DIR
-
+# configure_cinder_rootwrap() - configure Cinder's rootwrap
+function configure_cinder_rootwrap() {
     # Set the paths of certain binaries
     CINDER_ROOTWRAP=$(get_rootwrap_location cinder)
     if [[ ! -x $CINDER_ROOTWRAP ]]; then
@@ -214,6 +207,18 @@
     chmod 0440 $TEMPFILE
     sudo chown root:root $TEMPFILE
     sudo mv $TEMPFILE /etc/sudoers.d/cinder-rootwrap
+}
+
+# configure_cinder() - Set config files, create data dirs, etc
+function configure_cinder() {
+    if [[ ! -d $CINDER_CONF_DIR ]]; then
+        sudo mkdir -p $CINDER_CONF_DIR
+    fi
+    sudo chown $STACK_USER $CINDER_CONF_DIR
+
+    cp -p $CINDER_DIR/etc/cinder/policy.json $CINDER_CONF_DIR
+
+    configure_cinder_rootwrap
 
     cp $CINDER_DIR/etc/cinder/api-paste.ini $CINDER_API_PASTE_INI
 
@@ -341,7 +346,7 @@
             -e 's/snapshot_autoextend_percent =.*/snapshot_autoextend_percent = 20/' \
             /etc/lvm/lvm.conf
     fi
-    iniset $CINDER_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT
+    configure_API_version $CINDER_CONF $IDENTITY_API_VERSION
     iniset $CINDER_CONF keystone_authtoken admin_user cinder
     iniset $CINDER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
     iniset $CINDER_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
@@ -365,7 +370,7 @@
         CINDER_USER=$(keystone user-create \
             --name=cinder \
             --pass="$SERVICE_PASSWORD" \
-            --tenant_id $SERVICE_TENANT \
+            --tenant-id $SERVICE_TENANT \
             --email=cinder@example.com \
             | grep " id " | get_field 2)
         keystone user-role-add \
@@ -556,7 +561,7 @@
 function stop_cinder() {
     # Kill the cinder screen windows
     for serv in c-api c-bak c-sch c-vol; do
-        screen -S $SCREEN_NAME -p $serv -X kill
+        screen_stop $serv
     done
 
     if is_service_enabled c-vol; then
diff --git a/lib/glance b/lib/glance
index 135136d..21c1fa5 100644
--- a/lib/glance
+++ b/lib/glance
@@ -83,7 +83,7 @@
     iniset $GLANCE_REGISTRY_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
     iniset $GLANCE_REGISTRY_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
     iniset $GLANCE_REGISTRY_CONF keystone_authtoken cafile $KEYSTONE_SSL_CA
-    iniset $GLANCE_REGISTRY_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/
+    configure_API_version $GLANCE_REGISTRY_CONF $IDENTITY_API_VERSION
     iniset $GLANCE_REGISTRY_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
     iniset $GLANCE_REGISTRY_CONF keystone_authtoken admin_user glance
     iniset $GLANCE_REGISTRY_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
@@ -101,7 +101,7 @@
     iniset $GLANCE_API_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
     iniset $GLANCE_API_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
     iniset $GLANCE_API_CONF keystone_authtoken cafile $KEYSTONE_SSL_CA
-    iniset $GLANCE_API_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/
+    configure_API_version $GLANCE_API_CONF $IDENTITY_API_VERSION
     iniset $GLANCE_API_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
     iniset $GLANCE_API_CONF keystone_authtoken admin_user glance
     iniset $GLANCE_API_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
@@ -206,8 +206,8 @@
 # stop_glance() - Stop running processes
 function stop_glance() {
     # Kill the Glance screen windows
-    screen -S $SCREEN_NAME -p g-api -X kill
-    screen -S $SCREEN_NAME -p g-reg -X kill
+    screen_stop g-api
+    screen_stop g-reg
 }
 
 
diff --git a/lib/heat b/lib/heat
index e44a618..e35305b 100644
--- a/lib/heat
+++ b/lib/heat
@@ -95,7 +95,7 @@
     iniset $HEAT_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
     iniset $HEAT_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
     iniset $HEAT_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
-    iniset $HEAT_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0
+    configure_API_version $HEAT_CONF $IDENTITY_API_VERSION
     iniset $HEAT_CONF keystone_authtoken cafile $KEYSTONE_SSL_CA
     iniset $HEAT_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
     iniset $HEAT_CONF keystone_authtoken admin_user heat
@@ -175,7 +175,7 @@
 function stop_heat() {
     # Kill the screen windows
     for serv in h-eng h-api h-api-cfn h-api-cw; do
-        screen -S $SCREEN_NAME -p $serv -X kill
+        screen_stop $serv
     done
 }
 
diff --git a/lib/ironic b/lib/ironic
index 099746a..1ff3c81 100644
--- a/lib/ironic
+++ b/lib/ironic
@@ -149,11 +149,11 @@
         IRONIC_USER=$(keystone user-create \
             --name=ironic \
             --pass="$SERVICE_PASSWORD" \
-            --tenant_id $SERVICE_TENANT \
+            --tenant-id $SERVICE_TENANT \
             --email=ironic@example.com \
             | grep " id " | get_field 2)
         keystone user-role-add \
-            --tenant_id $SERVICE_TENANT \
+            --tenant-id $SERVICE_TENANT \
             --user_id $IRONIC_USER \
             --role_id $ADMIN_ROLE
         if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
diff --git a/lib/keystone b/lib/keystone
index 29b9604..a7e5d66 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -335,6 +335,14 @@
     fi
 }
 
+# Configure the API version for the OpenStack projects.
+# configure_API_version conf_file version
+function configure_API_version() {
+    local conf_file=$1
+    local api_version=$2
+    iniset $conf_file keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v$api_version
+}
+
 # init_keystone() - Initialize databases, etc.
 function init_keystone() {
     if is_service_enabled ldap; then
@@ -421,7 +429,7 @@
 # stop_keystone() - Stop running processes
 function stop_keystone() {
     # Kill the Keystone screen window
-    screen -S $SCREEN_NAME -p key -X kill
+    screen_stop key
 }
 
 
diff --git a/lib/marconi b/lib/marconi
index 742f866..6b9ffdc 100644
--- a/lib/marconi
+++ b/lib/marconi
@@ -142,7 +142,7 @@
 
     MARCONI_USER=$(get_id keystone user-create --name=marconi \
                                                 --pass="$SERVICE_PASSWORD" \
-                                                --tenant_id $SERVICE_TENANT \
+                                                --tenant-id $SERVICE_TENANT \
                                                 --email=marconi@example.com)
     keystone user-role-add --tenant-id $SERVICE_TENANT \
                             --user-id $MARCONI_USER \
diff --git a/lib/neutron b/lib/neutron
index a7519ad..43f43f9 100644
--- a/lib/neutron
+++ b/lib/neutron
@@ -328,7 +328,7 @@
         NEUTRON_USER=$(keystone user-create \
             --name=neutron \
             --pass="$SERVICE_PASSWORD" \
-            --tenant_id $SERVICE_TENANT \
+            --tenant-id $SERVICE_TENANT \
             --email=neutron@example.com \
             | grep " id " | get_field 2)
         keystone user-role-add \
@@ -357,7 +357,7 @@
 
     # Create a small network
     # Since neutron command is executed in admin context at this point,
-    # ``--tenant_id`` needs to be specified.
+    # ``--tenant-id`` needs to be specified.
     if is_baremetal; then
         if [[ "$PUBLIC_INTERFACE" == '' || "$OVS_PHYSICAL_BRIDGE" == '' ]]; then
             die $LINENO "Neutron settings for baremetal not set.. exiting"
@@ -367,16 +367,16 @@
             sudo ip addr del $IP dev $PUBLIC_INTERFACE
             sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE
         done
-        NET_ID=$(neutron net-create $PHYSICAL_NETWORK --tenant_id $TENANT_ID --provider:network_type flat --provider:physical_network "$PHYSICAL_NETWORK" | grep ' id ' | get_field 2)
+        NET_ID=$(neutron net-create $PHYSICAL_NETWORK --tenant-id $TENANT_ID --provider:network_type flat --provider:physical_network "$PHYSICAL_NETWORK" | grep ' id ' | get_field 2)
         die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $TENANT_ID"
-        SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
+        SUBNET_ID=$(neutron subnet-create --tenant-id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
         die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $TENANT_ID"
         sudo ifconfig $OVS_PHYSICAL_BRIDGE up
         sudo route add default gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE
     else
-        NET_ID=$(neutron net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
+        NET_ID=$(neutron net-create --tenant-id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
         die_if_not_set $LINENO NET_ID "Failure creating NET_ID for $PHYSICAL_NETWORK $TENANT_ID"
-        SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
+        SUBNET_ID=$(neutron subnet-create --tenant-id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
         die_if_not_set $LINENO SUBNET_ID "Failure creating SUBNET_ID for $TENANT_ID"
     fi
 
@@ -384,7 +384,7 @@
         # Create a router, and add the private subnet as one of its interfaces
         if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
             # create a tenant-owned router.
-            ROUTER_ID=$(neutron router-create --tenant_id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2)
+            ROUTER_ID=$(neutron router-create --tenant-id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2)
             die_if_not_set $LINENO ROUTER_ID "Failure creating ROUTER_ID for $TENANT_ID $Q_ROUTER_NAME"
         else
             # Plugin only supports creating a single router, which should be admin owned.
diff --git a/lib/neutron_plugins/nicira b/lib/neutron_plugins/nicira
deleted file mode 100644
index 87d3c3d..0000000
--- a/lib/neutron_plugins/nicira
+++ /dev/null
@@ -1,149 +0,0 @@
-# Neutron Nicira NVP plugin
-# ---------------------------
-
-# Save trace setting
-MY_XTRACE=$(set +o | grep xtrace)
-set +o xtrace
-
-source $TOP_DIR/lib/neutron_plugins/ovs_base
-
-function setup_integration_bridge() {
-    _neutron_ovs_base_setup_bridge $OVS_BRIDGE
-    # Set manager to NVP controller (1st of list)
-    if [[ "$NVP_CONTROLLERS" != "" ]]; then
-        # Get the first controller
-        controllers=(${NVP_CONTROLLERS//,/ })
-        OVS_MGR_IP=${controllers[0]}
-    else
-        die $LINENO "Error - No controller specified. Unable to set a manager for OVS"
-    fi
-    sudo ovs-vsctl set-manager ssl:$OVS_MGR_IP
-}
-
-function is_neutron_ovs_base_plugin() {
-    # NVP uses OVS, but not the l3-agent
-    return 0
-}
-
-function neutron_plugin_create_nova_conf() {
-    # if n-cpu is enabled, then setup integration bridge
-    if is_service_enabled n-cpu; then
-        setup_integration_bridge
-    fi
-}
-
-function neutron_plugin_install_agent_packages() {
-    # Nicira Plugin does not run q-agt, but it currently needs dhcp and metadata agents
-    _neutron_ovs_base_install_agent_packages
-}
-
-function neutron_plugin_configure_common() {
-    Q_PLUGIN_CONF_PATH=etc/neutron/plugins/nicira
-    Q_PLUGIN_CONF_FILENAME=nvp.ini
-    Q_DB_NAME="neutron_nvp"
-    Q_PLUGIN_CLASS="neutron.plugins.nicira.NeutronPlugin.NvpPluginV2"
-}
-
-function neutron_plugin_configure_debug_command() {
-    sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
-    iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT external_network_bridge "$PUBLIC_BRIDGE"
-}
-
-function neutron_plugin_configure_dhcp_agent() {
-    setup_integration_bridge
-    iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata True
-    iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network True
-    iniset $Q_DHCP_CONF_FILE DEFAULT ovs_use_veth True
-}
-
-function neutron_plugin_configure_l3_agent() {
-    # Nicira plugin does not run L3 agent
-    die $LINENO "q-l3 should must not be executed with Nicira plugin!"
-}
-
-function neutron_plugin_configure_plugin_agent() {
-    # Nicira plugin does not run L2 agent
-    die $LINENO "q-agt must not be executed with Nicira plugin!"
-}
-
-function neutron_plugin_configure_service() {
-    if [[ "$MAX_LP_PER_BRIDGED_LS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE nvp max_lp_per_bridged_ls $MAX_LP_PER_BRIDGED_LS
-    fi
-    if [[ "$MAX_LP_PER_OVERLAY_LS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE nvp max_lp_per_overlay_ls $MAX_LP_PER_OVERLAY_LS
-    fi
-    if [[ "$FAILOVER_TIME" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE nvp failover_time $FAILOVER_TIME
-    fi
-    if [[ "$CONCURRENT_CONNECTIONS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE nvp concurrent_connections $CONCURRENT_CONNECTIONS
-    fi
-
-    if [[ "$DEFAULT_TZ_UUID" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_tz_uuid $DEFAULT_TZ_UUID
-    else
-        die $LINENO "The nicira plugin won't work without a default transport zone."
-    fi
-    if [[ "$DEFAULT_L3_GW_SVC_UUID" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID
-        Q_L3_ENABLED=True
-        Q_L3_ROUTER_PER_TENANT=True
-        iniset /$Q_PLUGIN_CONF_FILE nvp metadata_mode access_network
-    fi
-    if [[ "$DEFAULT_L2_GW_SVC_UUID" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l2_gw_service_uuid $DEFAULT_L2_GW_SVC_UUID
-    fi
-    # NVP_CONTROLLERS must be a comma separated string
-    if [[ "$NVP_CONTROLLERS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nvp_controllers $NVP_CONTROLLERS
-    else
-        die $LINENO "The nicira plugin needs at least an NVP controller."
-    fi
-    if [[ "$NVP_USER" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nvp_user $NVP_USER
-    fi
-    if [[ "$NVP_PASSWORD" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nvp_password $NVP_PASSWORD
-    fi
-    if [[ "$NVP_REQ_TIMEOUT" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT req_timeout $NVP_REQ_TIMEOUT
-    fi
-    if [[ "$NVP_HTTP_TIMEOUT" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT http_timeout $NVP_HTTP_TIMEOUT
-    fi
-    if [[ "$NVP_RETRIES" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT retries $NVP_RETRIES
-    fi
-    if [[ "$NVP_REDIRECTS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT redirects $NVP_REDIRECTS
-    fi
-    if [[ "$AGENT_MODE" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE nvp agent_mode $AGENT_MODE
-        if [[ "$AGENT_MODE" == "agentless" ]]; then
-            if [[ "$DEFAULT_SERVICE_CLUSTER_UUID" != "" ]]; then
-                iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_service_cluster_uuid $DEFAULT_SERVICE_CLUSTER_UUID
-            else
-                die $LINENO "Agentless mode requires a service cluster."
-            fi
-            iniset /$Q_PLUGIN_CONF_FILE nvp_metadata metadata_server_address $Q_META_DATA_IP
-        fi
-    fi
-}
-
-function neutron_plugin_setup_interface_driver() {
-    local conf_file=$1
-    iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
-}
-
-function has_neutron_plugin_security_group() {
-    # 0 means True here
-    return 0
-}
-
-function neutron_plugin_check_adv_test_requirements() {
-    is_service_enabled q-dhcp && return 0
-}
-
-# Restore xtrace
-$MY_XTRACE
diff --git a/lib/neutron_plugins/vmware_nsx b/lib/neutron_plugins/vmware_nsx
new file mode 100644
index 0000000..d506cb6
--- /dev/null
+++ b/lib/neutron_plugins/vmware_nsx
@@ -0,0 +1,150 @@
+# Neutron VMware NSX plugin
+# -------------------------
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+source $TOP_DIR/lib/neutron_plugins/ovs_base
+
+function setup_integration_bridge() {
+    _neutron_ovs_base_setup_bridge $OVS_BRIDGE
+    # Set manager to NSX controller (1st of list)
+    if [[ "$NSX_CONTROLLERS" != "" ]]; then
+        # Get the first controller
+        controllers=(${NSX_CONTROLLERS//,/ })
+        OVS_MGR_IP=${controllers[0]}
+    else
+        die $LINENO "Error - No controller specified. Unable to set a manager for OVS"
+    fi
+    sudo ovs-vsctl set-manager ssl:$OVS_MGR_IP
+}
+
+function is_neutron_ovs_base_plugin() {
+    # NSX uses OVS, but not the l3-agent
+    return 0
+}
+
+function neutron_plugin_create_nova_conf() {
+    # if n-cpu is enabled, then setup integration bridge
+    if is_service_enabled n-cpu; then
+        setup_integration_bridge
+    fi
+}
+
+function neutron_plugin_install_agent_packages() {
+    # VMware NSX Plugin does not run q-agt, but it currently needs dhcp and metadata agents
+    _neutron_ovs_base_install_agent_packages
+}
+
+function neutron_plugin_configure_common() {
+    Q_PLUGIN_CONF_PATH=etc/neutron/plugins/vmware
+    Q_PLUGIN_CONF_FILENAME=nsx.ini
+    Q_DB_NAME="neutron_nsx"
+    # TODO(armando-migliaccio): rename this once the code rename is complete
+    Q_PLUGIN_CLASS="neutron.plugins.nicira.NeutronPlugin.NvpPluginV2"
+}
+
+function neutron_plugin_configure_debug_command() {
+    sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
+    iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT external_network_bridge "$PUBLIC_BRIDGE"
+}
+
+function neutron_plugin_configure_dhcp_agent() {
+    setup_integration_bridge
+    iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata True
+    iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network True
+    iniset $Q_DHCP_CONF_FILE DEFAULT ovs_use_veth True
+}
+
+function neutron_plugin_configure_l3_agent() {
+    # VMware NSX plugin does not run L3 agent
+    die $LINENO "q-l3 should must not be executed with VMware NSX plugin!"
+}
+
+function neutron_plugin_configure_plugin_agent() {
+    # VMware NSX plugin does not run L2 agent
+    die $LINENO "q-agt must not be executed with VMware NSX plugin!"
+}
+
+function neutron_plugin_configure_service() {
+    if [[ "$MAX_LP_PER_BRIDGED_LS" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE nsx max_lp_per_bridged_ls $MAX_LP_PER_BRIDGED_LS
+    fi
+    if [[ "$MAX_LP_PER_OVERLAY_LS" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE nsx max_lp_per_overlay_ls $MAX_LP_PER_OVERLAY_LS
+    fi
+    if [[ "$FAILOVER_TIME" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE nsx failover_time $FAILOVER_TIME
+    fi
+    if [[ "$CONCURRENT_CONNECTIONS" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE nsx concurrent_connections $CONCURRENT_CONNECTIONS
+    fi
+
+    if [[ "$DEFAULT_TZ_UUID" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_tz_uuid $DEFAULT_TZ_UUID
+    else
+        die $LINENO "The VMware NSX plugin won't work without a default transport zone."
+    fi
+    if [[ "$DEFAULT_L3_GW_SVC_UUID" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID
+        Q_L3_ENABLED=True
+        Q_L3_ROUTER_PER_TENANT=True
+        iniset /$Q_PLUGIN_CONF_FILE nsx metadata_mode access_network
+    fi
+    if [[ "$DEFAULT_L2_GW_SVC_UUID" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l2_gw_service_uuid $DEFAULT_L2_GW_SVC_UUID
+    fi
+    # NSX_CONTROLLERS must be a comma separated string
+    if [[ "$NSX_CONTROLLERS" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_controllers $NSX_CONTROLLERS
+    else
+        die $LINENO "The VMware NSX plugin needs at least an NSX controller."
+    fi
+    if [[ "$NSX_USER" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_user $NSX_USER
+    fi
+    if [[ "$NSX_PASSWORD" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_password $NSX_PASSWORD
+    fi
+    if [[ "$NSX_REQ_TIMEOUT" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT req_timeout $NSX_REQ_TIMEOUT
+    fi
+    if [[ "$NSX_HTTP_TIMEOUT" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT http_timeout $NSX_HTTP_TIMEOUT
+    fi
+    if [[ "$NSX_RETRIES" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT retries $NSX_RETRIES
+    fi
+    if [[ "$NSX_REDIRECTS" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE DEFAULT redirects $NSX_REDIRECTS
+    fi
+    if [[ "$AGENT_MODE" != "" ]]; then
+        iniset /$Q_PLUGIN_CONF_FILE nsx agent_mode $AGENT_MODE
+        if [[ "$AGENT_MODE" == "agentless" ]]; then
+            if [[ "$DEFAULT_SERVICE_CLUSTER_UUID" != "" ]]; then
+                iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_service_cluster_uuid $DEFAULT_SERVICE_CLUSTER_UUID
+            else
+                die $LINENO "Agentless mode requires a service cluster."
+            fi
+            iniset /$Q_PLUGIN_CONF_FILE nsx_metadata metadata_server_address $Q_META_DATA_IP
+        fi
+    fi
+}
+
+function neutron_plugin_setup_interface_driver() {
+    local conf_file=$1
+    iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
+}
+
+function has_neutron_plugin_security_group() {
+    # 0 means True here
+    return 0
+}
+
+function neutron_plugin_check_adv_test_requirements() {
+    is_service_enabled q-dhcp && return 0
+}
+
+# Restore xtrace
+$MY_XTRACE
diff --git a/lib/neutron_thirdparty/nicira b/lib/neutron_thirdparty/nicira
deleted file mode 100644
index a24392c..0000000
--- a/lib/neutron_thirdparty/nicira
+++ /dev/null
@@ -1,82 +0,0 @@
-# Nicira NVP
-# ----------
-
-# This third-party addition can be used to configure connectivity between a DevStack instance
-# and an NVP Gateway in dev/test environments. In order to use this correctly, the following
-# env variables need to be set (e.g. in your localrc file):
-#
-# * enable_service nicira            --> to execute this third-party addition
-# * PUBLIC_BRIDGE                    --> bridge used for external connectivity, typically br-ex
-# * NVP_GATEWAY_NETWORK_INTERFACE    --> interface used to communicate with the NVP Gateway
-# * NVP_GATEWAY_NETWORK_CIDR         --> CIDR to configure br-ex, e.g. 172.24.4.211/24
-
-# Save trace setting
-MY_XTRACE=$(set +o | grep xtrace)
-set +o xtrace
-
-# This is the interface that connects the Devstack instance
-# to an network that allows it to talk to the gateway for
-# testing purposes
-NVP_GATEWAY_NETWORK_INTERFACE=${NVP_GATEWAY_NETWORK_INTERFACE:-eth2}
-# Re-declare floating range as it's needed also in stop_nicira, which
-# is invoked by unstack.sh
-FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
-
-function configure_nicira() {
-    :
-}
-
-function init_nicira() {
-    if ! is_set NVP_GATEWAY_NETWORK_CIDR; then
-        NVP_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
-        echo "The IP address to set on br-ex was not specified. "
-        echo "Defaulting to "$NVP_GATEWAY_NETWORK_CIDR
-    fi
-    # Make sure the interface is up, but not configured
-    sudo ip link set $NVP_GATEWAY_NETWORK_INTERFACE up
-    # Save and then flush the IP addresses on the interface
-    addresses=$(ip addr show dev $NVP_GATEWAY_NETWORK_INTERFACE | grep inet | awk {'print $2'})
-    sudo ip addr flush $NVP_GATEWAY_NETWORK_INTERFACE
-    # Use the PUBLIC Bridge to route traffic to the NVP gateway
-    # NOTE(armando-migliaccio): if running in a nested environment this will work
-    # only with mac learning enabled, portsecurity and security profiles disabled
-    # The public bridge might not exist for the NVP plugin if Q_USE_DEBUG_COMMAND is off
-    # Try to create it anyway
-    sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
-    sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_INTERFACE
-    nvp_gw_net_if_mac=$(ip link show $NVP_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
-    sudo ip link set address $nvp_gw_net_if_mac dev $PUBLIC_BRIDGE
-    for address in $addresses; do
-        sudo ip addr add dev $PUBLIC_BRIDGE $address
-    done
-    sudo ip addr add dev $PUBLIC_BRIDGE $NVP_GATEWAY_NETWORK_CIDR
-}
-
-function install_nicira() {
-    :
-}
-
-function start_nicira() {
-    :
-}
-
-function stop_nicira() {
-    if ! is_set NVP_GATEWAY_NETWORK_CIDR; then
-        NVP_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
-        echo "The IP address expected on br-ex was not specified. "
-        echo "Defaulting to "$NVP_GATEWAY_NETWORK_CIDR
-    fi
-    sudo ip addr del $NVP_GATEWAY_NETWORK_CIDR dev $PUBLIC_BRIDGE
-    # Save and then flush remaining addresses on the interface
-    addresses=$(ip addr show dev $PUBLIC_BRIDGE | grep inet | awk {'print $2'})
-    sudo ip addr flush $PUBLIC_BRIDGE
-    # Try to detach physical interface from PUBLIC_BRIDGE
-    sudo ovs-vsctl del-port $NVP_GATEWAY_NETWORK_INTERFACE
-    # Restore addresses on NVP_GATEWAY_NETWORK_INTERFACE
-    for address in $addresses; do
-        sudo ip addr add dev $NVP_GATEWAY_NETWORK_INTERFACE $address
-    done
-}
-
-# Restore xtrace
-$MY_XTRACE
diff --git a/lib/neutron_thirdparty/vmware_nsx b/lib/neutron_thirdparty/vmware_nsx
new file mode 100644
index 0000000..70d3482
--- /dev/null
+++ b/lib/neutron_thirdparty/vmware_nsx
@@ -0,0 +1,82 @@
+# VMware NSX
+# ----------
+
+# This third-party addition can be used to configure connectivity between a DevStack instance
+# and an NSX Gateway in dev/test environments. In order to use this correctly, the following
+# env variables need to be set (e.g. in your localrc file):
+#
+# * enable_service vmware_nsx        --> to execute this third-party addition
+# * PUBLIC_BRIDGE                    --> bridge used for external connectivity, typically br-ex
+# * NSX_GATEWAY_NETWORK_INTERFACE    --> interface used to communicate with the NSX Gateway
+# * NSX_GATEWAY_NETWORK_CIDR         --> CIDR to configure br-ex, e.g. 172.24.4.211/24
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+# This is the interface that connects the Devstack instance
+# to an network that allows it to talk to the gateway for
+# testing purposes
+NSX_GATEWAY_NETWORK_INTERFACE=${NSX_GATEWAY_NETWORK_INTERFACE:-eth2}
+# Re-declare floating range as it's needed also in stop_vmware_nsx, which
+# is invoked by unstack.sh
+FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
+
+function configure_vmware_nsx() {
+    :
+}
+
+function init_vmware_nsx() {
+    if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
+        NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
+        echo "The IP address to set on br-ex was not specified. "
+        echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
+    fi
+    # Make sure the interface is up, but not configured
+    sudo ip link set $NSX_GATEWAY_NETWORK_INTERFACE up
+    # Save and then flush the IP addresses on the interface
+    addresses=$(ip addr show dev $NSX_GATEWAY_NETWORK_INTERFACE | grep inet | awk {'print $2'})
+    sudo ip addr flush $NSX_GATEWAY_NETWORK_INTERFACE
+    # Use the PUBLIC Bridge to route traffic to the NSX gateway
+    # NOTE(armando-migliaccio): if running in a nested environment this will work
+    # only with mac learning enabled, portsecurity and security profiles disabled
+    # The public bridge might not exist for the NSX plugin if Q_USE_DEBUG_COMMAND is off
+    # Try to create it anyway
+    sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
+    sudo ovs-vsctl -- --may-exist add-port $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_INTERFACE
+    nsx_gw_net_if_mac=$(ip link show $NSX_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
+    sudo ip link set address $nsx_gw_net_if_mac dev $PUBLIC_BRIDGE
+    for address in $addresses; do
+        sudo ip addr add dev $PUBLIC_BRIDGE $address
+    done
+    sudo ip addr add dev $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_CIDR
+}
+
+function install_vmware_nsx() {
+    :
+}
+
+function start_vmware_nsx() {
+    :
+}
+
+function stop_vmware_nsx() {
+    if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
+        NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
+        echo "The IP address expected on br-ex was not specified. "
+        echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
+    fi
+    sudo ip addr del $NSX_GATEWAY_NETWORK_CIDR dev $PUBLIC_BRIDGE
+    # Save and then flush remaining addresses on the interface
+    addresses=$(ip addr show dev $PUBLIC_BRIDGE | grep inet | awk {'print $2'})
+    sudo ip addr flush $PUBLIC_BRIDGE
+    # Try to detach physical interface from PUBLIC_BRIDGE
+    sudo ovs-vsctl del-port $NSX_GATEWAY_NETWORK_INTERFACE
+    # Restore addresses on NSX_GATEWAY_NETWORK_INTERFACE
+    for address in $addresses; do
+        sudo ip addr add dev $NSX_GATEWAY_NETWORK_INTERFACE $address
+    done
+}
+
+# Restore xtrace
+$MY_XTRACE
diff --git a/lib/nova b/lib/nova
index 39685a8..4eb56b8 100644
--- a/lib/nova
+++ b/lib/nova
@@ -318,7 +318,7 @@
         NOVA_USER=$(keystone user-create \
             --name=nova \
             --pass="$SERVICE_PASSWORD" \
-            --tenant_id $SERVICE_TENANT \
+            --tenant-id $SERVICE_TENANT \
             --email=nova@example.com \
             | grep " id " | get_field 2)
         keystone user-role-add \
@@ -705,7 +705,7 @@
     # Some services are listed here twice since more than one instance
     # of a service may be running in certain configs.
     for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cond n-cell n-cell n-api-meta; do
-        screen -S $SCREEN_NAME -p $serv -X kill
+        screen_stop $serv
     done
     if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
         stop_nova_hypervisor
diff --git a/lib/savanna b/lib/savanna
index 6794e36..bb4dfe6 100644
--- a/lib/savanna
+++ b/lib/savanna
@@ -56,7 +56,7 @@
     SAVANNA_USER=$(keystone user-create \
         --name=savanna \
         --pass="$SERVICE_PASSWORD" \
-        --tenant_id $SERVICE_TENANT \
+        --tenant-id $SERVICE_TENANT \
         --email=savanna@example.com \
         | grep " id " | get_field 2)
     keystone user-role-add \
diff --git a/lib/swift b/lib/swift
index 96929db..44c230b 100644
--- a/lib/swift
+++ b/lib/swift
@@ -514,7 +514,7 @@
     ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
 
     SWIFT_USER=$(keystone user-create --name=swift --pass="$SERVICE_PASSWORD" \
-        --tenant_id $SERVICE_TENANT --email=swift@example.com | grep " id " | get_field 2)
+        --tenant-id $SERVICE_TENANT --email=swift@example.com | grep " id " | get_field 2)
     keystone user-role-add --tenant-id $SERVICE_TENANT --user-id $SWIFT_USER --role-id $ADMIN_ROLE
 
     if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
diff --git a/lib/trove b/lib/trove
index f8e3edd..8e817f5 100644
--- a/lib/trove
+++ b/lib/trove
@@ -64,7 +64,7 @@
         TROVE_USER=$(keystone user-create \
             --name=trove \
             --pass="$SERVICE_PASSWORD" \
-            --tenant_id $SERVICE_TENANT \
+            --tenant-id $SERVICE_TENANT \
             --email=trove@example.com \
             | grep " id " | get_field 2)
         keystone user-role-add --tenant-id $SERVICE_TENANT \
@@ -198,7 +198,7 @@
 function stop_trove() {
     # Kill the trove screen windows
     for serv in tr-api tr-tmgr tr-cond; do
-        screen -S $SCREEN_NAME -p $serv -X kill
+        screen_stop $serv
     done
 }
 
diff --git a/stackrc b/stackrc
index 3fdc566..49fb26b 100644
--- a/stackrc
+++ b/stackrc
@@ -9,6 +9,9 @@
 # Destination for working data
 DATA_DIR=${DEST}/data
 
+# Destination for status files
+SERVICE_DIR=${DEST}/status
+
 # Determine stack user
 if [[ $EUID -eq 0 ]]; then
     STACK_USER=stack
diff --git a/unstack.sh b/unstack.sh
index 67c8b7c..77dbe07 100755
--- a/unstack.sh
+++ b/unstack.sh
@@ -36,6 +36,9 @@
 # Get project function libraries
 source $TOP_DIR/lib/baremetal
 source $TOP_DIR/lib/cinder
+source $TOP_DIR/lib/keystone
+source $TOP_DIR/lib/glance
+source $TOP_DIR/lib/nova
 source $TOP_DIR/lib/horizon
 source $TOP_DIR/lib/swift
 source $TOP_DIR/lib/neutron
@@ -75,21 +78,29 @@
     teardown_neutron_debug
 fi
 
-# Shut down devstack's screen to get the bulk of OpenStack services in one shot
-SCREEN=$(which screen)
-if [[ -n "$SCREEN" ]]; then
-    SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
-    if [[ -n "$SESSION" ]]; then
-        screen -X -S $SESSION quit
-    fi
+# Call service stop
+if is_service_enabled trove; then
+    stop_trove
 fi
 
-# Shut down Nova hypervisor plugins after Nova
-NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins
-if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
-    # Load plugin
-    source $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER
-    stop_nova_hypervisor
+if is_service_enabled heat; then
+    stop_heat
+fi
+
+if is_service_enabled ceilometer; then
+    stop_ceilometer
+fi
+
+if is_service_enabled nova; then
+    stop_nova
+fi
+
+if is_service_enabled g-api g-reg; then
+    stop_glance
+fi
+
+if is_service_enabled key; then
+    stop_keystone
 fi
 
 # Swift runs daemons
@@ -123,6 +134,7 @@
 
 # Get the iSCSI volumes
 if is_service_enabled cinder; then
+    stop_cinder
     cleanup_cinder
 fi
 
@@ -152,4 +164,13 @@
     cleanup_trove
 fi
 
+# Clean up the remainder of the screen processes
+SCREEN=$(which screen)
+if [[ -n "$SCREEN" ]]; then
+    SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
+    if [[ -n "$SESSION" ]]; then
+        screen -X -S $SESSION quit
+    fi
+fi
+
 cleanup_tmp