Merge "Install libguestfs for nova-compute on Ubuntu"
diff --git a/extras.d/70-gantt.sh b/extras.d/70-gantt.sh
new file mode 100644
index 0000000..ac1efba
--- /dev/null
+++ b/extras.d/70-gantt.sh
@@ -0,0 +1,31 @@
+# gantt.sh - Devstack extras script to install Gantt
+
+if is_service_enabled n-sch; then
+    disable_service gantt
+fi
+
+if is_service_enabled gantt; then
+    if [[ "$1" == "source" ]]; then
+        # Initial source
+        source $TOP_DIR/lib/gantt
+    elif [[ "$1" == "stack" && "$2" == "install" ]]; then
+        echo_summary "Installing Gantt"
+        install_gantt
+        cleanup_gantt
+    elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
+        echo_summary "Configuring Gantt"
+        configure_gantt
+
+    elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
+        # Initialize gantt
+        init_gantt
+
+        # Start gantt
+        echo_summary "Starting Gantt"
+        start_gantt
+    fi
+
+    if [[ "$1" == "unstack" ]]; then
+        stop_gantt
+    fi
+fi
diff --git a/lib/databases/postgresql b/lib/databases/postgresql
index 60e5a33..c459feb 100644
--- a/lib/databases/postgresql
+++ b/lib/databases/postgresql
@@ -43,7 +43,13 @@
     if is_fedora; then
         PG_HBA=/var/lib/pgsql/data/pg_hba.conf
         PG_CONF=/var/lib/pgsql/data/postgresql.conf
-        sudo [ -e $PG_HBA ] || sudo postgresql-setup initdb
+        if ! sudo [ -e $PG_HBA ]; then
+            if ! [[ $DISTRO =~ (rhel6) ]]; then
+                sudo postgresql-setup initdb
+            else
+                sudo service postgresql initdb
+            fi
+        fi
     elif is_ubuntu; then
         PG_DIR=`find /etc/postgresql -name pg_hba.conf|xargs dirname`
         PG_HBA=$PG_DIR/pg_hba.conf
diff --git a/lib/gantt b/lib/gantt
new file mode 100644
index 0000000..832d759
--- /dev/null
+++ b/lib/gantt
@@ -0,0 +1,96 @@
+# lib/gantt
+# Install and start **Gantt** scheduler service
+
+# Dependencies:
+#
+# - functions
+# - DEST, DATA_DIR, STACK_USER must be defined
+
+# stack.sh
+# ---------
+# - install_gantt
+# - configure_gantt
+# - init_gantt
+# - start_gantt
+# - stop_gantt
+# - cleanup_gantt
+
+# Save trace setting
+XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+# Defaults
+# --------
+
+# set up default directories
+GANTT_DIR=$DEST/gantt
+GANTT_STATE_PATH=${GANTT_STATE_PATH:=$DATA_DIR/gantt}
+GANTT_REPO=${GANTT_REPO:-${GIT_BASE}/openstack/gantt.git}
+GANTT_BRANCH=${GANTT_BRANCH:-master}
+
+GANTTCLIENT_DIR=$DEST/python-ganttclient
+GANTTCLIENT_REPO=${GANTT_REPO:-${GIT_BASE}/openstack/python-ganttclient.git}
+GANTTCLIENT_BRANCH=${GANTT_BRANCH:-master}
+
+# eventually we will have a separate gantt config
+# file but for compatibility reasone stick with
+# nova.conf for now
+GANTT_CONF_DIR=${GANTT_CONF_DIR:-/etc/nova}
+GANTT_CONF=$GANTT_CONF_DIR/nova.conf
+
+# Support entry points installation of console scripts
+GANTT_BIN_DIR=$(get_python_exec_prefix)
+
+
+# Functions
+# ---------
+
+# cleanup_gantt() - Remove residual data files, anything left over from previous
+# runs that a clean run would need to clean up
+function cleanup_gantt() {
+    echo "Cleanup Gantt"
+}
+
+# configure_gantt() - Set config files, create data dirs, etc
+function configure_gantt() {
+    echo "Configure Gantt"
+}
+
+# init_gantt() - Initialize database and volume group
+function init_gantt() {
+    echo "Initialize Gantt"
+}
+
+# install_gantt() - Collect source and prepare
+function install_gantt() {
+    git_clone $GANTT_REPO $GANTT_DIR $GANTT_BRANCH
+    setup_develop $GANTT_DIR
+}
+
+# install_ganttclient() - Collect source and prepare
+function install_ganttclient() {
+    echo "Install Gantt Client"
+#    git_clone $GANTTCLIENT_REPO $GANTTCLIENT_DIR $GANTTCLIENT_BRANCH
+#    setup_develop $GANTTCLIENT_DIR
+}
+
+# start_gantt() - Start running processes, including screen
+function start_gantt() {
+    if is_service_enabled gantt; then
+        screen_it gantt "cd $GANTT_DIR && $GANTT_BIN_DIR/gantt-scheduler --config-file $GANTT_CONF"
+    fi
+}
+
+# stop_gantt() - Stop running processes
+function stop_gantt() {
+    echo "Stop Gantt"
+    screen_stop gantt
+}
+
+# Restore xtrace
+$XTRACE
+
+# Tell emacs to use shell-script-mode
+## Local variables:
+## mode: shell-script
+## End:
diff --git a/lib/keystone b/lib/keystone
index 0850fb2..4f7f68b 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -178,6 +178,7 @@
     # Set the URL advertised in the ``versions`` structure returned by the '/' route
     iniset $KEYSTONE_CONF DEFAULT public_endpoint "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:%(public_port)s/"
     iniset $KEYSTONE_CONF DEFAULT admin_endpoint "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:%(admin_port)s/"
+    iniset $KEYSTONE_CONF DEFAULT admin_bind_host "$KEYSTONE_SERVICE_HOST"
 
     # Register SSL certificates if provided
     if is_ssl_enabled_service key; then
diff --git a/lib/swift b/lib/swift
index afdf995..54d6f1c 100644
--- a/lib/swift
+++ b/lib/swift
@@ -261,6 +261,8 @@
     SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONF_DIR}/proxy-server.conf
     cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER}
 
+    cp ${SWIFT_DIR}/etc/container-sync-realms.conf-sample ${SWIFT_CONF_DIR}/container-sync-realms.conf
+
     iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user
     iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${STACK_USER}
 
diff --git a/lib/tempest b/lib/tempest
index ee99665..06183b1 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -46,8 +46,8 @@
 
 # Set up default directories
 TEMPEST_DIR=$DEST/tempest
-TEMPEST_CONF_DIR=$TEMPEST_DIR/etc
-TEMPEST_CONF=$TEMPEST_CONF_DIR/tempest.conf
+TEMPEST_CONFIG_DIR=${TEMPEST_CONFIG_DIR:-$TEMPEST_DIR/etc}
+TEMPEST_CONFIG=$TEMPEST_CONFIG_DIR/tempest.conf
 TEMPEST_STATE_PATH=${TEMPEST_STATE_PATH:=$DATA_DIR/tempest}
 
 NOVA_SOURCE_DIR=$DEST/nova
@@ -58,6 +58,10 @@
 
 BOTO_MATERIALS_PATH="$FILES/images/s3-materials/cirros-0.3.1"
 
+# Cinder/Volume variables
+TEMPEST_VOLUME_DRIVER=${TEMPEST_VOLUME_DRIVER:-default}
+TEMPEST_VOLUME_VENDOR=${TEMPEST_VOLUME_VENDOR:-"Open Source"}
+TEMPEST_STORAGE_PROTOCOL=${TEMPEST_STORAGE_PROTOCOL:-iSCSI}
 
 # Functions
 # ---------
@@ -83,6 +87,11 @@
     local boto_instance_type="m1.tiny"
     local ssh_connect_method="fixed"
 
+    if [[ ! -d $TEMPEST_CONFIG_DIR ]]; then
+        sudo mkdir -p $TEMPEST_CONFIG_DIR
+    fi
+    sudo chown $STACK_USER $TEMPEST_CONFIG_DIR
+
     # TODO(afazekas):
     # sudo python setup.py deploy
 
@@ -133,7 +142,8 @@
 
     # Create tempest.conf from tempest.conf.sample
     # copy every time, because the image UUIDS are going to change
-    cp $TEMPEST_CONF.sample $TEMPEST_CONF
+    sudo cp $TEMPEST_DIR/etc/tempest.conf.sample $TEMPEST_CONFIG
+    sudo chmod 644 $TEMPEST_CONFIG
 
     password=${ADMIN_PASSWORD:-secrete}
 
@@ -224,121 +234,126 @@
     fi
 
     # Oslo
-    iniset $TEMPEST_CONF DEFAULT lock_path $TEMPEST_STATE_PATH
+    iniset $TEMPEST_CONFIG DEFAULT lock_path $TEMPEST_STATE_PATH
     mkdir -p $TEMPEST_STATE_PATH
-    iniset $TEMPEST_CONF DEFAULT use_stderr False
-    iniset $TEMPEST_CONF DEFAULT log_file tempest.log
-    iniset $TEMPEST_CONF DEFAULT debug True
+    iniset $TEMPEST_CONFIG DEFAULT use_stderr False
+    iniset $TEMPEST_CONFIG DEFAULT log_file tempest.log
+    iniset $TEMPEST_CONFIG DEFAULT debug True
 
     # Timeouts
-    iniset $TEMPEST_CONF compute build_timeout $BUILD_TIMEOUT
-    iniset $TEMPEST_CONF volume build_timeout $BUILD_TIMEOUT
-    iniset $TEMPEST_CONF boto build_timeout $BUILD_TIMEOUT
-    iniset $TEMPEST_CONF compute build_interval $BUILD_INTERVAL
-    iniset $TEMPEST_CONF volume build_interval $BUILD_INTERVAL
-    iniset $TEMPEST_CONF boto build_interval $BUILD_INTERVAL
-    iniset $TEMPEST_CONF boto http_socket_timeout 5
+    iniset $TEMPEST_CONFIG compute build_timeout $BUILD_TIMEOUT
+    iniset $TEMPEST_CONFIG volume build_timeout $BUILD_TIMEOUT
+    iniset $TEMPEST_CONFIG boto build_timeout $BUILD_TIMEOUT
+    iniset $TEMPEST_CONFIG compute build_interval $BUILD_INTERVAL
+    iniset $TEMPEST_CONFIG volume build_interval $BUILD_INTERVAL
+    iniset $TEMPEST_CONFIG boto build_interval $BUILD_INTERVAL
+    iniset $TEMPEST_CONFIG boto http_socket_timeout 5
 
     # Identity
-    iniset $TEMPEST_CONF identity uri "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v2.0/"
-    iniset $TEMPEST_CONF identity password "$password"
-    iniset $TEMPEST_CONF identity alt_username $ALT_USERNAME
-    iniset $TEMPEST_CONF identity alt_password "$password"
-    iniset $TEMPEST_CONF identity alt_tenant_name $ALT_TENANT_NAME
-    iniset $TEMPEST_CONF identity admin_password "$password"
+    iniset $TEMPEST_CONFIG identity uri "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:5000/v2.0/"
+    iniset $TEMPEST_CONFIG identity password "$password"
+    iniset $TEMPEST_CONFIG identity alt_username $ALT_USERNAME
+    iniset $TEMPEST_CONFIG identity alt_password "$password"
+    iniset $TEMPEST_CONFIG identity alt_tenant_name $ALT_TENANT_NAME
+    iniset $TEMPEST_CONFIG identity admin_password "$password"
 
     # Image
     # for the gate we want to be able to override this variable so we aren't
     # doing an HTTP fetch over the wide internet for this test
     if [[ ! -z "$TEMPEST_HTTP_IMAGE" ]]; then
-        iniset $TEMPEST_CONF image http_image $TEMPEST_HTTP_IMAGE
+        iniset $TEMPEST_CONFIG image http_image $TEMPEST_HTTP_IMAGE
     fi
 
     # Compute
-    iniset $TEMPEST_CONF compute change_password_available False
+    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_CONF compute allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
-    iniset $TEMPEST_CONF compute ssh_user ${DEFAULT_INSTANCE_USER:-cirros} # DEPRECATED
-    iniset $TEMPEST_CONF compute network_for_ssh $PRIVATE_NETWORK_NAME
-    iniset $TEMPEST_CONF compute ip_version_for_ssh 4
-    iniset $TEMPEST_CONF compute ssh_timeout $BUILD_TIMEOUT
-    iniset $TEMPEST_CONF compute image_ref $image_uuid
-    iniset $TEMPEST_CONF compute image_ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
-    iniset $TEMPEST_CONF compute image_ref_alt $image_uuid_alt
-    iniset $TEMPEST_CONF compute image_alt_ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
-    iniset $TEMPEST_CONF compute flavor_ref $flavor_ref
-    iniset $TEMPEST_CONF compute flavor_ref_alt $flavor_ref_alt
-    iniset $TEMPEST_CONF compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
-    iniset $TEMPEST_CONF compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
-    iniset $TEMPEST_CONF compute ssh_connect_method $ssh_connect_method
+    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
+    iniset $TEMPEST_CONFIG compute ip_version_for_ssh 4
+    iniset $TEMPEST_CONFIG compute ssh_timeout $BUILD_TIMEOUT
+    iniset $TEMPEST_CONFIG compute image_ref $image_uuid
+    iniset $TEMPEST_CONFIG compute image_ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
+    iniset $TEMPEST_CONFIG compute image_ref_alt $image_uuid_alt
+    iniset $TEMPEST_CONFIG compute image_alt_ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
+    iniset $TEMPEST_CONFIG compute flavor_ref $flavor_ref
+    iniset $TEMPEST_CONFIG compute flavor_ref_alt $flavor_ref_alt
+    iniset $TEMPEST_CONFIG compute live_migration_available ${LIVE_MIGRATION_AVAILABLE:-False}
+    iniset $TEMPEST_CONFIG compute use_block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
+    iniset $TEMPEST_CONFIG compute ssh_connect_method $ssh_connect_method
 
     # Compute admin
-    iniset $TEMPEST_CONF "compute-admin" password "$password" # DEPRECATED
+    iniset $TEMPEST_CONFIG "compute-admin" password "$password" # DEPRECATED
 
-    iniset $TEMPEST_CONF network api_version 2.0
-    iniset $TEMPEST_CONF network tenant_networks_reachable "$tenant_networks_reachable"
-    iniset $TEMPEST_CONF network public_network_id "$public_network_id"
-    iniset $TEMPEST_CONF network public_router_id "$public_router_id"
-    iniset $TEMPEST_CONF network default_network "$FIXED_RANGE"
+    iniset $TEMPEST_CONFIG network api_version 2.0
+    iniset $TEMPEST_CONFIG network tenant_networks_reachable "$tenant_networks_reachable"
+    iniset $TEMPEST_CONFIG network public_network_id "$public_network_id"
+    iniset $TEMPEST_CONFIG network public_router_id "$public_router_id"
+    iniset $TEMPEST_CONFIG network default_network "$FIXED_RANGE"
 
     # boto
-    iniset $TEMPEST_CONF boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
-    iniset $TEMPEST_CONF boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
-    iniset $TEMPEST_CONF boto s3_materials_path "$BOTO_MATERIALS_PATH"
-    iniset $TEMPEST_CONF boto instance_type "$boto_instance_type"
-    iniset $TEMPEST_CONF boto http_socket_timeout 30
-    iniset $TEMPEST_CONF boto ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
+    iniset $TEMPEST_CONFIG boto ec2_url "http://$SERVICE_HOST:8773/services/Cloud"
+    iniset $TEMPEST_CONFIG boto s3_url "http://$SERVICE_HOST:${S3_SERVICE_PORT:-3333}"
+    iniset $TEMPEST_CONFIG boto s3_materials_path "$BOTO_MATERIALS_PATH"
+    iniset $TEMPEST_CONFIG boto instance_type "$boto_instance_type"
+    iniset $TEMPEST_CONFIG boto http_socket_timeout 30
+    iniset $TEMPEST_CONFIG boto ssh_user ${DEFAULT_INSTANCE_USER:-cirros}
 
     # Orchestration test image
     if [[ ! -z "$HEAT_FETCHED_TEST_IMAGE" ]]; then
-        iniset $TEMPEST_CONF orchestration image_ref "$HEAT_FETCHED_TEST_IMAGE"
+        iniset $TEMPEST_CONFIG orchestration image_ref "$HEAT_FETCHED_TEST_IMAGE"
     elif [[ "$HEAT_CREATE_TEST_IMAGE" = "True" ]]; then
         disk_image_create /usr/share/tripleo-image-elements "vm fedora heat-cfntools" "i386" "fedora-vm-heat-cfntools-tempest"
-        iniset $TEMPEST_CONF orchestration image_ref "fedora-vm-heat-cfntools-tempest"
+        iniset $TEMPEST_CONFIG orchestration image_ref "fedora-vm-heat-cfntools-tempest"
     fi
 
     # Scenario
-    iniset $TEMPEST_CONF scenario img_dir "$FILES/images/cirros-0.3.1-x86_64-uec"
+    iniset $TEMPEST_CONFIG 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}
+    iniset $TEMPEST_CONFIG scenario large_ops_number ${TEMPEST_LARGE_OPS_NUMBER:-0}
 
     # Volume
     if is_service_enabled c-bak; then
-        iniset $TEMPEST_CONF volume volume_backup_enabled "True"
+        iniset $TEMPEST_CONFIG volume volume_backup_enabled "True"
     fi
     CINDER_MULTI_LVM_BACKEND=$(trueorfalse False $CINDER_MULTI_LVM_BACKEND)
     if [ $CINDER_MULTI_LVM_BACKEND == "True" ]; then
-        iniset $TEMPEST_CONF volume multi_backend_enabled "True"
-        iniset $TEMPEST_CONF volume backend1_name "LVM_iSCSI"
-        iniset $TEMPEST_CONF volume backend2_name "LVM_iSCSI_2"
+        iniset $TEMPEST_CONFIG volume multi_backend_enabled "True"
+        iniset $TEMPEST_CONFIG volume backend1_name "LVM_iSCSI"
+        iniset $TEMPEST_CONFIG volume backend2_name "LVM_iSCSI_2"
+    fi
+
+    if [ $TEMPEST_VOLUME_DRIVER != "default" ]; then
+        iniset $TEMPEST_CONFIG volume vendor_name $TEMPEST_VOLUME_VENDOR
+        iniset $TEMPEST_CONFIG volume storage_protocol $TEMPEST_STORAGE_PROTOCOL
     fi
 
     # Dashboard
-    iniset $TEMPEST_CONF dashboard dashboard_url "http://$SERVICE_HOST/"
-    iniset $TEMPEST_CONF dashboard login_url "http://$SERVICE_HOST/auth/login/"
+    iniset $TEMPEST_CONFIG dashboard dashboard_url "http://$SERVICE_HOST/"
+    iniset $TEMPEST_CONFIG dashboard login_url "http://$SERVICE_HOST/auth/login/"
 
     # cli
-    iniset $TEMPEST_CONF cli cli_dir $NOVA_BIN_DIR
+    iniset $TEMPEST_CONFIG cli cli_dir $NOVA_BIN_DIR
 
     # Networking
-    iniset $TEMPEST_CONF network-feature-enabled api_extensions "${NETWORK_API_EXTENSIONS:-all}"
+    iniset $TEMPEST_CONFIG network-feature-enabled api_extensions "${NETWORK_API_EXTENSIONS:-all}"
 
     # service_available
     for service in ${TEMPEST_SERVICES//,/ }; do
         if is_service_enabled $service ; then
-            iniset $TEMPEST_CONF service_available $service "True"
+            iniset $TEMPEST_CONFIG service_available $service "True"
         else
-            iniset $TEMPEST_CONF service_available $service "False"
+            iniset $TEMPEST_CONFIG service_available $service "False"
         fi
     done
 
     echo "Created tempest configuration file:"
-    cat $TEMPEST_CONF
+    cat $TEMPEST_CONFIG
 
     # Restore IFS
     IFS=$ifs
diff --git a/tools/sar_filter.py b/tools/sar_filter.py
index ed8c196..24ef0e4 100755
--- a/tools/sar_filter.py
+++ b/tools/sar_filter.py
@@ -25,10 +25,10 @@
 
 
 def parse_line(line):
-    m = re.search('(\d\d:\d\d:\d\d \w\w)(\s+((\S+)\s*)+)', line)
+    m = re.search('(\d\d:\d\d:\d\d( \w\w)?)(\s+((\S+)\s*)+)', line)
     if m:
         date = m.group(1)
-        data = m.group(2).rstrip()
+        data = m.group(3).rstrip()
         return date, data
     else:
         return None, None
@@ -47,6 +47,10 @@
 data_line = ""
 printed_header = False
 current_ts = None
+
+# print out the first sysstat line regardless
+print process.stdout.readline()
+
 while True:
     nextline = process.stdout.readline()
     if nextline == '' and process.poll() is not None: