Browse code

Add marconi support to devstack

Marconi has an optional dependency on keystone for authentication. This
code was tested with everything enabled and also with the following
localrc:

STACK_USER=fedora
SERVICE_TOKEN=secrete
ADMIN_PASSWORD=secrete
MYSQL_PASSWORD=secrete
RABBIT_PASSWORD=secrete
SERVICE_PASSWORD=secrete

disable_all_services
enable_service qpid
enable_service key
enable_service mysql
enable_service marconi-server

Implements blueprint marconi-devstack-integration
Implements blueprint devstack-support

Change-Id: I13495bcc5c5eb66cee641894e9f84a0089460c8b

Flaper Fesp authored on 2013/09/04 22:35:47
Showing 5 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,43 @@
0
+#!/usr/bin/env bash
1
+
2
+# **marconi.sh**
3
+
4
+# Sanity check that Marconi 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 marconi-server || exit 55
36
+
37
+curl http://$SERVICE_HOST:8888/v1/ 2>/dev/null | grep -q 'Auth' || die $LINENO "Marconi API not functioning!"
38
+
39
+set +o xtrace
40
+echo "*********************************************************************"
41
+echo "SUCCESS: End DevStack Exercise: $0"
42
+echo "*********************************************************************"
0 43
new file mode 100644
... ...
@@ -0,0 +1,29 @@
0
+# marconi.sh - Devstack extras script to install Marconi
1
+
2
+if is_service_enabled marconi-server; then
3
+    if [[ "$1" == "source" ]]; then
4
+        # Initial source
5
+        source $TOP_DIR/lib/marconi
6
+    elif [[ "$1" == "stack" && "$2" == "install" ]]; then
7
+        echo_summary "Installing Marconi"
8
+        install_marconiclient
9
+        install_marconi
10
+    elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
11
+        echo_summary "Configuring Marconi"
12
+        configure_marconi
13
+        configure_marconiclient
14
+
15
+        if is_service_enabled key; then
16
+            create_marconi_accounts
17
+        fi
18
+
19
+    elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
20
+        echo_summary "Initializing Marconi"
21
+        init_marconi
22
+        start_marconi
23
+    fi
24
+
25
+    if [[ "$1" == "unstack" ]]; then
26
+        stop_marconi
27
+    fi
28
+fi
0 29
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+python-pymongo
1
+mongodb-server
2
+pkg-config
0 3
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+selinux-policy-targeted
1
+mongodb-server
2
+pymongo
0 3
new file mode 100644
... ...
@@ -0,0 +1,171 @@
0
+# lib/marconi
1
+# Install and start **Marconi** service
2
+
3
+# To enable a minimal set of Marconi services, add the following to localrc:
4
+#   enable_service marconi-server
5
+#
6
+# Dependencies:
7
+# - functions
8
+# - OS_AUTH_URL for auth in api
9
+# - DEST set to the destination directory
10
+# - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api
11
+# - STACK_USER service user
12
+
13
+# stack.sh
14
+# ---------
15
+# install_marconi
16
+# configure_marconi
17
+# init_marconi
18
+# start_marconi
19
+# stop_marconi
20
+# cleanup_marconi
21
+
22
+# Save trace setting
23
+XTRACE=$(set +o | grep xtrace)
24
+set +o xtrace
25
+
26
+
27
+# Defaults
28
+# --------
29
+
30
+# Set up default directories
31
+MARCONI_DIR=$DEST/marconi
32
+MARCONICLIENT_DIR=$DEST/python-marconiclient
33
+MARCONI_CONF_DIR=/etc/marconi
34
+MARCONI_CONF=$MARCONI_CONF_DIR/marconi.conf
35
+MARCONI_API_LOG_DIR=/var/log/marconi-api
36
+MARCONI_AUTH_CACHE_DIR=${MARCONI_AUTH_CACHE_DIR:-/var/cache/marconi}
37
+
38
+# Support potential entry-points console scripts
39
+MARCONI_BIN_DIR=$(get_python_exec_prefix)
40
+
41
+# Set up database backend
42
+MARCONI_BACKEND=${MARCONI_BACKEND:-mongodb}
43
+
44
+
45
+# Set Marconi repository
46
+MARCONI_REPO=${MARCONI_REPO:-${GIT_BASE}/openstack/marconi.git}
47
+MARCONI_BRANCH=${MARCONI_BRANCH:-master}
48
+
49
+# Set client library repository
50
+MARCONICLIENT_REPO=${MARCONICLIENT_REPO:-${GIT_BASE}/openstack/python-marconiclient.git}
51
+MARCONICLIENT_BRANCH=${MARCONICLIENT_BRANCH:-master}
52
+
53
+# Functions
54
+# ---------
55
+
56
+# cleanup_marconi() - Remove residual data files, anything left over from previous
57
+# runs that a clean run would need to clean up
58
+function cleanup_marconi() {
59
+    mongo marconi --eval "db.dropDatabase();"
60
+}
61
+
62
+# configure_marconiclient() - Set config files, create data dirs, etc
63
+function configure_marconiclient() {
64
+    setup_develop $MARCONICLIENT_DIR
65
+}
66
+
67
+# configure_marconi() - Set config files, create data dirs, etc
68
+function configure_marconi() {
69
+    setup_develop $MARCONI_DIR
70
+
71
+    [ ! -d $MARCONI_CONF_DIR ] && sudo mkdir -m 755 -p $MARCONI_CONF_DIR
72
+    sudo chown $USER $MARCONI_CONF_DIR
73
+
74
+    [ ! -d $MARCONI_API_LOG_DIR ] &&  sudo mkdir -m 755 -p $MARCONI_API_LOG_DIR
75
+    sudo chown $USER $MARCONI_API_LOG_DIR
76
+
77
+    iniset $MARCONI_CONF DEFAULT verbose True
78
+    iniset $MARCONI_CONF 'drivers:transport:wsgi' bind '0.0.0.0'
79
+
80
+    # Install the policy file for the API server
81
+    cp $MARCONI_DIR/etc/marconi/policy.json $MARCONI_CONF_DIR
82
+    iniset $MARCONI_CONF DEFAULT policy_file $MARCONI_CONF_DIR/policy.json
83
+
84
+    iniset $MARCONI_CONF keystone_authtoken auth_protocol http
85
+    iniset $MARCONI_CONF keystone_authtoken admin_user marconi
86
+    iniset $MARCONI_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
87
+    iniset $MARCONI_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
88
+    iniset $MARCONI_CONF keystone_authtoken signing_dir $MARCONI_AUTH_CACHE_DIR
89
+
90
+    if [[ "$MARCONI_BACKEND" = 'mongodb' ]]; then
91
+        iniset $MARCONI_CONF database connection mongodb://localhost:27017/marconi
92
+        configure_mongodb
93
+        cleanup_marconi
94
+    fi
95
+}
96
+
97
+function configure_mongodb() {
98
+    # Set nssize to 2GB. This increases the number of namespaces supported
99
+    # # per database.
100
+    sudo sed -i '/--nssize/!s/OPTIONS=\"/OPTIONS=\"--nssize 2047 /' /etc/sysconfig/mongod
101
+
102
+    restart_service mongod
103
+}
104
+
105
+# init_marconi() - Initialize etc.
106
+function init_marconi() {
107
+    # Create cache dir
108
+    sudo mkdir -p $MARCONI_AUTH_CACHE_DIR
109
+    sudo chown $STACK_USER $MARCONI_AUTH_CACHE_DIR
110
+    rm -f $MARCONI_AUTH_CACHE_DIR/*
111
+}
112
+
113
+# install_marconi() - Collect source and prepare
114
+function install_marconi() {
115
+    git_clone $MARCONI_REPO $MARCONI_DIR $MARCONI_BRANCH
116
+    setup_develop $MARCONI_DIR
117
+}
118
+
119
+# install_marconiclient() - Collect source and prepare
120
+function install_marconiclient() {
121
+    git_clone $MARCONICLIENT_REPO $MARCONICLIENT_DIR $MARCONICLIENT_BRANCH
122
+    setup_develop $MARCONICLIENT_DIR
123
+}
124
+
125
+# start_marconi() - Start running processes, including screen
126
+function start_marconi() {
127
+    screen_it marconi-server "marconi-server --config-file $MARCONI_CONF"
128
+}
129
+
130
+# stop_marconi() - Stop running processes
131
+function stop_marconi() {
132
+    # Kill the marconi screen windows
133
+    for serv in marconi-server; do
134
+        screen -S $SCREEN_NAME -p $serv -X kill
135
+    done
136
+}
137
+
138
+function create_marconi_accounts() {
139
+    SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
140
+    ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
141
+
142
+    MARCONI_USER=$(get_id keystone user-create --name=marconi \
143
+                                                --pass="$SERVICE_PASSWORD" \
144
+                                                --tenant_id $SERVICE_TENANT \
145
+                                                --email=marconi@example.com)
146
+    keystone user-role-add --tenant-id $SERVICE_TENANT \
147
+                            --user-id $MARCONI_USER \
148
+                            --role-id $ADMIN_ROLE
149
+    if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
150
+        MARCONI_SERVICE=$(get_id keystone service-create \
151
+            --name=marconi \
152
+            --type=queuing \
153
+            --description="Marconi Service")
154
+        keystone endpoint-create \
155
+            --region RegionOne \
156
+            --service_id $MARCONI_SERVICE \
157
+            --publicurl "http://$SERVICE_HOST:8888" \
158
+            --adminurl "http://$SERVICE_HOST:8888" \
159
+            --internalurl "http://$SERVICE_HOST:8888"
160
+    fi
161
+
162
+}
163
+
164
+
165
+# Restore xtrace
166
+$XTRACE
167
+
168
+# Local variables:
169
+# mode: shell-script
170
+# End: