blob: cc33aebd2b58d78df93cffadd4699ecfa243032f [file] [log] [blame]
Flaper Fesp06b345e2013-09-04 15:35:47 +02001# lib/marconi
2# Install and start **Marconi** service
3
4# To enable a minimal set of Marconi services, add the following to localrc:
Dean Troyerd8864fe2014-02-17 11:00:42 -06005#
6# enable_service marconi-server
Flaper Fesp06b345e2013-09-04 15:35:47 +02007#
8# Dependencies:
9# - functions
10# - OS_AUTH_URL for auth in api
11# - DEST set to the destination directory
12# - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api
13# - STACK_USER service user
14
15# stack.sh
16# ---------
17# install_marconi
18# configure_marconi
19# init_marconi
20# start_marconi
21# stop_marconi
22# cleanup_marconi
23
24# Save trace setting
25XTRACE=$(set +o | grep xtrace)
26set +o xtrace
27
28
29# Defaults
30# --------
31
32# Set up default directories
33MARCONI_DIR=$DEST/marconi
34MARCONICLIENT_DIR=$DEST/python-marconiclient
35MARCONI_CONF_DIR=/etc/marconi
36MARCONI_CONF=$MARCONI_CONF_DIR/marconi.conf
37MARCONI_API_LOG_DIR=/var/log/marconi-api
38MARCONI_AUTH_CACHE_DIR=${MARCONI_AUTH_CACHE_DIR:-/var/cache/marconi}
39
40# Support potential entry-points console scripts
41MARCONI_BIN_DIR=$(get_python_exec_prefix)
42
43# Set up database backend
44MARCONI_BACKEND=${MARCONI_BACKEND:-mongodb}
45
46
47# Set Marconi repository
48MARCONI_REPO=${MARCONI_REPO:-${GIT_BASE}/openstack/marconi.git}
49MARCONI_BRANCH=${MARCONI_BRANCH:-master}
50
51# Set client library repository
52MARCONICLIENT_REPO=${MARCONICLIENT_REPO:-${GIT_BASE}/openstack/python-marconiclient.git}
53MARCONICLIENT_BRANCH=${MARCONICLIENT_BRANCH:-master}
54
Dean Troyer4237f592014-01-29 16:22:11 -060055# Tell Tempest this project is present
Malini Kamalambal1e4e3ac2014-02-14 11:29:26 -050056TEMPEST_SERVICES+=,marconi
Dean Troyer4237f592014-01-29 16:22:11 -060057
58
Flaper Fesp06b345e2013-09-04 15:35:47 +020059# Functions
60# ---------
61
Malini Kamalambal9972ec22014-02-10 11:22:39 -050062# Test if any Marconi services are enabled
63# is_marconi_enabled
64function is_marconi_enabled {
65 [[ ,${ENABLED_SERVICES} =~ ,"marconi-" ]] && return 0
66 return 1
67}
68
Flaper Fesp06b345e2013-09-04 15:35:47 +020069# cleanup_marconi() - Remove residual data files, anything left over from previous
70# runs that a clean run would need to clean up
71function cleanup_marconi() {
72 mongo marconi --eval "db.dropDatabase();"
73}
74
75# configure_marconiclient() - Set config files, create data dirs, etc
76function configure_marconiclient() {
77 setup_develop $MARCONICLIENT_DIR
78}
79
80# configure_marconi() - Set config files, create data dirs, etc
81function configure_marconi() {
82 setup_develop $MARCONI_DIR
83
84 [ ! -d $MARCONI_CONF_DIR ] && sudo mkdir -m 755 -p $MARCONI_CONF_DIR
85 sudo chown $USER $MARCONI_CONF_DIR
86
87 [ ! -d $MARCONI_API_LOG_DIR ] && sudo mkdir -m 755 -p $MARCONI_API_LOG_DIR
88 sudo chown $USER $MARCONI_API_LOG_DIR
89
90 iniset $MARCONI_CONF DEFAULT verbose True
91 iniset $MARCONI_CONF 'drivers:transport:wsgi' bind '0.0.0.0'
92
Flaper Fesp06b345e2013-09-04 15:35:47 +020093 iniset $MARCONI_CONF keystone_authtoken auth_protocol http
94 iniset $MARCONI_CONF keystone_authtoken admin_user marconi
95 iniset $MARCONI_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
96 iniset $MARCONI_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
97 iniset $MARCONI_CONF keystone_authtoken signing_dir $MARCONI_AUTH_CACHE_DIR
98
99 if [[ "$MARCONI_BACKEND" = 'mongodb' ]]; then
100 iniset $MARCONI_CONF database connection mongodb://localhost:27017/marconi
101 configure_mongodb
102 cleanup_marconi
103 fi
104}
105
106function configure_mongodb() {
107 # Set nssize to 2GB. This increases the number of namespaces supported
108 # # per database.
Dean Troyer41d96d72014-02-11 09:08:35 -0600109 if is_ubuntu; then
110 sudo sed -i -e "
111 s|[^ \t]*#[ \t]*\(nssize[ \t]*=.*\$\)|\1|
112 s|^\(nssize[ \t]*=[ \t]*\).*\$|\1 2047|
113 " /etc/mongodb.conf
114 restart_service mongodb
115 elif is_fedora; then
116 sudo sed -i '/--nssize/!s/OPTIONS=\"/OPTIONS=\"--nssize 2047 /' /etc/sysconfig/mongod
117 restart_service mongod
118 fi
Flaper Fesp06b345e2013-09-04 15:35:47 +0200119}
120
121# init_marconi() - Initialize etc.
122function init_marconi() {
123 # Create cache dir
124 sudo mkdir -p $MARCONI_AUTH_CACHE_DIR
125 sudo chown $STACK_USER $MARCONI_AUTH_CACHE_DIR
126 rm -f $MARCONI_AUTH_CACHE_DIR/*
127}
128
129# install_marconi() - Collect source and prepare
130function install_marconi() {
131 git_clone $MARCONI_REPO $MARCONI_DIR $MARCONI_BRANCH
132 setup_develop $MARCONI_DIR
133}
134
135# install_marconiclient() - Collect source and prepare
136function install_marconiclient() {
137 git_clone $MARCONICLIENT_REPO $MARCONICLIENT_DIR $MARCONICLIENT_BRANCH
138 setup_develop $MARCONICLIENT_DIR
139}
140
141# start_marconi() - Start running processes, including screen
142function start_marconi() {
143 screen_it marconi-server "marconi-server --config-file $MARCONI_CONF"
144}
145
146# stop_marconi() - Stop running processes
147function stop_marconi() {
148 # Kill the marconi screen windows
149 for serv in marconi-server; do
150 screen -S $SCREEN_NAME -p $serv -X kill
151 done
152}
153
154function create_marconi_accounts() {
Steve Martinelli19685422014-01-24 13:02:26 -0600155 SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
156 ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }")
Flaper Fesp06b345e2013-09-04 15:35:47 +0200157
Steve Martinelli19685422014-01-24 13:02:26 -0600158 MARCONI_USER=$(openstack user create \
159 marconi \
160 --password "$SERVICE_PASSWORD" \
161 --project $SERVICE_TENANT \
162 --email marconi@example.com \
163 | grep " id " | get_field 2)
164 openstack role add \
165 $ADMIN_ROLE \
166 --project $SERVICE_TENANT \
167 --user $MARCONI_USER
Malini Kamalambal0b3aacc2014-02-13 18:18:51 -0500168
Flaper Fesp06b345e2013-09-04 15:35:47 +0200169 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Steve Martinelli19685422014-01-24 13:02:26 -0600170 MARCONI_SERVICE=$(openstack service create \
171 marconi \
Flaper Fesp06b345e2013-09-04 15:35:47 +0200172 --type=queuing \
Malini Kamalambal0f7ad6b2013-12-13 12:42:31 -0500173 --description="Marconi Service" \
174 | grep " id " | get_field 2)
Steve Martinelli19685422014-01-24 13:02:26 -0600175 openstack endpoint create \
176 $MARCONI_SERVICE \
Flaper Fesp06b345e2013-09-04 15:35:47 +0200177 --region RegionOne \
Flaper Fesp06b345e2013-09-04 15:35:47 +0200178 --publicurl "http://$SERVICE_HOST:8888" \
179 --adminurl "http://$SERVICE_HOST:8888" \
180 --internalurl "http://$SERVICE_HOST:8888"
181 fi
182
183}
184
185
186# Restore xtrace
187$XTRACE
188
189# Local variables:
190# mode: shell-script
191# End: