Skip to content

Commit 0cccad4

Browse files
SlickNikhub-cap
authored andcommitted
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
1 parent 58afc72 commit 0cccad4

9 files changed

Lines changed: 257 additions & 2 deletions

File tree

exercises/trove.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
# **trove.sh**
4+
5+
# Sanity check that trove started if enabled
6+
7+
echo "*********************************************************************"
8+
echo "Begin DevStack Exercise: $0"
9+
echo "*********************************************************************"
10+
11+
# This script exits on an error so that errors don't compound and you see
12+
# only the first error that occurred.
13+
set -o errexit
14+
15+
# Print the commands being run so that we can see the command that triggers
16+
# an error. It is also useful for following allowing as the install occurs.
17+
set -o xtrace
18+
19+
20+
# Settings
21+
# ========
22+
23+
# Keep track of the current directory
24+
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
25+
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
26+
27+
# Import common functions
28+
source $TOP_DIR/functions
29+
30+
# Import configuration
31+
source $TOP_DIR/openrc
32+
33+
# Import exercise configuration
34+
source $TOP_DIR/exerciserc
35+
36+
is_service_enabled trove || exit 55
37+
38+
# can we get a list versions
39+
curl http://$SERVICE_HOST:8779/ 2>/dev/null | grep -q 'versions' || die $LINENO "Trove API not functioning!"
40+
41+
set +o xtrace
42+
echo "*********************************************************************"
43+
echo "SUCCESS: End DevStack Exercise: $0"
44+
echo "*********************************************************************"
45+

files/apts/trove

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libxslt1-dev # testonly

files/rpms-suse/trove

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libxslt1-dev # testonly

files/rpms/trove

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libxslt1-dev # testonly

