Merge "Add keystone middleware to devstack"
diff --git a/clean.sh b/clean.sh
index 7851da3..e2374e7 100755
--- a/clean.sh
+++ b/clean.sh
@@ -120,9 +120,9 @@
 
 # Clean up files
 
-FILES_TO_CLEAN=".localrc.auto docs-files docs/ shocco/ stack-screenrc test*.conf* test.ini*"
+FILES_TO_CLEAN=".localrc.auto docs/files docs/html shocco/ stack-screenrc test*.conf* test.ini*"
 FILES_TO_CLEAN+=".stackenv .prereqs"
 
 for file in $FILES_TO_CLEAN; do
-    rm -f $TOP_DIR/$file
+    rm -rf $TOP_DIR/$file
 done
diff --git a/files/apts/keystone b/files/apts/keystone
index 57fde80..b7218b7 100644
--- a/files/apts/keystone
+++ b/files/apts/keystone
@@ -11,3 +11,4 @@
 python-routes
 libldap2-dev
 libsasl2-dev
+libkrb5-dev
diff --git a/files/apts/opendaylight b/files/apts/opendaylight
deleted file mode 100644
index ec3cc9d..0000000
--- a/files/apts/opendaylight
+++ /dev/null
@@ -1,2 +0,0 @@
-openvswitch-datapath-dkms # NOPRIME
-openvswitch-switch # NOPRIME
diff --git a/files/apts/openvswitch b/files/apts/openvswitch
new file mode 100644
index 0000000..4c0af4a
--- /dev/null
+++ b/files/apts/openvswitch
@@ -0,0 +1,3 @@
+fakeroot
+make
+openvswitch-switch
diff --git a/files/apts/tls-proxy b/files/apts/tls-proxy
index 8fca42d..dce9c07 100644
--- a/files/apts/tls-proxy
+++ b/files/apts/tls-proxy
@@ -1 +1 @@
-stud # only available in dist:precise
+stud
diff --git a/files/rpms-suse/opendaylight b/files/rpms-suse/opendaylight
deleted file mode 100644
index f7fafff..0000000
--- a/files/rpms-suse/opendaylight
+++ /dev/null
@@ -1,3 +0,0 @@
-openvswitch # NOPRIME
-openvswitch-switch # NOPRIME
-
diff --git a/files/rpms-suse/openvswitch b/files/rpms-suse/openvswitch
new file mode 100644
index 0000000..edfb4d2
--- /dev/null
+++ b/files/rpms-suse/openvswitch
@@ -0,0 +1,3 @@
+openvswitch
+openvswitch-switch
+
diff --git a/files/rpms/opendaylight b/files/rpms/opendaylight
deleted file mode 100644
index 98aaaf4..0000000
--- a/files/rpms/opendaylight
+++ /dev/null
@@ -1 +0,0 @@
-openvswitch # NOPRIME
diff --git a/files/rpms/openvswitch b/files/rpms/openvswitch
new file mode 100644
index 0000000..64796f7
--- /dev/null
+++ b/files/rpms/openvswitch
@@ -0,0 +1 @@
+openvswitch
diff --git a/lib/ceilometer b/lib/ceilometer
index 286f199..eef6740 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -163,6 +163,7 @@
     iniset $CEILOMETER_CONF service_credentials os_username ceilometer
     iniset $CEILOMETER_CONF service_credentials os_password $SERVICE_PASSWORD
     iniset $CEILOMETER_CONF service_credentials os_tenant_name $SERVICE_TENANT_NAME
+    iniset $CEILOMETER_CONF service_credentials os_auth_url $OS_AUTH_URL
 
     iniset $CEILOMETER_CONF keystone_authtoken identity_uri $KEYSTONE_AUTH_URI
     iniset $CEILOMETER_CONF keystone_authtoken admin_user ceilometer
diff --git a/lib/cinder b/lib/cinder
index 40a8418..6f2d7c6 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -269,6 +269,10 @@
     iniset $CINDER_CONF DEFAULT state_path $CINDER_STATE_PATH
     iniset $CINDER_CONF DEFAULT lock_path $CINDER_STATE_PATH
     iniset $CINDER_CONF DEFAULT periodic_interval $CINDER_PERIODIC_INTERVAL
+    # NOTE(thingee): Cinder V1 API is deprecated and defaults to off as of
+    # Juno. Keep it enabled so we can continue testing while it's still
+    # supported.
+    iniset $CINDER_CONF DEFAULT enable_v1_api true
 
     if is_service_enabled swift; then
         iniset $CINDER_CONF DEFAULT backup_swift_url "http://$SERVICE_HOST:8080/v1/AUTH_"
diff --git a/lib/databases/postgresql b/lib/databases/postgresql
index 96a5947..b39984c 100644
--- a/lib/databases/postgresql
+++ b/lib/databases/postgresql
@@ -23,7 +23,7 @@
         # Get ruthless with mysql
         apt_get purge -y postgresql*
         return
-    elif is_fedora; then
+    elif is_fedora || is_suse; then
         uninstall_package postgresql-server
     else
         return
diff --git a/lib/horizon b/lib/horizon
index bf476c6..a65b243 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -159,7 +159,7 @@
 # install_django_openstack_auth() - Collect source and prepare
 function install_django_openstack_auth {
     git_clone $HORIZONAUTH_REPO $HORIZONAUTH_DIR $HORIZONAUTH_BRANCH
-    setup_develop $HORIZONAUTH_DIR
+    setup_install $HORIZONAUTH_DIR
 }
 
 # install_horizon() - Collect source and prepare
diff --git a/lib/keystone b/lib/keystone
index e30d410..8a4683f 100644
--- a/lib/keystone
+++ b/lib/keystone
@@ -486,7 +486,10 @@
     fi
 
     echo "Waiting for keystone to start..."
-    if ! timeout $SERVICE_TIMEOUT sh -c "while ! curl --noproxy '*' -k -s $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$service_port/v$IDENTITY_API_VERSION/ >/dev/null; do sleep 1; done"; then
+    # Check that the keystone service is running. Even if the tls tunnel
+    # should be enabled, make sure the internal port is checked using
+    # unencryted traffic at this point.
+    if ! timeout $SERVICE_TIMEOUT sh -c "while ! curl --noproxy '*' -k -s http://$KEYSTONE_SERVICE_HOST:$service_port/v$IDENTITY_API_VERSION/ >/dev/null; do sleep 1; done"; then
         die $LINENO "keystone did not start"
     fi
 
diff --git a/lib/neutron_plugins/ovs_base b/lib/neutron_plugins/ovs_base
index e13cbb1..26c5489 100644
--- a/lib/neutron_plugins/ovs_base
+++ b/lib/neutron_plugins/ovs_base
@@ -32,26 +32,24 @@
     done
 }
 
+function _neutron_ovs_base_install_ubuntu_dkms {
+    # install Dynamic Kernel Module Support packages if needed
+    local kernel_version=$(uname -r)
+    local kernel_major_minor=`echo $kernel_version | cut -d. -f1-2`
+    # From kernel 3.13 on, openvswitch-datapath-dkms is not needed
+    if [ `vercmp_numbers "$kernel_major_minor" "3.13"` -lt "0" ]; then
+        install_package "dkms openvswitch-datapath-dkms linux-headers-$kernel_version"
+    fi
+}
+
 function _neutron_ovs_base_install_agent_packages {
-    local kernel_version
     # Install deps
-    # FIXME add to ``files/apts/neutron``, but don't install if not needed!
+    install_package $(get_packages "openvswitch")
     if is_ubuntu; then
-        kernel_version=`cat /proc/version | cut -d " " -f3`
-        ovs_packages="make fakeroot dkms openvswitch-switch"
-        # From kernel 3.13 on, openvswitch-datapath-dkms is not needed
-        kernel_major_minor=`echo $kernel_version | cut -d. -f1-2`
-        if [ `vercmp_numbers "$kernel_major_minor" "3.13"` -lt "0" ]; then
-            ovs_packages="$ovs_packages openvswitch-datapath-dkms"
-        fi
-        ovs_packages="$ovs_packages linux-headers-$kernel_version"
-        install_package $ovs_packages
+        _neutron_ovs_base_install_ubuntu_dkms
     elif is_fedora; then
-        install_package openvswitch
-        # Ensure that the service is started
         restart_service openvswitch
     elif is_suse; then
-        install_package openvswitch-switch
         restart_service openvswitch-switch
     fi
 }
diff --git a/lib/opendaylight b/lib/opendaylight
index 0ac7f2b..33b3f0a 100644
--- a/lib/opendaylight
+++ b/lib/opendaylight
@@ -122,22 +122,10 @@
     unzip -u $ODL_PKG
 }
 
-# install_opendaylight-compute - Make sure OVS is install
+# install_opendaylight-compute - Make sure OVS is installed
 function install_opendaylight-compute {
-    local kernel_version
-    # Install deps
-    # FIXME add to ``files/apts/neutron``, but don't install if not needed!
-    if is_ubuntu; then
-        kernel_version=`cat /proc/version | cut -d " " -f3`
-        install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
-    elif is_fedora; then
-        install_package openvswitch
-        # Ensure that the service is started
-        restart_service openvswitch
-    elif is_suse; then
-        install_package openvswitch-switch
-        restart_service openvswitch-switch
-    fi
+    # packages are the same as for Neutron OVS agent
+    _neutron_ovs_base_install_agent_packages
 }
 
 # start_opendaylight() - Start running processes, including screen
diff --git a/lib/tls b/lib/tls
index 88e5f60..02906b7 100644
--- a/lib/tls
+++ b/lib/tls
@@ -18,9 +18,9 @@
 # - configure_proxy
 # - start_tls_proxy
 
-# - make_root_ca
-# - make_int_ca
-# - new_cert $INT_CA_DIR int-server "abc"
+# - make_root_CA
+# - make_int_CA
+# - make_cert ca-dir cert-name "common-name" ["alt-name" ...]
 # - start_tls_proxy HOST_IP 5000 localhost 5000
 # - ensure_certificates
 # - is_ssl_enabled_service
diff --git a/lib/trove b/lib/trove
index e467c90..401ab78 100644
--- a/lib/trove
+++ b/lib/trove
@@ -33,6 +33,10 @@
 TROVE_CONF_DIR=/etc/trove
 TROVE_LOCAL_CONF_DIR=$TROVE_DIR/etc/trove
 TROVE_AUTH_CACHE_DIR=${TROVE_AUTH_CACHE_DIR:-/var/cache/trove}
+TROVE_DATASTORE_TYPE=${TROVE_DATASTORE_TYPE:-"mysql"}
+TROVE_DATASTORE_VERSION=${TROVE_DATASTORE_VERSION:-"5.5"}
+TROVE_DATASTORE_PACKAGE=${TROVE_DATASTORE_PACKAGE:-"mysql-server-5.5"}
+TROVE_GUEST_IMAGE_URL=${TROVE_GUEST_IMAGE_URL:-"http://tarballs.openstack.org/trove/images/ubuntu_mysql.qcow2/ubuntu_mysql.qcow2"}
 
 # Support entry points installation of console scripts
 if [[ -d $TROVE_DIR/bin ]]; then
@@ -148,12 +152,8 @@
 
     iniset $TROVE_CONF_DIR/trove.conf DEFAULT rabbit_password $RABBIT_PASSWORD
     iniset $TROVE_CONF_DIR/trove.conf DEFAULT sql_connection `database_connection_url trove`
-
-    iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT rabbit_password $RABBIT_PASSWORD
-    sed -i "s/localhost/$TROVE_HOST_GATEWAY/g" $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample
-
+    iniset $TROVE_CONF_DIR/trove.conf DEFAULT default_datastore $TROVE_DATASTORE_TYPE
     setup_trove_logging $TROVE_CONF_DIR/trove.conf
-    setup_trove_logging $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample
 
     # (Re)create trove taskmanager conf file if needed
     if is_service_enabled tr-tmgr; then
@@ -180,6 +180,18 @@
         iniset $TROVE_CONF_DIR/trove-conductor.conf DEFAULT control_exchange trove
         setup_trove_logging $TROVE_CONF_DIR/trove-conductor.conf
     fi
+
+    # Set up Guest Agent conf
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT rabbit_host $TROVE_HOST_GATEWAY
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT rabbit_password $RABBIT_PASSWORD
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT nova_proxy_admin_user radmin
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT nova_proxy_admin_tenant_name trove
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT nova_proxy_admin_pass $RADMIN_USER_PASS
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT control_exchange trove
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT log_dir /tmp/
+    iniset $TROVE_CONF_DIR/trove-guestagent.conf DEFAULT log_file trove-guestagent.log
+    setup_trove_logging $TROVE_CONF_DIR/trove-guestagent.conf
 }
 
 # install_troveclient() - Collect source and prepare
@@ -194,11 +206,22 @@
 
 # init_trove() - Initializes Trove Database as a Service
 function init_trove {
-    #(Re)Create trove db
+    # (Re)Create trove db
     recreate_database trove utf8
 
-    #Initialize the trove database
+    # Initialize the trove database
     $TROVE_BIN_DIR/trove-manage db_sync
+
+    # Upload the trove-guest image to glance
+    TROVE_GUEST_IMAGE_ID=$(upload_image $TROVE_GUEST_IMAGE_URL $TOKEN | grep ' id ' | get_field 2)
+
+    # Initialize appropriate datastores / datastore versions
+    $TROVE_BIN_DIR/trove-manage datastore_update "$TROVE_DATASTORE_TYPE" ""
+    $TROVE_BIN_DIR/trove-manage datastore_version_update "$TROVE_DATASTORE_TYPE" "$TROVE_DATASTORE_VERSION" "$TROVE_DATASTORE_TYPE" \
+        "$TROVE_GUEST_IMAGE_ID" "$TROVE_DATASTORE_PACKAGE" 1
+    $TROVE_BIN_DIR/trove-manage datastore_version_update "$TROVE_DATASTORE_TYPE" "inactive_version" "inactive_manager" "$TROVE_GUEST_IMAGE_ID" "" 0
+    $TROVE_BIN_DIR/trove-manage datastore_update "$TROVE_DATASTORE_TYPE" "$TROVE_DATASTORE_VERSION"
+    $TROVE_BIN_DIR/trove-manage datastore_update "Inactive_Datastore" ""
 }
 
 # start_trove() - Start running processes, including screen
diff --git a/stack.sh b/stack.sh
index 5dfe6eb..e58436d 100755
--- a/stack.sh
+++ b/stack.sh
@@ -142,7 +142,7 @@
 
 # Warn users who aren't on an explicitly supported distro, but allow them to
 # override check and attempt installation with ``FORCE=yes ./stack``
-if [[ ! ${DISTRO} =~ (precise|saucy|trusty|7.0|wheezy|sid|testing|jessie|f19|f20|rhel6) ]]; then
+if [[ ! ${DISTRO} =~ (precise|saucy|trusty|7.0|wheezy|sid|testing|jessie|f19|f20|rhel6|rhel7) ]]; then
     echo "WARNING: this script has not been tested on $DISTRO"
     if [[ "$FORCE" != "yes" ]]; then
         die $LINENO "If you wish to run this script anyway run with FORCE=yes"
diff --git a/stackrc b/stackrc
index 52879b0..ea61a37 100644
--- a/stackrc
+++ b/stackrc
@@ -370,7 +370,7 @@
 PRECACHE_IMAGES=$(trueorfalse False $PRECACHE_IMAGES)
 if [[ "$PRECACHE_IMAGES" == "True" ]]; then
     # staging in update for nodepool
-    IMAGE_URLS+=",https://dl.fedoraproject.org/pub/fedora/linux/updates/20/Images/x86_64/Fedora-x86_64-20-20140407-sda.qcow2"
+    IMAGE_URLS+=",http://dl.fedoraproject.org/pub/alt/openstack/20/x86_64/Fedora-x86_64-20-20140618-sda.qcow2"
 fi
 
 # 10Gb default volume backing file size