Merge "Adds new tag for testonly packages in package lists"
diff --git a/exercises/boot_from_volume.sh b/exercises/boot_from_volume.sh
index a3a14eb..36524ed 100755
--- a/exercises/boot_from_volume.sh
+++ b/exercises/boot_from_volume.sh
@@ -174,7 +174,8 @@
 fi
 
 # Get the instance IP
-IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
+IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME)
+
 die_if_not_set $LINENO IP "Failure retrieving IP address"
 
 # Private IPs can be pinged in single node deployments
diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh
index ac65cf7..f93a727 100755
--- a/exercises/floating_ips.sh
+++ b/exercises/floating_ips.sh
@@ -132,7 +132,7 @@
 fi
 
 # Get the instance IP
-IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
+IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME)
 die_if_not_set $LINENO IP "Failure retrieving IP address"
 
 # Private IPs can be pinged in single node deployments
diff --git a/exercises/neutron-adv-test.sh b/exercises/neutron-adv-test.sh
index 4367e2e..abb29cf 100755
--- a/exercises/neutron-adv-test.sh
+++ b/exercises/neutron-adv-test.sh
@@ -272,12 +272,12 @@
 }
 
 function ping_ip {
-   # Test agent connection.  Assumes namespaces are disabled, and
-   # that DHCP is in use, but not L3
-   local VM_NAME=$1
-   local NET_NAME=$2
-   IP=`nova show $VM_NAME | grep 'network' | awk '{print $5}'`
-   ping_check $NET_NAME $IP $BOOT_TIMEOUT
+     # Test agent connection.  Assumes namespaces are disabled, and
+     # that DHCP is in use, but not L3
+     local VM_NAME=$1
+     local NET_NAME=$2
+     IP=$(get_instance_ip $VM_NAME $NET_NAME)
+     ping_check $NET_NAME $IP $BOOT_TIMEOUT
 }
 
 function check_vm {
diff --git a/exercises/volumes.sh b/exercises/volumes.sh
index b2b391c..028d19b 100755
--- a/exercises/volumes.sh
+++ b/exercises/volumes.sh
@@ -135,7 +135,8 @@
 fi
 
 # Get the instance IP
-IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
+IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME)
+
 die_if_not_set $LINENO IP "Failure retrieving IP address"
 
 # Private IPs can be pinged in single node deployments
diff --git a/files/sources.list b/files/sources.list
deleted file mode 100644
index 77a1bfb..0000000
--- a/files/sources.list
+++ /dev/null
@@ -1,9 +0,0 @@
-deb http://mirror.rackspace.com/ubuntu/ %DIST% main restricted
-deb http://mirror.rackspace.com/ubuntu/ %DIST%-updates main restricted
-deb http://mirror.rackspace.com/ubuntu/ %DIST% universe
-deb http://mirror.rackspace.com/ubuntu/ %DIST%-updates universe
-deb http://mirror.rackspace.com/ubuntu/ %DIST% multiverse
-deb http://mirror.rackspace.com/ubuntu/ %DIST%-updates multiverse
-deb http://security.ubuntu.com/ubuntu %DIST%-security main restricted
-deb http://security.ubuntu.com/ubuntu %DIST%-security universe
-deb http://security.ubuntu.com/ubuntu %DIST%-security multiverse
diff --git a/functions b/functions
index 5546def..ae151fe 100644
--- a/functions
+++ b/functions
@@ -407,8 +407,9 @@
         # CentOS release 5.5 (Final)
         # CentOS Linux release 6.0 (Final)
         # Fedora release 16 (Verne)
+        # XenServer release 6.2.0-70446c (xenenterprise)
         os_CODENAME=""
-        for r in "Red Hat" CentOS Fedora; do
+        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`
@@ -471,6 +472,8 @@
     elif [[ "$os_VENDOR" =~ (Red Hat) || "$os_VENDOR" =~ (CentOS) ]]; then
         # Drop the . release as we assume it's compatible
         DISTRO="rhel${os_RELEASE::1}"
+    elif [[ "$os_VENDOR" =~ (XenServer) ]]; then
+        DISTRO="xs$os_RELEASE"
     else
         # Catch-all for now is Vendor + Release + Update
         DISTRO="$os_VENDOR-$os_RELEASE.$os_UPDATE"
@@ -929,7 +932,7 @@
     fi
 
     if [[ "$os_PACKAGE" = "deb" ]]; then
-        dpkg -l "$@" > /dev/null
+        dpkg -l "$@" > /dev/null 2> /dev/null
     elif [[ "$os_PACKAGE" = "rpm" ]]; then
         rpm --quiet -q "$@"
     else
@@ -1080,7 +1083,7 @@
             sleep 1.5
 
             NL=`echo -ne '\015'`
-            screen -S $SCREEN_NAME -p $1 -X stuff "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL"
+            screen -S $SCREEN_NAME -p $1 -X stuff "$2 || 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
@@ -1453,6 +1456,19 @@
     fi
 }
 
+# Get ip of instance
+function get_instance_ip(){
+    local vm_id=$1
+    local network_name=$2
+    local nova_result="$(nova show $vm_id)"
+    local ip=$(echo "$nova_result" | grep "$network_name" | get_field 2)
+    if [[ $ip = "" ]];then
+        echo "$nova_result"
+        die $LINENO "[Fail] Coudn't get ipaddress of VM"
+        exit 1
+    fi
+    echo $ip
+}
 
 # ssh check
 
diff --git a/lib/cinder b/lib/cinder
index b39fbdc..826b958 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -287,6 +287,13 @@
             CINDER_GLUSTERFS_SHARES=$(echo $CINDER_GLUSTERFS_SHARES | tr ";" "\n")
             echo "$CINDER_GLUSTERFS_SHARES" > $CINDER_CONF_DIR/glusterfs_shares
         fi
+    elif [ "$CINDER_DRIVER" == "vsphere" ]; then
+        echo_summary "Using VMware vCenter driver"
+        iniset $CINDER_CONF DEFAULT vmware_host_ip "$VMWAREAPI_IP"
+        iniset $CINDER_CONF DEFAULT vmware_host_username "$VMWAREAPI_USER"
+        iniset $CINDER_CONF DEFAULT vmware_host_password "$VMWAREAPI_PASSWORD"
+        iniset $CINDER_CONF DEFAULT vmware_cluster_name "$VMWAREAPI_CLUSTER"
+        iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver"
     fi
 
     if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
@@ -460,6 +467,7 @@
 function install_cinderclient() {
     git_clone $CINDERCLIENT_REPO $CINDERCLIENT_DIR $CINDERCLIENT_BRANCH
     setup_develop $CINDERCLIENT_DIR
+    sudo install -D -m 0644 -o $STACK_USER {$CINDERCLIENT_DIR/tools/,/etc/bash_completion.d/}cinder.bash_completion
 }
 
 # apply config.d approach for cinder volumes directory
diff --git a/lib/heat b/lib/heat
index f7a76dd..5d6c6aa 100644
--- a/lib/heat
+++ b/lib/heat
@@ -31,6 +31,8 @@
 HEATCLIENT_DIR=$DEST/python-heatclient
 HEAT_AUTH_CACHE_DIR=${HEAT_AUTH_CACHE_DIR:-/var/cache/heat}
 HEAT_STANDALONE=`trueorfalse False $HEAT_STANDALONE`
+HEAT_CONF_DIR=/etc/heat
+HEAT_ENV_DIR=$HEAT_CONF_DIR/environment.d
 
 # Functions
 # ---------
@@ -39,13 +41,13 @@
 # runs that a clean run would need to clean up
 function cleanup_heat() {
     sudo rm -rf $HEAT_AUTH_CACHE_DIR
+    sudo rm -rf $HEAT_ENV_DIR
 }
 
 # configure_heat() - Set config files, create data dirs, etc
 function configure_heat() {
     setup_develop $HEAT_DIR
 
-    HEAT_CONF_DIR=/etc/heat
     if [[ ! -d $HEAT_CONF_DIR ]]; then
         sudo mkdir -p $HEAT_CONF_DIR
     fi
@@ -125,6 +127,14 @@
 
     iniset_rpc_backend heat $HEAT_ENGINE_CONF DEFAULT
 
+    if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
+        # Add color to logging output
+        iniset $HEAT_ENGINE_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s%(color)s] %(instance)s%(color)s%(message)s"
+        iniset $HEAT_ENGINE_CONF DEFAULT logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
+        iniset $HEAT_ENGINE_CONF DEFAULT logging_debug_format_suffix "from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
+        iniset $HEAT_ENGINE_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s"
+    fi
+
     # Cloudwatch API
     HEAT_API_CW_CONF=$HEAT_CONF_DIR/heat-api-cloudwatch.conf
     cp $HEAT_DIR/etc/heat/heat-api-cloudwatch.conf $HEAT_API_CW_CONF
@@ -147,6 +157,12 @@
 
     iniset_rpc_backend heat $HEAT_API_CW_CONF DEFAULT
 
+    # heat environment
+    sudo mkdir -p $HEAT_ENV_DIR
+    sudo chown $STACK_USER $HEAT_ENV_DIR
+    # copy the default environment
+    cp $HEAT_DIR/etc/heat/environment.d/* $HEAT_ENV_DIR/
+
 }
 
 # init_heat() - Initialize database
diff --git a/lib/horizon b/lib/horizon
index 89bd659..a879d1e 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -106,13 +106,13 @@
     sudo mkdir -p $HORIZON_DIR/.blackhole
 
     HORIZON_REQUIRE=''
-    local horizon_conf=/etc/$APACHE_NAME/$APACHE_CONF_DIR/horizon
+    local horizon_conf=/etc/$APACHE_NAME/$APACHE_CONF_DIR/horizon.conf
     if is_ubuntu; then
         # Clean up the old config name
         sudo rm -f /etc/apache2/sites-enabled/000-default
         # Be a good citizen and use the distro tools here
         sudo touch $horizon_conf
-        sudo a2ensite horizon
+        sudo a2ensite horizon.conf
         # WSGI isn't enabled by default, enable it
         sudo a2enmod wsgi
     elif is_fedora; then
diff --git a/lib/keystone b/lib/keystone
index e7e0544..0a35dd5 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -289,6 +289,7 @@
 function install_keystoneclient() {
     git_clone $KEYSTONECLIENT_REPO $KEYSTONECLIENT_DIR $KEYSTONECLIENT_BRANCH
     setup_develop $KEYSTONECLIENT_DIR
+    sudo install -D -m 0644 -o $STACK_USER {$KEYSTONECLIENT_DIR/tools/,/etc/bash_completion.d/}keystone.bash_completion
 }
 
 # install_keystone() - Collect source and prepare
diff --git a/lib/neutron b/lib/neutron
index 31876de..c041cd4 100644
--- a/lib/neutron
+++ b/lib/neutron
@@ -250,18 +250,18 @@
 }
 
 function create_nova_conf_neutron() {
-    iniset $NOVA_CONF DEFAULT network_api_class "nova.network.quantumv2.api.API"
-    iniset $NOVA_CONF DEFAULT quantum_admin_username "$Q_ADMIN_USERNAME"
-    iniset $NOVA_CONF DEFAULT quantum_admin_password "$SERVICE_PASSWORD"
-    iniset $NOVA_CONF DEFAULT quantum_admin_auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0"
-    iniset $NOVA_CONF DEFAULT quantum_auth_strategy "$Q_AUTH_STRATEGY"
-    iniset $NOVA_CONF DEFAULT quantum_admin_tenant_name "$SERVICE_TENANT_NAME"
-    iniset $NOVA_CONF DEFAULT quantum_region_name "RegionOne"
-    iniset $NOVA_CONF DEFAULT quantum_url "http://$Q_HOST:$Q_PORT"
+    iniset $NOVA_CONF DEFAULT network_api_class "nova.network.neutronv2.api.API"
+    iniset $NOVA_CONF DEFAULT neutron_admin_username "$Q_ADMIN_USERNAME"
+    iniset $NOVA_CONF DEFAULT neutron_admin_password "$SERVICE_PASSWORD"
+    iniset $NOVA_CONF DEFAULT neutron_admin_auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0"
+    iniset $NOVA_CONF DEFAULT neutron_auth_strategy "$Q_AUTH_STRATEGY"
+    iniset $NOVA_CONF DEFAULT neutron_admin_tenant_name "$SERVICE_TENANT_NAME"
+    iniset $NOVA_CONF DEFAULT neutron_region_name "RegionOne"
+    iniset $NOVA_CONF DEFAULT neutron_url "http://$Q_HOST:$Q_PORT"
 
     if [[ "$Q_USE_SECGROUP" == "True" ]]; then
         LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
-        iniset $NOVA_CONF DEFAULT security_group_api quantum
+        iniset $NOVA_CONF DEFAULT security_group_api neutron
     fi
 
     # set NOVA_VIF_DRIVER and optionally set options in nova_conf
@@ -270,7 +270,7 @@
     iniset $NOVA_CONF DEFAULT libvirt_vif_driver "$NOVA_VIF_DRIVER"
     iniset $NOVA_CONF DEFAULT linuxnet_interface_driver "$LINUXNET_VIF_DRIVER"
     if is_service_enabled q-meta; then
-        iniset $NOVA_CONF DEFAULT service_quantum_metadata_proxy "True"
+        iniset $NOVA_CONF DEFAULT service_neutron_metadata_proxy "True"
     fi
 }
 
@@ -382,6 +382,7 @@
 function install_neutronclient() {
     git_clone $NEUTRONCLIENT_REPO $NEUTRONCLIENT_DIR $NEUTRONCLIENT_BRANCH
     setup_develop $NEUTRONCLIENT_DIR
+    sudo install -D -m 0644 -o $STACK_USER {$NEUTRONCLIENT_DIR/tools/,/etc/bash_completion.d/}neutron.bash_completion
 }
 
 # install_neutron_agent_packages() - Collect source and prepare
@@ -541,6 +542,14 @@
     iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
     iniset $Q_DHCP_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
 
+    # Define extra "DEFAULT" configuration options when q-dhcp is configured by
+    # defining the array ``Q_DHCP_EXTRA_DEFAULT_OPTS``.
+    # For Example: ``Q_DHCP_EXTRA_DEFAULT_OPTS=(foo=true bar=2)``
+    for I in "${Q_DHCP_EXTRA_DEFAULT_OPTS[@]}"; do
+        # Replace the first '=' with ' ' for iniset syntax
+        iniset $Q_DHCP_CONF_FILE DEFAULT ${I/=/ }
+    done
+
     _neutron_setup_interface_driver $Q_DHCP_CONF_FILE
 
     neutron_plugin_configure_dhcp_agent
@@ -577,7 +586,7 @@
     iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP
     iniset $Q_META_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
 
-    _neutron_setup_keystone $Q_META_CONF_FILE DEFAULT True True
+    _neutron_setup_keystone $Q_META_CONF_FILE DEFAULT True True True
 
 }
 
@@ -690,11 +699,16 @@
     local section=$2
     local use_auth_url=$3
     local skip_auth_cache=$4
+    local use_service_port=$5
+    local keystone_port=$KEYSTONE_AUTH_PORT
+    if [[ -n $use_service_port ]]; then
+        keystone_port=$KEYSTONE_SERVICE_PORT
+    fi
     if [[ -n $use_auth_url ]]; then
-        iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0"
+        iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$keystone_port/v2.0"
     else
         iniset $conf_file $section auth_host $KEYSTONE_SERVICE_HOST
-        iniset $conf_file $section auth_port $KEYSTONE_AUTH_PORT
+        iniset $conf_file $section auth_port $keystone_port
         iniset $conf_file $section auth_protocol $KEYSTONE_SERVICE_PROTOCOL
     fi
     iniset $conf_file $section admin_tenant_name $SERVICE_TENANT_NAME
diff --git a/lib/neutron_plugins/nicira b/lib/neutron_plugins/nicira
index eabc417..e9deb64 100644
--- a/lib/neutron_plugins/nicira
+++ b/lib/neutron_plugins/nicira
@@ -90,7 +90,7 @@
         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 enable_metadata_access_network 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
diff --git a/lib/nova b/lib/nova
index 842c098..a835386 100644
--- a/lib/nova
+++ b/lib/nova
@@ -451,6 +451,7 @@
     if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then
         iniset $NOVA_CONF DEFAULT libvirt_type "$LIBVIRT_TYPE"
         iniset $NOVA_CONF DEFAULT libvirt_cpu_mode "none"
+        iniset $NOVA_CONF DEFAULT use_usb_tablet "False"
     fi
     iniset $NOVA_CONF DEFAULT instance_name_template "${INSTANCE_NAME_PREFIX}%08x"
     iniset $NOVA_CONF osapi_v3 enabled "True"
@@ -645,6 +646,7 @@
 function install_novaclient() {
     git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
     setup_develop $NOVACLIENT_DIR
+    sudo install -D -m 0644 -o $STACK_USER {$NOVACLIENT_DIR/tools/,/etc/bash_completion.d/}nova.bash_completion
 }
 
 # install_nova() - Collect source and prepare
@@ -682,6 +684,7 @@
 
     git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
     setup_develop $NOVA_DIR
+    sudo install -D -m 0644 -o $STACK_USER {$NOVA_DIR/tools/,/etc/bash_completion.d/}nova-manage.bash_completion
 }
 
 # start_nova_api() - Start the API process ahead of other things
diff --git a/lib/oslo b/lib/oslo
index de5ec4e..f77a4fa 100644
--- a/lib/oslo
+++ b/lib/oslo
@@ -40,12 +40,12 @@
 
 # cleanup_oslo() - purge possibly old versions of oslo
 function cleanup_oslo() {
-    # this means we've got an old olso installed, lets get rid of it
-    if find /usr | grep oslo.config | grep -v oslo.config.egg-link > /dev/null; then
+    # this means we've got an old oslo installed, lets get rid of it
+    if ! python -c 'import oslo.config' 2>/dev/null; then
         echo "Found old oslo.config... removing to ensure consistency"
         local PIP_CMD=$(get_pip_command)
-        pip_install olso.config
-        sudo $PIP_CMD uninstall -y olso.config
+        pip_install oslo.config
+        sudo $PIP_CMD uninstall -y oslo.config
     fi
 }
 
diff --git a/lib/tempest b/lib/tempest
index 0d4f370..50289b6 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -282,6 +282,9 @@
     # Scenario
     iniset $TEMPEST_CONF scenario img_dir "$FILES/images/cirros-0.3.1-x86_64-uec"
 
+    # Large Ops Number
+    iniset $TEMPEST_CONF scenario large_ops_number ${TEMPEST_LARGE_OPS_NUMBER:-0}
+
     # Volume
     CINDER_MULTI_LVM_BACKEND=$(trueorfalse False $CINDER_MULTI_LVM_BACKEND)
     if [ $CINDER_MULTI_LVM_BACKEND == "True" ]; then
diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh
index 92b1317..997644d 100755
--- a/tools/xen/install_os_domU.sh
+++ b/tools/xen/install_os_domU.sh
@@ -29,6 +29,10 @@
 # xapi functions
 . $THIS_DIR/functions
 
+# Determine what system we are running on.
+# Might not be XenServer if we're using xenserver-core
+GetDistro
+
 #
 # Get Settings
 #