functions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ function is_running() {
779779
# **glance** returns true if any service enabled start with **g-**
780780
# **neutron** returns true if any service enabled start with **q-**
781781
# **swift** returns true if any service enabled start with **s-**
782+
# **trove** returns true if any service enabled start with **tr-**
782783
# For backward compatibility if we have **swift** in ENABLED_SERVICES all the
783784
# **s-** services will be enabled. This will be deprecated in the future.
784785
#
@@ -798,6 +799,7 @@ function is_service_enabled() {
798799
[[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0
799800
[[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
800801
[[ ${service} == "neutron" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
802+
[[ ${service} == "trove" && ${ENABLED_SERVICES} =~ "tr-" ]] && return 0
801803
[[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && return 0
802804
[[ ${service} == s-* && ${ENABLED_SERVICES} =~ "swift" ]] && return 0
803805
done

lib/trove

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# lib/trove
2+
# Functions to control the configuration and operation of the **Trove** service
3+
4+
# Dependencies:
5+
# ``functions`` file
6+
# ``DEST``, ``STACK_USER`` must be defined
7+
# ``SERVICE_{HOST|PROTOCOL|TOKEN}`` must be defined
8+
9+
# ``stack.sh`` calls the entry points in this order:
10+
#
11+
# install_trove
12+
# configure_trove
13+
# init_trove
14+
# start_trove
15+
# stop_trove
16+
# cleanup_trove
17+
18+
# Save trace setting
19+
XTRACE=$(set +o | grep xtrace)
20+
set +o xtrace
21+
22+
# Defaults
23+
# --------
24+
25+
NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
26+
27+
# Set up default configuration
28+
TROVE_DIR=$DEST/trove
29+
TROVECLIENT_DIR=$DEST/python-troveclient
30+
TROVE_CONF_DIR=/etc/trove
31+
TROVE_LOCAL_CONF_DIR=$TROVE_DIR/etc/trove
32+
TROVE_AUTH_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT//v$IDENTITY_API_VERSION
33+
TROVE_AUTH_CACHE_DIR=${TROVE_AUTH_CACHE_DIR:-/var/cache/trove}
34+
TROVE_BIN_DIR=/usr/local/bin
35+
36+
# create_trove_accounts() - Set up common required trove accounts
37+
38+
# Tenant User Roles
39+
# ------------------------------------------------------------------
40+
# service trove admin # if enabled
41+
42+
create_trove_accounts() {
43+
# Trove
44+
SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
45+
SERVICE_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
46+
47+
if [[ "$ENABLED_SERVICES" =~ "trove" ]]; then
48+
TROVE_USER=$(keystone user-create --name=trove \
49+
--pass="$SERVICE_PASSWORD" \
50+
--tenant_id $SERVICE_TENANT \
51+
52+
| grep " id " | get_field 2)
53+
keystone user-role-add --tenant-id $SERVICE_TENANT \
54+
--user-id $TROVE_USER \
55+
--role-id $SERVICE_ROLE
56+
if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
57+
TROVE_SERVICE=$(keystone service-create \
58+
--name=trove \
59+
--type=database \
60+
--description="Trove Service" \
61+
| grep " id " | get_field 2)
62+
keystone endpoint-create \
63+
--region RegionOne \
64+
--service_id $TROVE_SERVICE \
65+
--publicurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
66+
--adminurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
67+
--internalurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s"
68+
fi
69+
fi
70+
}
71+
72+
# stack.sh entry points
73+
# ---------------------
74+
75+
# cleanup_trove() - Remove residual data files, anything left over from previous
76+
# runs that a clean run would need to clean up
77+
function cleanup_trove() {
78+
#Clean up dirs
79+
rm -fr $TROVE_AUTH_CACHE_DIR/*
80+
rm -fr $TROVE_CONF_DIR/*
81+
}
82+
83+
# configure_troveclient() - Set config files, create data dirs, etc
84+
function configure_troveclient() {
85+
setup_develop $TROVECLIENT_DIR
86+
}
87+
88+
# configure_trove() - Set config files, create data dirs, etc
89+
function configure_trove() {
90+
setup_develop $TROVE_DIR
91+
92+
# Create the trove conf dir and cache dirs if they don't exist
93+
sudo mkdir -p ${TROVE_CONF_DIR}
94+
sudo mkdir -p ${TROVE_AUTH_CACHE_DIR}
95+
sudo chown -R $STACK_USER: ${TROVE_CONF_DIR}
96+
sudo chown -R $STACK_USER: ${TROVE_AUTH_CACHE_DIR}
97+
98+
# Copy api-paste file over to the trove conf dir and configure it
99+
cp $TROVE_LOCAL_CONF_DIR/api-paste.ini $TROVE_CONF_DIR/api-paste.ini
100+
TROVE_API_PASTE_INI=$TROVE_CONF_DIR/api-paste.ini
101+
iniset $TROVE_API_PASTE_INI filter:tokenauth auth_host $KEYSTONE_AUTH_HOST
102+
iniset $TROVE_API_PASTE_INI filter:tokenauth auth_port $KEYSTONE_AUTH_PORT
103+
iniset $TROVE_API_PASTE_INI filter:tokenauth auth_protocol $KEYSTONE_AUTH_PROTOCOL
104+
iniset $TROVE_API_PASTE_INI filter:tokenauth admin_tenant_name $SERVICE_TENANT_NAME
105+
iniset $TROVE_API_PASTE_INI filter:tokenauth admin_user trove
106+
iniset $TROVE_API_PASTE_INI filter:tokenauth admin_password $SERVICE_PASSWORD
107+
iniset $TROVE_API_PASTE_INI filter:tokenauth signing_dir $TROVE_AUTH_CACHE_DIR
108+
109+
# (Re)create trove conf files
110+
rm -f $TROVE_CONF_DIR/trove.conf
111+
rm -f $TROVE_CONF_DIR/trove-taskmanager.conf
112+
iniset $TROVE_CONF_DIR/trove.conf DEFAULT rabbit_password $RABBIT_PASSWORD
113+
iniset $TROVE_CONF_DIR/trove.conf DEFAULT sql_connection `database_connection_url trove`
114+
iniset $TROVE_CONF_DIR/trove.conf DEFAULT add_addresses True
115+
116+
iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT rabbit_password $RABBIT_PASSWORD
117+
iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT sql_connection `database_connection_url trove`
118+
sed -i "s/localhost/$NETWORK_GATEWAY/g" $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample
119+
120+
# (Re)create trove taskmanager conf file if needed
121+
if is_service_enabled tr-tmgr; then
122+
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT rabbit_password $RABBIT_PASSWORD
123+
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT sql_connection `database_connection_url trove`
124+
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT taskmanager_manager trove.taskmanager.manager.Manager
125+
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_user radmin
126+
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_tenant_name trove
127+
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_pass $RADMIN_USER_PASS
128+
iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
129+
fi
130+
}
131+
132+
# install_troveclient() - Collect source and prepare
133+
function install_troveclient() {
134+
git_clone $TROVECLIENT_REPO $TROVECLIENT_DIR $TROVECLIENT_BRANCH
135+
}
136+
137+
# install_trove() - Collect source and prepare
138+
function install_trove() {
139+
git_clone $TROVE_REPO $TROVE_DIR $TROVE_BRANCH
140+
}
141+
142+
# init_trove() - Initializes Trove Database as a Service
143+
function init_trove() {
144+
#(Re)Create trove db
145+
recreate_database trove utf8
146+
147+
#Initialize the trove database
148+
$TROVE_DIR/bin/trove-manage db_sync
149+
}
150+
151+
# start_trove() - Start running processes, including screen
152+
function start_trove() {
153+
screen_it tr-api "cd $TROVE_DIR; bin/trove-api --config-file=$TROVE_CONF_DIR/trove.conf --debug 2>&1"
154+
screen_it tr-tmgr "cd $TROVE_DIR; bin/trove-taskmanager --config-file=$TROVE_CONF_DIR/trove-taskmanager.conf --debug 2>&1"
155+
}
156+
157+
# stop_trove() - Stop running processes
158+
function stop_trove() {
159+
# Kill the trove screen windows
160+
for serv in tr-api tr-tmgr; do
161+
screen -S $SCREEN_NAME -p $serv -X kill
162+
done
163+
}
164+
165+
# Restore xtrace
166+
$XTRACE
167+
168+
# Local variables:
169+
# mode: shell-script
170+
# End:

stack.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# ``stack.sh`` is an opinionated OpenStack developer installation. It
44
# installs and configures various combinations of **Ceilometer**, **Cinder**,
5-
# **Glance**, **Heat**, **Horizon**, **Keystone**, **Nova**, **Neutron**
6-
# and **Swift**.
5+
# **Glance**, **Heat**, **Horizon**, **Keystone**, **Nova**, **Neutron**,
6+
# **Swift**, and **Trove**
77

88
# This script allows you to specify configuration options of what git
99
# repositories to use, enabled services, network configuration and various
@@ -319,6 +319,7 @@ source $TOP_DIR/lib/neutron
319319
source $TOP_DIR/lib/baremetal
320320
source $TOP_DIR/lib/ldap
321321
source $TOP_DIR/lib/ironic
322+
source $TOP_DIR/lib/trove
322323

323324
# Look for Nova hypervisor plugin
324325
NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins
@@ -720,6 +721,12 @@ if is_service_enabled heat; then
720721
configure_heat
721722
fi
722723

724+
if is_service_enabled trove; then
725+
install_trove
726+
install_troveclient
727+
cleanup_trove
728+
fi
729+
723730
if is_service_enabled tls-proxy; then
724731
configure_CA
725732
init_CA
@@ -860,6 +867,10 @@ if is_service_enabled key; then
860867
create_cinder_accounts
861868
create_neutron_accounts
862869

870+
if is_service_enabled trove; then
871+
create_trove_accounts
872+
fi
873+
863874
if is_service_enabled swift || is_service_enabled s-proxy; then
864875
create_swift_accounts
865876
fi
@@ -1236,6 +1247,18 @@ if is_service_enabled heat; then
12361247
start_heat
12371248
fi
12381249

1250+
# Configure and launch the trove service api, and taskmanager
1251+
if is_service_enabled trove; then
1252+
# Initialize trove
1253+
echo_summary "Configuring Trove"
1254+
configure_troveclient
1255+
configure_trove
1256+
init_trove
1257+
1258+
# Start the trove API and trove taskmgr components
1259+
echo_summary "Starting Trove"
1260+
start_trove
1261+
fi
12391262

12401263
# Create account rc files
12411264
# =======================

stackrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ RYU_BRANCH=${RYU_BRANCH:-master}
181181
SPICE_REPO=${SPICE_REPO:-http://anongit.freedesktop.org/git/spice/spice-html5.git}
182182
SPICE_BRANCH=${SPICE_BRANCH:-master}
183183

184+
# trove service
185+
TROVE_REPO=${TROVE_REPO:-${GIT_BASE}/openstack/trove.git}
186+
TROVE_BRANCH=${TROVE_BRANCH:-master}
187+
188+
# trove client library test
189+
TROVECLIENT_REPO=${TROVECLIENT_REPO:-${GIT_BASE}/openstack/python-troveclient.git}
190+
TROVECLIENT_BRANCH=${TROVECLIENT_BRANCH:-master}
184191

185192
# Nova hypervisor configuration. We default to libvirt with **kvm** but will
186193
# drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can

unstack.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ source $TOP_DIR/lib/horizon
3434
source $TOP_DIR/lib/swift
3535
source $TOP_DIR/lib/neutron
3636
source $TOP_DIR/lib/ironic
37+
source $TOP_DIR/lib/trove
3738

3839
# Determine what system we are running on. This provides ``os_VENDOR``,
3940
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
@@ -130,4 +131,8 @@ if is_service_enabled neutron; then
130131
cleanup_neutron
131132
fi
132133

134+
if is_service_enabled trove; then
135+
cleanup_trove
136+
fi
137+
133138
cleanup_tmp

0 commit comments

Comments
 (0)