Browse code

Merge "Added Trove (Database as a Service)."

Jenkins authored on 2013/09/13 07:42:18
Showing 9 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,45 @@
0
+#!/usr/bin/env bash
1
+
2
+# **trove.sh**
3
+
4
+# Sanity check that trove started if enabled
5
+
6
+echo "*********************************************************************"
7
+echo "Begin DevStack Exercise: $0"
8
+echo "*********************************************************************"
9
+
10
+# This script exits on an error so that errors don't compound and you see
11
+# only the first error that occurred.
12
+set -o errexit
13
+
14
+# Print the commands being run so that we can see the command that triggers
15
+# an error.  It is also useful for following allowing as the install occurs.
16
+set -o xtrace
17
+
18
+
19
+# Settings
20
+# ========
21
+
22
+# Keep track of the current directory
23
+EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
24
+TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
25
+
26
+# Import common functions
27
+source $TOP_DIR/functions
28
+
29
+# Import configuration
30
+source $TOP_DIR/openrc
31
+
32
+# Import exercise configuration
33
+source $TOP_DIR/exerciserc
34
+
35
+is_service_enabled trove || exit 55
36
+
37
+# can we get a list versions
38
+curl http://$SERVICE_HOST:8779/ 2>/dev/null | grep -q 'versions' || die $LINENO "Trove API not functioning!"
39
+
40
+set +o xtrace
41
+echo "*********************************************************************"
42
+echo "SUCCESS: End DevStack Exercise: $0"
43
+echo "*********************************************************************"
44
+
0 45
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+libxslt1-dev   # testonly
0 1
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+libxslt1-dev   # testonly
0 1
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+libxslt1-dev   # testonly
... ...
@@ -779,6 +779,7 @@ function is_running() {
779 779
 #   **glance** returns true if any service enabled start with **g-**
780 780
 #   **neutron** returns true if any service enabled start with **q-**
781 781
 #   **swift** returns true if any service enabled start with **s-**
782
+#   **trove** returns true if any service enabled start with **tr-**
782 783
 #   For backward compatibility if we have **swift** in ENABLED_SERVICES all the
783 784
 #   **s-** services will be enabled. This will be deprecated in the future.
784 785
 #
... ...
@@ -798,6 +799,7 @@ function is_service_enabled() {
798 798
         [[ ${service} == "ceilometer" && ${ENABLED_SERVICES} =~ "ceilometer-" ]] && return 0
799 799
         [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
800 800
         [[ ${service} == "neutron" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
801
+        [[ ${service} == "trove" && ${ENABLED_SERVICES} =~ "tr-" ]] && return 0
801 802
         [[ ${service} == "swift" && ${ENABLED_SERVICES} =~ "s-" ]] && return 0
802 803
         [[ ${service} == s-* && ${ENABLED_SERVICES} =~ "swift" ]] && return 0
803 804
     done
804 805
new file mode 100644
... ...
@@ -0,0 +1,170 @@
0
+# lib/trove
1
+# Functions to control the configuration and operation of the **Trove** service
2
+
3
+# Dependencies:
4
+# ``functions`` file
5
+# ``DEST``, ``STACK_USER`` must be defined
6
+# ``SERVICE_{HOST|PROTOCOL|TOKEN}`` must be defined
7
+
8
+# ``stack.sh`` calls the entry points in this order:
9
+#
10
+# install_trove
11
+# configure_trove
12
+# init_trove
13
+# start_trove
14
+# stop_trove
15
+# cleanup_trove
16
+
17
+# Save trace setting
18
+XTRACE=$(set +o | grep xtrace)
19
+set +o xtrace
20
+
21
+# Defaults
22
+# --------
23
+
24
+NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
25
+
26
+# Set up default configuration
27
+TROVE_DIR=$DEST/trove
28
+TROVECLIENT_DIR=$DEST/python-troveclient
29
+TROVE_CONF_DIR=/etc/trove
30
+TROVE_LOCAL_CONF_DIR=$TROVE_DIR/etc/trove
31
+TROVE_AUTH_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT//v$IDENTITY_API_VERSION
32
+TROVE_AUTH_CACHE_DIR=${TROVE_AUTH_CACHE_DIR:-/var/cache/trove}
33
+TROVE_BIN_DIR=/usr/local/bin
34
+
35
+# create_trove_accounts() - Set up common required trove accounts
36
+
37
+# Tenant               User       Roles
38
+# ------------------------------------------------------------------
39
+# service              trove     admin        # if enabled
40
+
41
+create_trove_accounts() {
42
+    # Trove
43
+    SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
44
+    SERVICE_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
45
+
46
+    if [[ "$ENABLED_SERVICES" =~ "trove" ]]; then
47
+        TROVE_USER=$(keystone user-create --name=trove \
48
+                                                  --pass="$SERVICE_PASSWORD" \
49
+                                                  --tenant_id $SERVICE_TENANT \
50
+                                                  --email=trove@example.com \
51
+                                                  | grep " id " | get_field 2)
52
+        keystone user-role-add --tenant-id $SERVICE_TENANT \
53
+                               --user-id $TROVE_USER \
54
+                               --role-id $SERVICE_ROLE
55
+        if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
56
+            TROVE_SERVICE=$(keystone service-create \
57
+                --name=trove \
58
+                --type=database \
59
+                --description="Trove Service" \
60
+                | grep " id " | get_field 2)
61
+            keystone endpoint-create \
62
+                --region RegionOne \
63
+                --service_id $TROVE_SERVICE \
64
+                --publicurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
65
+                --adminurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s" \
66
+                --internalurl "http://$SERVICE_HOST:8779/v1.0/\$(tenant_id)s"
67
+        fi
68
+    fi
69
+}
70
+
71
+# stack.sh entry points
72
+# ---------------------
73
+
74
+# cleanup_trove() - Remove residual data files, anything left over from previous
75
+# runs that a clean run would need to clean up
76
+function cleanup_trove() {
77
+    #Clean up dirs
78
+    rm -fr $TROVE_AUTH_CACHE_DIR/*
79
+    rm -fr $TROVE_CONF_DIR/*
80
+}
81
+
82
+# configure_troveclient() - Set config files, create data dirs, etc
83
+function configure_troveclient() {
84
+    setup_develop $TROVECLIENT_DIR
85
+}
86
+
87
+# configure_trove() - Set config files, create data dirs, etc
88
+function configure_trove() {
89
+    setup_develop $TROVE_DIR
90
+
91
+    # Create the trove conf dir and cache dirs if they don't exist
92
+    sudo mkdir -p ${TROVE_CONF_DIR}
93
+    sudo mkdir -p ${TROVE_AUTH_CACHE_DIR}
94
+    sudo chown -R $STACK_USER: ${TROVE_CONF_DIR}
95
+    sudo chown -R $STACK_USER: ${TROVE_AUTH_CACHE_DIR}
96
+
97
+    # Copy api-paste file over to the trove conf dir and configure it
98
+    cp $TROVE_LOCAL_CONF_DIR/api-paste.ini $TROVE_CONF_DIR/api-paste.ini
99
+    TROVE_API_PASTE_INI=$TROVE_CONF_DIR/api-paste.ini
100
+    iniset $TROVE_API_PASTE_INI filter:tokenauth auth_host $KEYSTONE_AUTH_HOST
101
+    iniset $TROVE_API_PASTE_INI filter:tokenauth auth_port $KEYSTONE_AUTH_PORT
102
+    iniset $TROVE_API_PASTE_INI filter:tokenauth auth_protocol $KEYSTONE_AUTH_PROTOCOL
103
+    iniset $TROVE_API_PASTE_INI filter:tokenauth admin_tenant_name $SERVICE_TENANT_NAME
104
+    iniset $TROVE_API_PASTE_INI filter:tokenauth admin_user trove
105
+    iniset $TROVE_API_PASTE_INI filter:tokenauth admin_password $SERVICE_PASSWORD
106
+    iniset $TROVE_API_PASTE_INI filter:tokenauth signing_dir $TROVE_AUTH_CACHE_DIR
107
+
108
+    # (Re)create trove conf files
109
+    rm -f $TROVE_CONF_DIR/trove.conf
110
+    rm -f $TROVE_CONF_DIR/trove-taskmanager.conf
111
+    iniset $TROVE_CONF_DIR/trove.conf DEFAULT rabbit_password $RABBIT_PASSWORD
112
+    iniset $TROVE_CONF_DIR/trove.conf DEFAULT sql_connection `database_connection_url trove`
113
+    iniset $TROVE_CONF_DIR/trove.conf DEFAULT add_addresses True
114
+
115
+    iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT rabbit_password $RABBIT_PASSWORD
116
+    iniset $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample DEFAULT sql_connection `database_connection_url trove`
117
+    sed -i "s/localhost/$NETWORK_GATEWAY/g" $TROVE_LOCAL_CONF_DIR/trove-guestagent.conf.sample
118
+
119
+    # (Re)create trove taskmanager conf file if needed
120
+    if is_service_enabled tr-tmgr; then
121
+        iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT rabbit_password $RABBIT_PASSWORD
122
+        iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT sql_connection `database_connection_url trove`
123
+        iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT taskmanager_manager trove.taskmanager.manager.Manager
124
+        iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_user radmin
125
+        iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_tenant_name trove
126
+        iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT nova_proxy_admin_pass $RADMIN_USER_PASS
127
+        iniset $TROVE_CONF_DIR/trove-taskmanager.conf DEFAULT trove_auth_url $TROVE_AUTH_ENDPOINT
128
+    fi
129
+}
130
+
131
+# install_troveclient() - Collect source and prepare
132
+function install_troveclient() {
133
+    git_clone $TROVECLIENT_REPO $TROVECLIENT_DIR $TROVECLIENT_BRANCH
134
+}
135
+
136
+# install_trove() - Collect source and prepare
137
+function install_trove() {
138
+    git_clone $TROVE_REPO $TROVE_DIR $TROVE_BRANCH
139
+}
140
+
141
+# init_trove() - Initializes Trove Database as a Service
142
+function init_trove() {
143
+    #(Re)Create trove db
144
+    recreate_database trove utf8
145
+
146
+    #Initialize the trove database
147
+    $TROVE_DIR/bin/trove-manage db_sync
148
+}
149
+
150
+# start_trove() - Start running processes, including screen
151
+function start_trove() {
152
+    screen_it tr-api "cd $TROVE_DIR; bin/trove-api --config-file=$TROVE_CONF_DIR/trove.conf --debug 2>&1"
153
+    screen_it tr-tmgr "cd $TROVE_DIR; bin/trove-taskmanager --config-file=$TROVE_CONF_DIR/trove-taskmanager.conf --debug 2>&1"
154
+}
155
+
156
+# stop_trove() - Stop running processes
157
+function stop_trove() {
158
+    # Kill the trove screen windows
159
+    for serv in tr-api tr-tmgr; do
160
+        screen -S $SCREEN_NAME -p $serv -X kill
161
+    done
162
+}
163
+
164
+# Restore xtrace
165
+$XTRACE
166
+
167
+# Local variables:
168
+# mode: shell-script
169
+# End:
... ...
@@ -2,8 +2,8 @@
2 2
 
3 3
 # ``stack.sh`` is an opinionated OpenStack developer installation.  It
4 4
 # 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**
7 7
 
8 8
 # This script allows you to specify configuration options of what git
9 9
 # repositories to use, enabled services, network configuration and various
... ...
@@ -319,6 +319,7 @@ source $TOP_DIR/lib/neutron
319 319
 source $TOP_DIR/lib/baremetal
320 320
 source $TOP_DIR/lib/ldap
321 321
 source $TOP_DIR/lib/ironic
322
+source $TOP_DIR/lib/trove
322 323
 
323 324
 # Look for Nova hypervisor plugin
324 325
 NOVA_PLUGINS=$TOP_DIR/lib/nova_plugins
... ...
@@ -720,6 +721,12 @@ if is_service_enabled heat; then
720 720
     configure_heat
721 721
 fi
722 722
 
723
+if is_service_enabled trove; then
724
+    install_trove
725
+    install_troveclient
726
+    cleanup_trove
727
+fi
728
+
723 729
 if is_service_enabled tls-proxy; then
724 730
     configure_CA
725 731
     init_CA
... ...
@@ -860,6 +867,10 @@ if is_service_enabled key; then
860 860
     create_cinder_accounts
861 861
     create_neutron_accounts
862 862
 
863
+    if is_service_enabled trove; then
864
+        create_trove_accounts
865
+    fi
866
+
863 867
     if is_service_enabled swift || is_service_enabled s-proxy; then
864 868
         create_swift_accounts
865 869
     fi
... ...
@@ -1236,6 +1247,18 @@ if is_service_enabled heat; then
1236 1236
     start_heat
1237 1237
 fi
1238 1238
 
1239
+# Configure and launch the trove service api, and taskmanager
1240
+if is_service_enabled trove; then
1241
+    # Initialize trove
1242
+    echo_summary "Configuring Trove"
1243
+    configure_troveclient
1244
+    configure_trove
1245
+    init_trove
1246
+
1247
+    # Start the trove API and trove taskmgr components
1248
+    echo_summary "Starting Trove"
1249
+    start_trove
1250
+fi
1239 1251
 
1240 1252
 # Create account rc files
1241 1253
 # =======================
... ...
@@ -181,6 +181,13 @@ RYU_BRANCH=${RYU_BRANCH:-master}
181 181
 SPICE_REPO=${SPICE_REPO:-http://anongit.freedesktop.org/git/spice/spice-html5.git}
182 182
 SPICE_BRANCH=${SPICE_BRANCH:-master}
183 183
 
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}
184 191
 
185 192
 # Nova hypervisor configuration.  We default to libvirt with **kvm** but will
186 193
 # drop back to **qemu** if we are unable to load the kvm module.  ``stack.sh`` can
... ...
@@ -34,6 +34,7 @@ source $TOP_DIR/lib/horizon
34 34
 source $TOP_DIR/lib/swift
35 35
 source $TOP_DIR/lib/neutron
36 36
 source $TOP_DIR/lib/ironic
37
+source $TOP_DIR/lib/trove
37 38
 
38 39
 # Determine what system we are running on.  This provides ``os_VENDOR``,
39 40
 # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
... ...
@@ -130,4 +131,8 @@ if is_service_enabled neutron; then
130 130
     cleanup_neutron
131 131
 fi
132 132
 
133
+if is_service_enabled trove; then
134
+    cleanup_trove
135
+fi
136
+
133 137
 cleanup_tmp