blob: 70feacd45af0a423ffb83f6acb34a065e4bdb988 [file] [log] [blame]
Sergey Lukjanov7ff84432014-03-10 20:04:51 +04001# lib/sahara
2
3# Dependencies:
4# ``functions`` file
5# ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined
6
7# ``stack.sh`` calls the entry points in this order:
8#
9# install_sahara
10# configure_sahara
11# start_sahara
12# stop_sahara
13# cleanup_sahara
14
15# Save trace setting
16XTRACE=$(set +o | grep xtrace)
17set +o xtrace
18
19
20# Defaults
21# --------
22
23# Set up default repos
24SAHARA_REPO=${SAHARA_REPO:-${GIT_BASE}/openstack/sahara.git}
25SAHARA_BRANCH=${SAHARA_BRANCH:-master}
26
27# Set up default directories
28SAHARA_DIR=$DEST/sahara
29SAHARA_CONF_DIR=${SAHARA_CONF_DIR:-/etc/sahara}
30SAHARA_CONF_FILE=${SAHARA_CONF_DIR}/sahara.conf
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040031
32SAHARA_SERVICE_HOST=${SAHARA_SERVICE_HOST:-$SERVICE_HOST}
33SAHARA_SERVICE_PORT=${SAHARA_SERVICE_PORT:-8386}
34SAHARA_SERVICE_PROTOCOL=${SAHARA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
35
36SAHARA_AUTH_CACHE_DIR=${SAHARA_AUTH_CACHE_DIR:-/var/cache/sahara}
37
Sergey Lukjanov10f41612014-04-25 11:42:41 +040038SAHARA_ENABLED_PLUGINS=${SAHARA_ENABLED_PLUGINS:-vanilla,hdp,fake}
39
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040040# Support entry points installation of console scripts
41if [[ -d $SAHARA_DIR/bin ]]; then
42 SAHARA_BIN_DIR=$SAHARA_DIR/bin
43else
44 SAHARA_BIN_DIR=$(get_python_exec_prefix)
45fi
46
47# Tell Tempest this project is present
48TEMPEST_SERVICES+=,sahara
49
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040050# Functions
51# ---------
52
53# create_sahara_accounts() - Set up common required sahara accounts
54#
55# Tenant User Roles
56# ------------------------------
57# service sahara admin
58function create_sahara_accounts {
59
60 SERVICE_TENANT=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
61 ADMIN_ROLE=$(openstack role list | awk "/ admin / { print \$2 }")
62
Bartosz Górski0abde392014-02-28 14:15:19 +010063 SAHARA_USER=$(get_or_create_user "sahara" \
Gael Chamoulaud6dd8a8b2014-07-22 01:12:12 +020064 "$SERVICE_PASSWORD" $SERVICE_TENANT)
Bartosz Górski0abde392014-02-28 14:15:19 +010065 get_or_add_user_role $ADMIN_ROLE $SAHARA_USER $SERVICE_TENANT
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040066
67 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Bartosz Górski0abde392014-02-28 14:15:19 +010068
69 SAHARA_SERVICE=$(get_or_create_service "sahara" \
70 "data_processing" "Sahara Data Processing")
71 get_or_create_endpoint $SAHARA_SERVICE \
72 "$REGION_NAME" \
73 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \
74 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \
75 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040076 fi
77}
78
79# cleanup_sahara() - Remove residual data files, anything left over from
80# previous runs that would need to clean up.
81function cleanup_sahara {
82
83 # Cleanup auth cache dir
84 sudo rm -rf $SAHARA_AUTH_CACHE_DIR
85}
86
87# configure_sahara() - Set config files, create data dirs, etc
88function configure_sahara {
89
90 if [[ ! -d $SAHARA_CONF_DIR ]]; then
91 sudo mkdir -p $SAHARA_CONF_DIR
92 fi
93 sudo chown $STACK_USER $SAHARA_CONF_DIR
94
95 # Copy over sahara configuration file and configure common parameters.
Sergey Lukjanov51ebda62014-03-12 22:26:12 +040096 cp $SAHARA_DIR/etc/sahara/sahara.conf.sample $SAHARA_CONF_FILE
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040097
98 # Create auth cache dir
99 sudo mkdir -p $SAHARA_AUTH_CACHE_DIR
100 sudo chown $STACK_USER $SAHARA_AUTH_CACHE_DIR
101 rm -rf $SAHARA_AUTH_CACHE_DIR/*
102
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400103 # Set actual keystone auth configs
104 iniset $SAHARA_CONF_FILE keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/
Sergey Lukjanov65dabd32014-04-22 18:37:45 +0400105 iniset $SAHARA_CONF_FILE keystone_authtoken auth_host $KEYSTONE_AUTH_HOST
106 iniset $SAHARA_CONF_FILE keystone_authtoken auth_port $KEYSTONE_AUTH_PORT
107 iniset $SAHARA_CONF_FILE keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400108 iniset $SAHARA_CONF_FILE keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
109 iniset $SAHARA_CONF_FILE keystone_authtoken admin_user sahara
110 iniset $SAHARA_CONF_FILE keystone_authtoken admin_password $SERVICE_PASSWORD
111 iniset $SAHARA_CONF_FILE keystone_authtoken signing_dir $SAHARA_AUTH_CACHE_DIR
112 iniset $SAHARA_CONF_FILE keystone_authtoken cafile $KEYSTONE_SSL_CA
113
Sergey Lukjanov3cd59e12014-03-25 00:06:31 +0400114 iniset $SAHARA_CONF_FILE DEFAULT verbose True
115 iniset $SAHARA_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400116
Sergey Lukjanov10f41612014-04-25 11:42:41 +0400117 iniset $SAHARA_CONF_FILE DEFAULT plugins $SAHARA_ENABLED_PLUGINS
118
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400119 iniset $SAHARA_CONF_FILE database connection `database_connection_url sahara`
120
121 if is_service_enabled neutron; then
122 iniset $SAHARA_CONF_FILE DEFAULT use_neutron true
123 iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips true
124 fi
125
126 if is_service_enabled heat; then
127 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine heat
128 else
129 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine direct
130 fi
131
132 iniset $SAHARA_CONF_FILE DEFAULT use_syslog $SYSLOG
133
Luigi Toscanob4bef1f2014-04-03 19:24:57 +0200134 # Format logging
135 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
136 setup_colorized_logging $SAHARA_CONF_FILE DEFAULT
137 fi
138
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400139 recreate_database sahara utf8
140 $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head
141}
142
143# install_sahara() - Collect source and prepare
144function install_sahara {
145 git_clone $SAHARA_REPO $SAHARA_DIR $SAHARA_BRANCH
146 setup_develop $SAHARA_DIR
147}
148
149# start_sahara() - Start running processes, including screen
150function start_sahara {
Sergey Lukjanov850e0fb2014-05-03 00:53:01 +0400151 screen_it sahara "cd $SAHARA_DIR && $SAHARA_BIN_DIR/sahara-all --config-file $SAHARA_CONF_FILE"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400152}
153
154# stop_sahara() - Stop running processes
155function stop_sahara {
156 # Kill the Sahara screen windows
157 screen -S $SCREEN_NAME -p sahara -X kill
158}
159
160
161# Restore xtrace
162$XTRACE
163
164# Local variables:
165# mode: shell-script
166# End: