Added Trove (Database as a Service).

- Added changes to stackrc for the Trove Repos.
- Added support to devstack for "install", "configure",
  "init", and "run"

implements blueprint:trove-devstack-integration

Change-Id: Ib3f6daad33e629f764a174b80762c808ce8588e2
This commit is contained in:
Nikhil Manchanda 2012-12-03 18:15:09 -07:00 committed by Michael Basnight
parent 58afc72983
commit 0cccad43aa
9 changed files with 257 additions and 2 deletions

45
exercises/trove.sh Executable file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env bash
# **trove.sh**
# Sanity check that trove started if enabled
echo "*********************************************************************"
echo "Begin DevStack Exercise: $0"
echo "*********************************************************************"
# This script exits on an error so that errors don't compound and you see
# only the first error that occurred.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
# Keep track of the current directory
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
# Import common functions
source $TOP_DIR/functions
# Import configuration
source $TOP_DIR/openrc
# Import exercise configuration
source $TOP_DIR/exerciserc
is_service_enabled trove || exit 55
# can we get a list versions
curl http://$SERVICE_HOST:8779/ 2>/dev/null | grep -q 'versions' || die $LINENO "Trove API not functioning!"
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"
echo "*********************************************************************"

1
files/apts/trove Normal file
View File

@ -0,0 +1 @@
libxslt1-dev # testonly

1
files/rpms-suse/trove Normal file
View File

@ -0,0 +1 @@
libxslt1-dev # testonly

1
files/rpms/trove Normal file
View File

@ -0,0 +1 @@
libxslt1-dev # testonly

View File

@ -779,6 +779,7 @@ function is_running() {
# **glance** returns true if any service enabled start with **g-** # **glance** returns true if any service enabled start with **g-**
# **neutron** returns true if any service enabled start with **q-** # **neutron** returns true if any service enabled start with **q-**
# **swift** returns true if any service enabled start with **s-** # **swift** returns true if any service enabled start with **s-**
# **trove** returns true if any service enabled start with **tr-**
# For backward compatibility if we have **swift** in ENABLED_SERVICES all the # For backward compatibility if we have **swift** in ENABLED_SERVICES all the
# **s-** services will be enabled. This will be deprecated in the future. # **s-** services will be enabled. This will be deprecated in the future.
# #
@ -798,6 +799,7 @@ function is_service_enabled() {
[[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0 [[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0
[[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0 [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
[[ ${service} == "neutron" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0 [[ ${service} == "neutron" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
[[ ${service} == "trove" && ${ENABLED_SERVICES} =~ "tr-" ]] && return 0
[[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && return 0 [[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && return 0
[[ ${service} == s-* && ${ENABLED_SERVICES} =~ "swift" ]] && return 0 [[ ${service} == s-* && ${ENABLED_SERVICES} =~ "swift" ]] && return 0
done done

170
lib/trove Normal file
View File

@ -0,0 +1,170 @@
# lib/trove
# Functions to control the configuration and operation of the **Trove** service
# Dependencies:
# ``functions`` file
# ``DEST``, ``STACK_USER`` must be defined
# ``SERVICE_{HOST|PROTOCOL|TOKEN}`` must be defined
# ``stack.sh`` calls the entry points in this order:
#
# install_trove
# configure_trove
# init_trove
# start_trove
# stop_trove
# cleanup_trove
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set +o xtrace
# Defaults
# --------
NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
# Set up default configuration
TROVE_DIR=$DEST/trove
TROVECLIENT_DIR=$DEST/python-troveclient
TROVE_CONF_DIR=/etc/trove
TROVE_LOCAL_CONF_DIR=$TROVE_DIR/etc/trove
TROVE_AUTH_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT//v$IDENTITY_API_VERSION
TROVE_AUTH_CACHE_DIR=${TROVE_AUTH_CACHE_DIR:-/var/cache/trove}
TROVE_BIN_DIR=/usr/local/bin
# create_trove_accounts() - Set up common required trove accounts
# Tenant User Roles
# ------------------------------------------------------------------
# service trove admin # if enabled
create_trove_accounts() {
# Trove
SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
SERVICE_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
if [[ "$ENABLED_SERVICES" =~ "trove" ]]; then
TROVE_USER=$(keystone user-create --name=trove \
--pass="$SERVICE_PASSWORD" \
--tenant_id $SERVICE_TENANT \
--email=trove@example.com \
| grep " id " | get_field 2)
keystone user-role-add --tenant-id $SERVICE_TENANT \
--user-id $TROVE_USER \
--role-id $SERVICE_ROLE
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
TROVE_SERVICE=$(keystone service-create \
--name=trove \
--type=database \
--description="Trove Service" \
| grep " id " | get_field 2)
keystone endpoint-create \
--region RegionOne \
--service_id $TROVE_SERVICE \
--publicurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
--adminurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
--internalurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s"
fi
fi
}
# stack.sh entry points
# ---------------------
# cleanup_trove() - Remove residual data files, anything left over from previous
# runs that a clean run would need to clean up
function cleanup_trove() {
#Clean up dirs
rm -fr $TROVE_AUTH_CACHE_DIR/*
rm -fr $TROVE_CONF_DIR/*
}
# configure_troveclient() - Set config files, create data dirs, etc
function configure_troveclient() {
setup_develop $TROVECLIENT_DIR
}
# configure_trove() - Set config files, create data dirs, etc
function configure_trove() {
setup_develop $TROVE_DIR
# Create the trove conf dir and cache dirs if they don't exist
sudo mkdir -p ${TROVE_CONF_DIR}
sudo mkdir -p ${TROVE_AUTH_CACHE_DIR}
sudo chown -R $STACK_USER: ${TROVE_CONF_DIR}
sudo chown -R $STACK_USER: ${TROVE_AUTH_CACHE_DIR}
# Copy api-paste file over to the trove conf dir and configure it
cp $TROVE_LOCAL_CONF_DIR/api-paste.ini $TROVE_CONF_DIR/api-paste.ini
TROVE_API_PASTE_INI=$TROVE_CONF_DIR/api-paste.ini
iniset $TROVE_API_PASTE_INI filter:tokenauth auth_host $KEYSTONE_AUTH_HOST
iniset $TROVE_API_PASTE_INI filter:tokenauth auth_port $KEYSTONE_AUTH_PORT
iniset $TROVE_API_PASTE_INI filter:tokenauth auth_protocol $KEYSTONE_AUTH_PROTOCOL
iniset $TROVE_API_PASTE_INI filter:tokenauth admin_tenant_name $SERVICE_TENANT_NAME
iniset $TROVE_API_PASTE_INI filter:tokenauth admin_user trove
iniset $TROVE_API_PASTE_INI filter:tokenauth admin_password $SERVICE_PASSWORD
iniset $TROVE_API_PASTE_INI filter:tokenauth signing_dir $TROVE_AUTH_CACHE_DIR
# (Re)create trove conf files
rm -f $TROVE_CONF_DIR/trove.conf
rm -f $TROVE_CONF_DIR/trove-taskmanager.conf
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_CONF_DIR/trove.conf DEFAULT add_addresses True
iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT rabbit_password $RABBIT_PASSWORD
iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT sql_connection `database_connection_url trove`
sed -i "s/localhost/$NETWORK_GATEWAY/g" $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample
# (Re)create trove taskmanager conf file if needed
if is_service_enabled tr-tmgr; then
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT rabbit_password $RABBIT_PASSWORD
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT sql_connection `database_connection_url trove`
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT taskmanager_manager trove.taskmanager.manager.Manager
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_user radmin
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_tenant_name trove
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_pass $RADMIN_USER_PASS
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
fi
}
# install_troveclient() - Collect source and prepare
function install_troveclient() {
git_clone $TROVECLIENT_REPO $TROVECLIENT_DIR $TROVECLIENT_BRANCH
}
# install_trove() - Collect source and prepare
function install_trove() {
git_clone $TROVE_REPO $TROVE_DIR $TROVE_BRANCH
}
# init_trove() - Initializes Trove Database as a Service
function init_trove() {
#(Re)Create trove db
recreate_database trove utf8
#Initialize the trove database
$TROVE_DIR/bin/trove-manage db_sync
}
# start_trove() - Start running processes, including screen
function start_trove() {
screen_it tr-api "cd $TROVE_DIR; bin/trove-api --config-file=$TROVE_CONF_DIR/trove.conf --debug 2>&1"
screen_it tr-tmgr "cd $TROVE_DIR; bin/trove-taskmanager --config-file=$TROVE_CONF_DIR/trove-taskmanager.conf --debug 2>&1"
}
# stop_trove() - Stop running processes
function stop_trove() {
# Kill the trove screen windows
for serv in tr-api tr-tmgr; do
screen -S $SCREEN_NAME -p $serv -X kill
done
}
# Restore xtrace
$XTRACE
# Local variables:
# mode: shell-script
# End:

View File

@ -2,8 +2,8 @@
# ``stack.sh`` is an opinionated OpenStack developer installation. It # ``stack.sh`` is an opinionated OpenStack developer installation. It
# installs and configures various combinations of **Ceilometer**, **Cinder**, # installs and configures various combinations of **Ceilometer**, **Cinder**,
# **Glance**, **Heat**, **Horizon**, **Keystone**, **Nova**, **Neutron** # **Glance**, **Heat**, **Horizon**, **Keystone**, **Nova**, **Neutron**,
# and **Swift**. # **Swift**, and **Trove**
# This script allows you to specify configuration options of what git # This script allows you to specify configuration options of what git
# repositories to use, enabled services, network configuration and various # repositories to use, enabled services, network configuration and various
@ -319,6 +319,7 @@ source $TOP_DIR/lib/neutron
source $TOP_DIR/lib/baremetal source $TOP_DIR/lib/baremetal
source $TOP_DIR/lib/ldap source $TOP_DIR/lib/ldap
source $TOP_DIR/lib/ironic source $TOP_DIR/lib/ironic
source $TOP_DIR/lib/trove
# Look for Nova hypervisor plugin # Look for Nova hypervisor plugin
NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins
@ -720,6 +721,12 @@ if is_service_enabled heat; then
configure_heat configure_heat
fi fi
if is_service_enabled trove; then
install_trove
install_troveclient
cleanup_trove
fi
if is_service_enabled tls-proxy; then if is_service_enabled tls-proxy; then
configure_CA configure_CA
init_CA init_CA
@ -860,6 +867,10 @@ if is_service_enabled key; then
create_cinder_accounts create_cinder_accounts
create_neutron_accounts create_neutron_accounts
if is_service_enabled trove; then
create_trove_accounts
fi
if is_service_enabled swift || is_service_enabled s-proxy; then if is_service_enabled swift || is_service_enabled s-proxy; then
create_swift_accounts create_swift_accounts
fi fi
@ -1236,6 +1247,18 @@ if is_service_enabled heat; then
start_heat start_heat
fi fi
# Configure and launch the trove service api, and taskmanager
if is_service_enabled trove; then
# Initialize trove
echo_summary "Configuring Trove"
configure_troveclient
configure_trove
init_trove
# Start the trove API and trove taskmgr components
echo_summary "Starting Trove"
start_trove
fi
# Create account rc files # Create account rc files
# ======================= # =======================

View File

@ -181,6 +181,13 @@ RYU_BRANCH=${RYU_BRANCH:-master}
SPICE_REPO=${SPICE_REPO:-http://anongit.freedesktop.org/git/spice/spice-html5.git} SPICE_REPO=${SPICE_REPO:-http://anongit.freedesktop.org/git/spice/spice-html5.git}
SPICE_BRANCH=${SPICE_BRANCH:-master} SPICE_BRANCH=${SPICE_BRANCH:-master}
# trove service
TROVE_REPO=${TROVE_REPO:-${GIT_BASE}/openstack/trove.git}
TROVE_BRANCH=${TROVE_BRANCH:-master}
# trove client library test
TROVECLIENT_REPO=${TROVECLIENT_REPO:-${GIT_BASE}/openstack/python-troveclient.git}
TROVECLIENT_BRANCH=${TROVECLIENT_BRANCH:-master}
# Nova hypervisor configuration. We default to libvirt with **kvm** but will # Nova hypervisor configuration. We default to libvirt with **kvm** but will
# drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can # drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can

View File

@ -34,6 +34,7 @@ source $TOP_DIR/lib/horizon
source $TOP_DIR/lib/swift source $TOP_DIR/lib/swift
source $TOP_DIR/lib/neutron source $TOP_DIR/lib/neutron
source $TOP_DIR/lib/ironic source $TOP_DIR/lib/ironic
source $TOP_DIR/lib/trove
# Determine what system we are running on. This provides ``os_VENDOR``, # Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
@ -130,4 +131,8 @@ if is_service_enabled neutron; then
cleanup_neutron cleanup_neutron
fi fi
if is_service_enabled trove; then
cleanup_trove
fi
cleanup_tmp cleanup_tmp