blob: 3d5ef82471fc404e383ef52f5aa43d45c14d4a85 [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:
5# enable_service marconi-server
6#
7# Dependencies:
8# - functions
9# - OS_AUTH_URL for auth in api
10# - DEST set to the destination directory
11# - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api
12# - STACK_USER service user
13
14# stack.sh
15# ---------
16# install_marconi
17# configure_marconi
18# init_marconi
19# start_marconi
20# stop_marconi
21# cleanup_marconi
22
23# Save trace setting
24XTRACE=$(set +o | grep xtrace)
25set +o xtrace
26
27
28# Defaults
29# --------
30
31# Set up default directories
32MARCONI_DIR=$DEST/marconi
33MARCONICLIENT_DIR=$DEST/python-marconiclient
34MARCONI_CONF_DIR=/etc/marconi
35MARCONI_CONF=$MARCONI_CONF_DIR/marconi.conf
36MARCONI_API_LOG_DIR=/var/log/marconi-api
37MARCONI_AUTH_CACHE_DIR=${MARCONI_AUTH_CACHE_DIR:-/var/cache/marconi}
38
39# Support potential entry-points console scripts
40MARCONI_BIN_DIR=$(get_python_exec_prefix)
41
42# Set up database backend
43MARCONI_BACKEND=${MARCONI_BACKEND:-mongodb}
44
45
46# Set Marconi repository
47MARCONI_REPO=${MARCONI_REPO:-${GIT_BASE}/openstack/marconi.git}
48MARCONI_BRANCH=${MARCONI_BRANCH:-master}
49
50# Set client library repository
51MARCONICLIENT_REPO=${MARCONICLIENT_REPO:-${GIT_BASE}/openstack/python-marconiclient.git}
52MARCONICLIENT_BRANCH=${MARCONICLIENT_BRANCH:-master}
53
Dean Troyer4237f592014-01-29 16:22:11 -060054# Tell Tempest this project is present
55TEMPEST_SERVICES+=,marconi
56
57
Flaper Fesp06b345e2013-09-04 15:35:47 +020058# Functions
59# ---------
60
61# cleanup_marconi() - Remove residual data files, anything left over from previous
62# runs that a clean run would need to clean up
63function cleanup_marconi() {
64 mongo marconi --eval "db.dropDatabase();"
65}
66
67# configure_marconiclient() - Set config files, create data dirs, etc
68function configure_marconiclient() {
69 setup_develop $MARCONICLIENT_DIR
70}
71
72# configure_marconi() - Set config files, create data dirs, etc
73function configure_marconi() {
74 setup_develop $MARCONI_DIR
75
76 [ ! -d $MARCONI_CONF_DIR ] && sudo mkdir -m 755 -p $MARCONI_CONF_DIR
77 sudo chown $USER $MARCONI_CONF_DIR
78
79 [ ! -d $MARCONI_API_LOG_DIR ] && sudo mkdir -m 755 -p $MARCONI_API_LOG_DIR
80 sudo chown $USER $MARCONI_API_LOG_DIR
81
82 iniset $MARCONI_CONF DEFAULT verbose True
83 iniset $MARCONI_CONF 'drivers:transport:wsgi' bind '0.0.0.0'
84
Flaper Fesp06b345e2013-09-04 15:35:47 +020085 iniset $MARCONI_CONF keystone_authtoken auth_protocol http
86 iniset $MARCONI_CONF keystone_authtoken admin_user marconi
87 iniset $MARCONI_CONF keystone_authtoken admin_password $SERVICE_PASSWORD
88 iniset $MARCONI_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
89 iniset $MARCONI_CONF keystone_authtoken signing_dir $MARCONI_AUTH_CACHE_DIR
90
91 if [[ "$MARCONI_BACKEND" = 'mongodb' ]]; then
92 iniset $MARCONI_CONF database connection mongodb://localhost:27017/marconi
93 configure_mongodb
94 cleanup_marconi
95 fi
96}
97
98function configure_mongodb() {
99 # Set nssize to 2GB. This increases the number of namespaces supported
100 # # per database.
Dean Troyer41d96d72014-02-11 09:08:35 -0600101 if is_ubuntu; then
102 sudo sed -i -e "
103 s|[^ \t]*#[ \t]*\(nssize[ \t]*=.*\$\)|\1|
104 s|^\(nssize[ \t]*=[ \t]*\).*\$|\1 2047|
105 " /etc/mongodb.conf
106 restart_service mongodb
107 elif is_fedora; then
108 sudo sed -i '/--nssize/!s/OPTIONS=\"/OPTIONS=\"--nssize 2047 /' /etc/sysconfig/mongod
109 restart_service mongod
110 fi
Flaper Fesp06b345e2013-09-04 15:35:47 +0200111}
112
113# init_marconi() - Initialize etc.
114function init_marconi() {
115 # Create cache dir
116 sudo mkdir -p $MARCONI_AUTH_CACHE_DIR
117 sudo chown $STACK_USER $MARCONI_AUTH_CACHE_DIR
118 rm -f $MARCONI_AUTH_CACHE_DIR/*
119}
120
121# install_marconi() - Collect source and prepare
122function install_marconi() {
123 git_clone $MARCONI_REPO $MARCONI_DIR $MARCONI_BRANCH
124 setup_develop $MARCONI_DIR
125}
126
127# install_marconiclient() - Collect source and prepare
128function install_marconiclient() {
129 git_clone $MARCONICLIENT_REPO $MARCONICLIENT_DIR $MARCONICLIENT_BRANCH
130 setup_develop $MARCONICLIENT_DIR
131}
132
133# start_marconi() - Start running processes, including screen
134function start_marconi() {
135 screen_it marconi-server "marconi-server --config-file $MARCONI_CONF"
136}
137
138# stop_marconi() - Stop running processes
139function stop_marconi() {
140 # Kill the marconi screen windows
141 for serv in marconi-server; do
142 screen -S $SCREEN_NAME -p $serv -X kill
143 done
144}
145
146function create_marconi_accounts() {
147 SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
148 ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
149
150 MARCONI_USER=$(get_id keystone user-create --name=marconi \
151 --pass="$SERVICE_PASSWORD" \
Dirk Mueller25049cd2014-01-09 13:53:52 +0100152 --tenant-id $SERVICE_TENANT \
Flaper Fesp06b345e2013-09-04 15:35:47 +0200153 --email=marconi@example.com)
154 keystone user-role-add --tenant-id $SERVICE_TENANT \
155 --user-id $MARCONI_USER \
156 --role-id $ADMIN_ROLE
157 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Malini Kamalambal0f7ad6b2013-12-13 12:42:31 -0500158 MARCONI_SERVICE=$(keystone service-create \
Flaper Fesp06b345e2013-09-04 15:35:47 +0200159 --name=marconi \
160 --type=queuing \
Malini Kamalambal0f7ad6b2013-12-13 12:42:31 -0500161 --description="Marconi Service" \
162 | grep " id " | get_field 2)
Flaper Fesp06b345e2013-09-04 15:35:47 +0200163 keystone endpoint-create \
164 --region RegionOne \
165 --service_id $MARCONI_SERVICE \
166 --publicurl "http://$SERVICE_HOST:8888" \
167 --adminurl "http://$SERVICE_HOST:8888" \
168 --internalurl "http://$SERVICE_HOST:8888"
169 fi
170
171}
172
173
174# Restore xtrace
175$XTRACE
176
177# Local variables:
178# mode: shell-script
179# End: