blob: 79cd8bd9c258f1b3510eb31e5aa6eb66e0b519b2 [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
Vitaly Gridneve50fcb12014-08-11 12:01:12 +0000114 # Set configuration to send notifications
115
116 if is_service_enabled ceilometer; then
117 iniset $SAHARA_CONF_FILE DEFAULT enable_notifications "true"
118 iniset $SAHARA_CONF_FILE DEFAULT notification_driver "messaging"
119 iniset_rpc_backend sahara $SAHARA_CONF_FILE DEFAULT
120 fi
121
Sergey Lukjanov3cd59e12014-03-25 00:06:31 +0400122 iniset $SAHARA_CONF_FILE DEFAULT verbose True
123 iniset $SAHARA_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400124
Sergey Lukjanov10f41612014-04-25 11:42:41 +0400125 iniset $SAHARA_CONF_FILE DEFAULT plugins $SAHARA_ENABLED_PLUGINS
126
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400127 iniset $SAHARA_CONF_FILE database connection `database_connection_url sahara`
128
129 if is_service_enabled neutron; then
130 iniset $SAHARA_CONF_FILE DEFAULT use_neutron true
131 iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips true
132 fi
133
134 if is_service_enabled heat; then
135 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine heat
136 else
137 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine direct
138 fi
139
140 iniset $SAHARA_CONF_FILE DEFAULT use_syslog $SYSLOG
141
Luigi Toscanob4bef1f2014-04-03 19:24:57 +0200142 # Format logging
143 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
144 setup_colorized_logging $SAHARA_CONF_FILE DEFAULT
145 fi
146
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400147 recreate_database sahara utf8
148 $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head
149}
150
151# install_sahara() - Collect source and prepare
152function install_sahara {
153 git_clone $SAHARA_REPO $SAHARA_DIR $SAHARA_BRANCH
154 setup_develop $SAHARA_DIR
155}
156
157# start_sahara() - Start running processes, including screen
158function start_sahara {
Sergey Lukjanov850e0fb2014-05-03 00:53:01 +0400159 screen_it sahara "cd $SAHARA_DIR && $SAHARA_BIN_DIR/sahara-all --config-file $SAHARA_CONF_FILE"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400160}
161
162# stop_sahara() - Stop running processes
163function stop_sahara {
164 # Kill the Sahara screen windows
165 screen -S $SCREEN_NAME -p sahara -X kill
166}
167
168
169# Restore xtrace
170$XTRACE
171
172# Local variables:
173# mode: shell-script
174# End: