blob: 4f1ba22c671b62eee2a74c7054cf81989cf53d18 [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
Sergey Lukjanova90898d2014-08-05 16:14:12 +040010# install_python_saharaclient
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040011# configure_sahara
12# start_sahara
13# stop_sahara
14# cleanup_sahara
15
16# Save trace setting
17XTRACE=$(set +o | grep xtrace)
18set +o xtrace
19
20
21# Defaults
22# --------
23
24# Set up default repos
Sergey Lukjanova90898d2014-08-05 16:14:12 +040025
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040026# Set up default directories
Sean Dagueee5ae7b2014-11-13 13:23:27 -050027GITDIR["python-saharaclient"]=$DEST/python-saharaclient
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040028SAHARA_DIR=$DEST/sahara
Sergey Lukjanova90898d2014-08-05 16:14:12 +040029
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040030SAHARA_CONF_DIR=${SAHARA_CONF_DIR:-/etc/sahara}
31SAHARA_CONF_FILE=${SAHARA_CONF_DIR}/sahara.conf
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040032
33SAHARA_SERVICE_HOST=${SAHARA_SERVICE_HOST:-$SERVICE_HOST}
34SAHARA_SERVICE_PORT=${SAHARA_SERVICE_PORT:-8386}
35SAHARA_SERVICE_PROTOCOL=${SAHARA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
36
37SAHARA_AUTH_CACHE_DIR=${SAHARA_AUTH_CACHE_DIR:-/var/cache/sahara}
38
Sergey Lukjanov10f41612014-04-25 11:42:41 +040039SAHARA_ENABLED_PLUGINS=${SAHARA_ENABLED_PLUGINS:-vanilla,hdp,fake}
40
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040041# Support entry points installation of console scripts
42if [[ -d $SAHARA_DIR/bin ]]; then
43 SAHARA_BIN_DIR=$SAHARA_DIR/bin
44else
45 SAHARA_BIN_DIR=$(get_python_exec_prefix)
46fi
47
48# Tell Tempest this project is present
49TEMPEST_SERVICES+=,sahara
50
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040051# Functions
52# ---------
53
54# create_sahara_accounts() - Set up common required sahara accounts
55#
56# Tenant User Roles
57# ------------------------------
58# service sahara admin
59function create_sahara_accounts {
60
Dean Troyer16ef9762014-08-19 19:31:34 -050061 local service_tenant=$(openstack project list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
62 local admin_role=$(openstack role list | awk "/ admin / { print \$2 }")
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040063
Dean Troyer16ef9762014-08-19 19:31:34 -050064 local sahara_user=$(get_or_create_user "sahara" \
65 "$SERVICE_PASSWORD" $service_tenant)
66 get_or_add_user_role $admin_role $sahara_user $service_tenant
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040067
68 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
Bartosz Górski0abde392014-02-28 14:15:19 +010069
Dean Troyer16ef9762014-08-19 19:31:34 -050070 local sahara_service=$(get_or_create_service "sahara" \
Bartosz Górski0abde392014-02-28 14:15:19 +010071 "data_processing" "Sahara Data Processing")
Dean Troyer16ef9762014-08-19 19:31:34 -050072 get_or_create_endpoint $sahara_service \
Bartosz Górski0abde392014-02-28 14:15:19 +010073 "$REGION_NAME" \
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" \
76 "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +040077 fi
78}
79
80# cleanup_sahara() - Remove residual data files, anything left over from
81# previous runs that would need to clean up.
82function cleanup_sahara {
83
84 # Cleanup auth cache dir
85 sudo rm -rf $SAHARA_AUTH_CACHE_DIR
86}
87
88# configure_sahara() - Set config files, create data dirs, etc
89function configure_sahara {
90
91 if [[ ! -d $SAHARA_CONF_DIR ]]; then
92 sudo mkdir -p $SAHARA_CONF_DIR
93 fi
94 sudo chown $STACK_USER $SAHARA_CONF_DIR
95
Andrew Lazarev627ca742014-10-29 17:01:15 -070096 if [[ -f $SAHARA_DIR/etc/sahara/policy.json ]]; then
97 cp -p $SAHARA_DIR/etc/sahara/policy.json $SAHARA_CONF_DIR
98 fi
99
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400100 # Copy over sahara configuration file and configure common parameters.
Sergey Lukjanov51ebda62014-03-12 22:26:12 +0400101 cp $SAHARA_DIR/etc/sahara/sahara.conf.sample $SAHARA_CONF_FILE
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400102
103 # Create auth cache dir
104 sudo mkdir -p $SAHARA_AUTH_CACHE_DIR
105 sudo chown $STACK_USER $SAHARA_AUTH_CACHE_DIR
Andrew Lazarev28d43922014-10-29 17:25:12 -0700106 sudo chmod 700 $SAHARA_AUTH_CACHE_DIR
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400107 rm -rf $SAHARA_AUTH_CACHE_DIR/*
108
Brant Knudson05952372014-09-19 17:22:22 -0500109 configure_auth_token_middleware $SAHARA_CONF_FILE sahara $SAHARA_AUTH_CACHE_DIR
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400110
Vitaly Gridneve50fcb12014-08-11 12:01:12 +0000111 # Set configuration to send notifications
112
113 if is_service_enabled ceilometer; then
114 iniset $SAHARA_CONF_FILE DEFAULT enable_notifications "true"
115 iniset $SAHARA_CONF_FILE DEFAULT notification_driver "messaging"
116 iniset_rpc_backend sahara $SAHARA_CONF_FILE DEFAULT
117 fi
118
Sergey Lukjanov3cd59e12014-03-25 00:06:31 +0400119 iniset $SAHARA_CONF_FILE DEFAULT verbose True
120 iniset $SAHARA_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400121
Sergey Lukjanov10f41612014-04-25 11:42:41 +0400122 iniset $SAHARA_CONF_FILE DEFAULT plugins $SAHARA_ENABLED_PLUGINS
123
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400124 iniset $SAHARA_CONF_FILE database connection `database_connection_url sahara`
125
126 if is_service_enabled neutron; then
127 iniset $SAHARA_CONF_FILE DEFAULT use_neutron true
128 iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips true
129 fi
130
131 if is_service_enabled heat; then
132 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine heat
133 else
134 iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine direct
135 fi
136
137 iniset $SAHARA_CONF_FILE DEFAULT use_syslog $SYSLOG
138
Luigi Toscanob4bef1f2014-04-03 19:24:57 +0200139 # Format logging
140 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
141 setup_colorized_logging $SAHARA_CONF_FILE DEFAULT
142 fi
143
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400144 recreate_database sahara utf8
145 $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head
146}
147
148# install_sahara() - Collect source and prepare
149function install_sahara {
150 git_clone $SAHARA_REPO $SAHARA_DIR $SAHARA_BRANCH
151 setup_develop $SAHARA_DIR
152}
153
Sergey Lukjanova90898d2014-08-05 16:14:12 +0400154# install_python_saharaclient() - Collect source and prepare
155function install_python_saharaclient {
Sean Dagueee5ae7b2014-11-13 13:23:27 -0500156 if use_library_from_git "python-saharaclient"; then
157 git_clone_by_name "python-saharaclient"
158 setup_dev_lib "python-saharaclient"
159 fi
Sergey Lukjanova90898d2014-08-05 16:14:12 +0400160}
161
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400162# start_sahara() - Start running processes, including screen
163function start_sahara {
Chris Dent2f27a0e2014-09-09 13:46:02 +0100164 run_process sahara "$SAHARA_BIN_DIR/sahara-all --config-file $SAHARA_CONF_FILE"
Sergey Lukjanov7ff84432014-03-10 20:04:51 +0400165}
166
167# stop_sahara() - Stop running processes
168function stop_sahara {
169 # Kill the Sahara screen windows
170 screen -S $SCREEN_NAME -p sahara -X kill
171}
172
173
174# Restore xtrace
175$XTRACE
176
177# Local variables:
178# mode: shell-script
179# End: