Merge "Neutron: Define a utility function to add neutron service class"
diff --git a/.gitignore b/.gitignore
index 49eb188..c49b4a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
 local.sh
 files/*.gz
 files/images
+files/pip-*
 stack-screenrc
 *.pem
 accrc
diff --git a/exercises/marconi.sh b/exercises/marconi.sh
index 1b9788d..9d83a99 100755
--- a/exercises/marconi.sh
+++ b/exercises/marconi.sh
@@ -35,7 +35,7 @@
 
 is_service_enabled marconi-server || exit 55
 
-curl http://$SERVICE_HOST:8888/v1/ 2>/dev/null | grep -q 'Auth' || die $LINENO "Marconi API not functioning!"
+curl http://$SERVICE_HOST:8888/v1/ 2>/dev/null | grep -q 'queue_name' || die $LINENO "Marconi API not functioning!"
 
 set +o xtrace
 echo "*********************************************************************"
diff --git a/files/apts/tempest b/files/apts/tempest
new file mode 100644
index 0000000..f244e4e
--- /dev/null
+++ b/files/apts/tempest
@@ -0,0 +1 @@
+libxslt1-dev
\ No newline at end of file
diff --git a/files/rpms/tempest b/files/rpms/tempest
new file mode 100644
index 0000000..de32b81
--- /dev/null
+++ b/files/rpms/tempest
@@ -0,0 +1 @@
+libxslt-dev
\ No newline at end of file
diff --git a/functions b/functions
index 7e08190..e79e1d5 100644
--- a/functions
+++ b/functions
@@ -422,6 +422,7 @@
         os_CODENAME=$(lsb_release -c -s)
     elif [[ -r /etc/redhat-release ]]; then
         # Red Hat Enterprise Linux Server release 5.5 (Tikanga)
+        # Red Hat Enterprise Linux Server release 7.0 Beta (Maipo)
         # CentOS release 5.5 (Final)
         # CentOS Linux release 6.0 (Final)
         # Fedora release 16 (Verne)
@@ -430,7 +431,7 @@
         for r in "Red Hat" CentOS Fedora XenServer; do
             os_VENDOR=$r
             if [[ -n "`grep \"$r\" /etc/redhat-release`" ]]; then
-                ver=`sed -e 's/^.* \(.*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release`
+                ver=`sed -e 's/^.* \([0-9].*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release`
                 os_CODENAME=${ver#*|}
                 os_RELEASE=${ver%|*}
                 os_UPDATE=${os_RELEASE##*.}
diff --git a/lib/config b/lib/config
index c28072f..1678aec 100644
--- a/lib/config
+++ b/lib/config
@@ -35,7 +35,7 @@
 
     $CONFIG_AWK_CMD -v matchgroup=$matchgroup -v configfile=$configfile '
         BEGIN { group = "" }
-        /^\[\[.+|.*\]\]/ {
+        /^\[\[.+\|.*\]\]/ {
             if (group == "") {
                 gsub("[][]", "", $1);
                 split($1, a, "|");
diff --git a/lib/glance b/lib/glance
index 2e29a8f..b278796 100644
--- a/lib/glance
+++ b/lib/glance
@@ -124,6 +124,8 @@
         iniset $GLANCE_API_CONF DEFAULT swift_store_user $SERVICE_TENANT_NAME:glance
         iniset $GLANCE_API_CONF DEFAULT swift_store_key $SERVICE_PASSWORD
         iniset $GLANCE_API_CONF DEFAULT swift_store_create_container_on_put True
+
+        iniset_multiline DEFAULT known_stores glance.store.filesystem.Store glance.store.http.Store glance.store.swift.Store
     fi
 
     cp -p $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI
diff --git a/lib/keystone b/lib/keystone
index 712a509..29b9604 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -403,7 +403,7 @@
         screen_it key "cd $KEYSTONE_DIR && sudo tail -f /var/log/$APACHE_NAME/keystone"
     else
         # Start Keystone in a screen window
-        screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug"
+        screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG --debug"
     fi
 
     echo "Waiting for keystone to start..."
diff --git a/lib/marconi b/lib/marconi
index 8e0b82b..742f866 100644
--- a/lib/marconi
+++ b/lib/marconi
@@ -148,10 +148,11 @@
                             --user-id $MARCONI_USER \
                             --role-id $ADMIN_ROLE
     if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
-        MARCONI_SERVICE=$(get_id keystone service-create \
+        MARCONI_SERVICE=$(keystone service-create \
             --name=marconi \
             --type=queuing \
-            --description="Marconi Service")
+            --description="Marconi Service" \
+            | grep " id " | get_field 2)
         keystone endpoint-create \
             --region RegionOne \
             --service_id $MARCONI_SERVICE \
diff --git a/lib/neutron b/lib/neutron
index 3808165..a7519ad 100644
--- a/lib/neutron
+++ b/lib/neutron
@@ -69,7 +69,7 @@
 
 # Gateway and subnet defaults, in case they are not customized in localrc
 NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
-PUBLIC_NETWORK_GATEWAY=${PUBLIC_NETWORK_GATEWAY:-172.24.4.225}
+PUBLIC_NETWORK_GATEWAY=${PUBLIC_NETWORK_GATEWAY:-172.24.4.1}
 PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"}
 PUBLIC_SUBNET_NAME=${PUBLIC_SUBNET_NAME:-"public-subnet"}
 
@@ -508,6 +508,19 @@
         pid=$(ps aux | awk '/neutron-ns-metadata-proxy/ { print $2 }')
         [ ! -z "$pid" ] && sudo kill -9 $pid
     fi
+
+    if is_service_enabled q-lbaas; then
+        neutron_lbaas_stop
+    fi
+    if is_service_enabled q-fwaas; then
+        neutron_fwaas_stop
+    fi
+    if is_service_enabled q-vpn; then
+        neutron_vpn_stop
+    fi
+    if is_service_enabled q-metering; then
+        neutron_metering_stop
+    fi
 }
 
 # cleanup_neutron() - Remove residual data files, anything left over from previous
@@ -518,7 +531,7 @@
     fi
 
     # delete all namespaces created by neutron
-    for ns in $(sudo ip netns list | grep -o -e qdhcp-[0-9a-f\-]* -e qrouter-[0-9a-f\-]*); do
+    for ns in $(sudo ip netns list | grep -o -E '(qdhcp|qrouter|qlbaas)-[0-9a-f-]*'); do
         sudo ip netns delete ${ns}
     done
 }
diff --git a/lib/neutron_plugins/services/firewall b/lib/neutron_plugins/services/firewall
index 97cc5a2..8273e54 100644
--- a/lib/neutron_plugins/services/firewall
+++ b/lib/neutron_plugins/services/firewall
@@ -19,5 +19,9 @@
     iniset_multiline $FWAAS_DRIVER_CONF_FILENAME fwaas driver "neutron.services.firewall.drivers.linux.iptables_fwaas.IptablesFwaasDriver"
 }
 
+function neutron_fwaas_stop() {
+    :
+}
+
 # Restore xtrace
 $MY_XTRACE
diff --git a/lib/neutron_plugins/services/loadbalancer b/lib/neutron_plugins/services/loadbalancer
index 6ff991c..5d7a94e 100644
--- a/lib/neutron_plugins/services/loadbalancer
+++ b/lib/neutron_plugins/services/loadbalancer
@@ -41,5 +41,10 @@
     fi
 }
 
+function neutron_lbaas_stop() {
+    pids=$(ps aux | awk '/haproxy/ { print $2 }')
+    [ ! -z "$pids" ] && sudo kill $pids
+}
+
 # Restore xtrace
 $MY_XTRACE
diff --git a/lib/neutron_plugins/services/metering b/lib/neutron_plugins/services/metering
index 5cabfbf..37952bb 100644
--- a/lib/neutron_plugins/services/metering
+++ b/lib/neutron_plugins/services/metering
@@ -22,5 +22,9 @@
     cp $NEUTRON_DIR/etc/metering_agent.ini $METERING_AGENT_CONF_FILENAME
 }
 
+function neutron_metering_stop() {
+    :
+}
+
 # Restore xtrace
 $MY_XTRACE
diff --git a/lib/neutron_plugins/services/vpn b/lib/neutron_plugins/services/vpn
index 1ab07cb..02370e7 100644
--- a/lib/neutron_plugins/services/vpn
+++ b/lib/neutron_plugins/services/vpn
@@ -18,5 +18,16 @@
     _neutron_service_plugin_class_add $VPN_PLUGIN
 }
 
+function neutron_vpn_stop() {
+    local ipsec_data_dir=$DATA_DIR/neutron/ipsec
+    local pids
+    if [ -d $ipsec_data_dir ]; then
+        pids=$(find $ipsec_data_dir -name 'pluto.pid' -exec cat {} \;)
+    fi
+    if [ -n "$pids" ]; then
+        sudo kill $pids
+    fi
+}
+
 # Restore xtrace
 $MY_XTRACE
diff --git a/lib/neutron_thirdparty/nicira b/lib/neutron_thirdparty/nicira
index 3efb5a9..a24392c 100644
--- a/lib/neutron_thirdparty/nicira
+++ b/lib/neutron_thirdparty/nicira
@@ -20,7 +20,7 @@
 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.224/28}
+FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
 
 function configure_nicira() {
     :
diff --git a/lib/neutron_thirdparty/trema b/lib/neutron_thirdparty/trema
index 9efd3f6..bdc2356 100644
--- a/lib/neutron_thirdparty/trema
+++ b/lib/neutron_thirdparty/trema
@@ -62,7 +62,7 @@
     sudo sed -i -e "s|/home/sliceable_switch/script|$TREMA_SS_SCRIPT_DIR|" \
         $TREMA_SS_APACHE_CONFIG
     sudo a2enmod rewrite actions
-    sudo a2ensite sliceable_switch
+    sudo a2ensite sliceable_switch.conf
 
     cp $TREMA_SS_DIR/sliceable_switch_null.conf $TREMA_SS_CONFIG
     sed -i -e "s|^\$apps_dir.*$|\$apps_dir = \"$TREMA_DIR/apps\"|" \
diff --git a/lib/swift b/lib/swift
index 3bf2b78..96929db 100644
--- a/lib/swift
+++ b/lib/swift
@@ -378,8 +378,8 @@
         iniuncomment ${swift_node_config} DEFAULT log_facility
         iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
 
-        iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers
-        iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1
+        iniuncomment ${swift_node_config} DEFAULT workers
+        iniset ${swift_node_config} DEFAULT workers 1
 
         iniuncomment ${swift_node_config} DEFAULT disable_fallocate
         iniset ${swift_node_config} DEFAULT disable_fallocate true
diff --git a/lib/tempest b/lib/tempest
index aa06791..0969b2d 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -324,6 +324,9 @@
     # cli
     iniset $TEMPEST_CONF cli cli_dir $NOVA_BIN_DIR
 
+    # Networking
+    iniset $TEMPEST_CONF network-feature-enabled api_extensions "${NETWORK_API_EXTENSIONS:-all}"
+
     # service_available
     for service in nova cinder glance neutron swift heat horizon ceilometer ironic savanna; do
         if is_service_enabled $service ; then
diff --git a/stack.sh b/stack.sh
index 22d184e..d54a652 100755
--- a/stack.sh
+++ b/stack.sh
@@ -260,7 +260,7 @@
 # from either range when attempting to guess the IP to use for the host.
 # Note that setting FIXED_RANGE may be necessary when running DevStack
 # in an OpenStack cloud that uses either of these address ranges internally.
-FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28}
+FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
 FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
 FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
 
@@ -1104,10 +1104,7 @@
 
 if is_service_enabled q-svc; then
     echo_summary "Starting Neutron"
-
     start_neutron_service_and_check
-    create_neutron_initial_network
-    setup_neutron_debug
 elif is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-net; then
     NM_CONF=${NOVA_CONF}
     if is_service_enabled n-cell; then
@@ -1127,6 +1124,12 @@
 if is_service_enabled neutron; then
     start_neutron_agents
 fi
+# Once neutron agents are started setup initial network elements
+if is_service_enabled q-svc; then
+    echo_summary "Creating initial neutron network elements"
+    create_neutron_initial_network
+    setup_neutron_debug
+fi
 if is_service_enabled nova; then
     echo_summary "Starting Nova"
     start_nova
diff --git a/stackrc b/stackrc
index 410f9d8..695bdb1 100644
--- a/stackrc
+++ b/stackrc
@@ -282,6 +282,10 @@
         IMAGE_URLS=${IMAGE_URLS:-"http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz"};;
 esac
 
+HEAT_FETCHED_TEST_IMAGE=${HEAT_FETCHED_TEST_IMAGE:-""}
+if [[ "$HEAT_FETCHED_TEST_IMAGE" == "Fedora-i386-20-20131211.1-sda" ]]; then
+    IMAGE_URLS+=",https://dl.fedoraproject.org/pub/fedora/linux/releases/20/Images/i386/$HEAT_FETCHED_TEST_IMAGE.qcow2"
+fi
 
 # 10Gb default volume backing file size
 VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-10250M}
diff --git a/tools/docker/install_docker.sh b/tools/docker/install_docker.sh
index 2e5b510..375cfe9 100755
--- a/tools/docker/install_docker.sh
+++ b/tools/docker/install_docker.sh
@@ -45,7 +45,7 @@
 
 echo "Waiting for docker daemon to start..."
 DOCKER_GROUP=$(groups | cut -d' ' -f1)
-CONFIGURE_CMD="while ! /bin/echo -e 'GET /v1.3/version HTTP/1.0\n\n' | socat - unix-connect:$DOCKER_UNIX_SOCKET | grep -q '200 OK'; do
+CONFIGURE_CMD="while ! /bin/echo -e 'GET /v1.3/version HTTP/1.0\n\n' | socat - unix-connect:$DOCKER_UNIX_SOCKET 2>/dev/null | grep -q '200 OK'; do
     # Set the right group on docker unix socket before retrying
     sudo chgrp $DOCKER_GROUP $DOCKER_UNIX_SOCKET
     sudo chmod g+rw $DOCKER_UNIX_SOCKET
diff --git a/tools/xen/xenrc b/tools/xen/xenrc
index c0ea3bc..cd28234 100644
--- a/tools/xen/xenrc
+++ b/tools/xen/xenrc
@@ -63,8 +63,8 @@
 PUB_NETMASK=${PUB_NETMASK:-255.255.255.0}
 
 # Ubuntu install settings
-UBUNTU_INST_RELEASE="precise"
-UBUNTU_INST_TEMPLATE_NAME="Ubuntu 12.04 (64-bit) for DevStack"
+UBUNTU_INST_RELEASE="saucy"
+UBUNTU_INST_TEMPLATE_NAME="Ubuntu 13.10 (64-bit) for DevStack"
 # For 12.04 use "precise" and update template name
 # However, for 12.04, you should be using
 # XenServer 6.1 and later or XCP 1.6 or later