Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 3 | # lib/sahara |
| 4 | |
| 5 | # Dependencies: |
| 6 | # ``functions`` file |
| 7 | # ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined |
| 8 | |
| 9 | # ``stack.sh`` calls the entry points in this order: |
| 10 | # |
| 11 | # install_sahara |
Sergey Lukjanov | a90898d | 2014-08-05 16:14:12 +0400 | [diff] [blame] | 12 | # install_python_saharaclient |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 13 | # configure_sahara |
Andrew Lazarev | b313048 | 2014-12-16 14:36:59 -0800 | [diff] [blame] | 14 | # sahara_register_images |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 15 | # start_sahara |
| 16 | # stop_sahara |
| 17 | # cleanup_sahara |
| 18 | |
| 19 | # Save trace setting |
| 20 | XTRACE=$(set +o | grep xtrace) |
| 21 | set +o xtrace |
| 22 | |
| 23 | |
| 24 | # Defaults |
| 25 | # -------- |
| 26 | |
| 27 | # Set up default repos |
Sergey Lukjanov | a90898d | 2014-08-05 16:14:12 +0400 | [diff] [blame] | 28 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 29 | # Set up default directories |
Sean Dague | ee5ae7b | 2014-11-13 13:23:27 -0500 | [diff] [blame] | 30 | GITDIR["python-saharaclient"]=$DEST/python-saharaclient |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 31 | SAHARA_DIR=$DEST/sahara |
Sergey Lukjanov | a90898d | 2014-08-05 16:14:12 +0400 | [diff] [blame] | 32 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 33 | SAHARA_CONF_DIR=${SAHARA_CONF_DIR:-/etc/sahara} |
| 34 | SAHARA_CONF_FILE=${SAHARA_CONF_DIR}/sahara.conf |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 35 | |
| 36 | SAHARA_SERVICE_HOST=${SAHARA_SERVICE_HOST:-$SERVICE_HOST} |
| 37 | SAHARA_SERVICE_PORT=${SAHARA_SERVICE_PORT:-8386} |
| 38 | SAHARA_SERVICE_PROTOCOL=${SAHARA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} |
| 39 | |
| 40 | SAHARA_AUTH_CACHE_DIR=${SAHARA_AUTH_CACHE_DIR:-/var/cache/sahara} |
| 41 | |
Sergey Reshetnyak | 32ac55a | 2015-02-25 15:54:20 +0300 | [diff] [blame] | 42 | SAHARA_ENABLED_PLUGINS=${SAHARA_ENABLED_PLUGINS:-vanilla,hdp,cdh,spark,fake} |
Sergey Lukjanov | 10f4161 | 2014-04-25 11:42:41 +0400 | [diff] [blame] | 43 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 44 | # Support entry points installation of console scripts |
| 45 | if [[ -d $SAHARA_DIR/bin ]]; then |
| 46 | SAHARA_BIN_DIR=$SAHARA_DIR/bin |
| 47 | else |
| 48 | SAHARA_BIN_DIR=$(get_python_exec_prefix) |
| 49 | fi |
| 50 | |
| 51 | # Tell Tempest this project is present |
| 52 | TEMPEST_SERVICES+=,sahara |
| 53 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 54 | # Functions |
| 55 | # --------- |
| 56 | |
| 57 | # create_sahara_accounts() - Set up common required sahara accounts |
| 58 | # |
| 59 | # Tenant User Roles |
| 60 | # ------------------------------ |
| 61 | # service sahara admin |
| 62 | function create_sahara_accounts { |
| 63 | |
Jamie Lennox | e8bc2b8 | 2015-02-10 20:38:56 +1100 | [diff] [blame] | 64 | create_service_user "sahara" |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 65 | |
| 66 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 67 | |
Telles Nobrega | 37a06f0 | 2014-11-18 07:59:10 -0300 | [diff] [blame] | 68 | # TODO: remove "data_processing" service when #1356053 will be fixed |
| 69 | local sahara_service_old=$(openstack service create \ |
| 70 | "data_processing" \ |
| 71 | --name "sahara" \ |
| 72 | --description "Sahara Data Processing" \ |
| 73 | -f value -c id |
| 74 | ) |
| 75 | local sahara_service_new=$(openstack service create \ |
| 76 | "data-processing" \ |
| 77 | --name "sahara" \ |
| 78 | --description "Sahara Data Processing" \ |
| 79 | -f value -c id |
| 80 | ) |
| 81 | get_or_create_endpoint $sahara_service_old \ |
| 82 | "$REGION_NAME" \ |
| 83 | "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \ |
| 84 | "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \ |
| 85 | "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" |
| 86 | get_or_create_endpoint $sahara_service_new \ |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 87 | "$REGION_NAME" \ |
| 88 | "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \ |
| 89 | "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" \ |
| 90 | "$SAHARA_SERVICE_PROTOCOL://$SAHARA_SERVICE_HOST:$SAHARA_SERVICE_PORT/v1.1/\$(tenant_id)s" |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 91 | fi |
| 92 | } |
| 93 | |
| 94 | # cleanup_sahara() - Remove residual data files, anything left over from |
| 95 | # previous runs that would need to clean up. |
| 96 | function cleanup_sahara { |
| 97 | |
| 98 | # Cleanup auth cache dir |
| 99 | sudo rm -rf $SAHARA_AUTH_CACHE_DIR |
| 100 | } |
| 101 | |
| 102 | # configure_sahara() - Set config files, create data dirs, etc |
| 103 | function configure_sahara { |
| 104 | |
| 105 | if [[ ! -d $SAHARA_CONF_DIR ]]; then |
| 106 | sudo mkdir -p $SAHARA_CONF_DIR |
| 107 | fi |
| 108 | sudo chown $STACK_USER $SAHARA_CONF_DIR |
| 109 | |
Andrew Lazarev | 627ca74 | 2014-10-29 17:01:15 -0700 | [diff] [blame] | 110 | if [[ -f $SAHARA_DIR/etc/sahara/policy.json ]]; then |
| 111 | cp -p $SAHARA_DIR/etc/sahara/policy.json $SAHARA_CONF_DIR |
| 112 | fi |
| 113 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 114 | # Copy over sahara configuration file and configure common parameters. |
Sergey Lukjanov | 51ebda6 | 2014-03-12 22:26:12 +0400 | [diff] [blame] | 115 | cp $SAHARA_DIR/etc/sahara/sahara.conf.sample $SAHARA_CONF_FILE |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 116 | |
| 117 | # Create auth cache dir |
| 118 | sudo mkdir -p $SAHARA_AUTH_CACHE_DIR |
| 119 | sudo chown $STACK_USER $SAHARA_AUTH_CACHE_DIR |
Andrew Lazarev | 28d4392 | 2014-10-29 17:25:12 -0700 | [diff] [blame] | 120 | sudo chmod 700 $SAHARA_AUTH_CACHE_DIR |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 121 | rm -rf $SAHARA_AUTH_CACHE_DIR/* |
| 122 | |
Brant Knudson | 0595237 | 2014-09-19 17:22:22 -0500 | [diff] [blame] | 123 | configure_auth_token_middleware $SAHARA_CONF_FILE sahara $SAHARA_AUTH_CACHE_DIR |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 124 | |
Vitaly Gridnev | e50fcb1 | 2014-08-11 12:01:12 +0000 | [diff] [blame] | 125 | # Set configuration to send notifications |
| 126 | |
| 127 | if is_service_enabled ceilometer; then |
| 128 | iniset $SAHARA_CONF_FILE DEFAULT enable_notifications "true" |
| 129 | iniset $SAHARA_CONF_FILE DEFAULT notification_driver "messaging" |
| 130 | iniset_rpc_backend sahara $SAHARA_CONF_FILE DEFAULT |
| 131 | fi |
| 132 | |
Sergey Lukjanov | 3cd59e1 | 2014-03-25 00:06:31 +0400 | [diff] [blame] | 133 | iniset $SAHARA_CONF_FILE DEFAULT verbose True |
| 134 | iniset $SAHARA_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 135 | |
Sergey Lukjanov | 10f4161 | 2014-04-25 11:42:41 +0400 | [diff] [blame] | 136 | iniset $SAHARA_CONF_FILE DEFAULT plugins $SAHARA_ENABLED_PLUGINS |
| 137 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 138 | iniset $SAHARA_CONF_FILE database connection `database_connection_url sahara` |
| 139 | |
| 140 | if is_service_enabled neutron; then |
| 141 | iniset $SAHARA_CONF_FILE DEFAULT use_neutron true |
| 142 | iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips true |
Andrew Lazarev | 4f7e0f2 | 2015-02-06 16:16:01 -0800 | [diff] [blame] | 143 | |
| 144 | if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then |
| 145 | iniset $SAHARA_CONF_FILE neutron ca_file $SSL_BUNDLE_FILE |
| 146 | fi |
Andrew Lazarev | 0943e07 | 2014-12-17 16:07:32 -0800 | [diff] [blame] | 147 | else |
| 148 | iniset $SAHARA_CONF_FILE DEFAULT use_neutron false |
| 149 | iniset $SAHARA_CONF_FILE DEFAULT use_floating_ips false |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 150 | fi |
| 151 | |
| 152 | if is_service_enabled heat; then |
| 153 | iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine heat |
Andrew Lazarev | 4f7e0f2 | 2015-02-06 16:16:01 -0800 | [diff] [blame] | 154 | |
| 155 | if is_ssl_enabled_service "heat" || is_service_enabled tls-proxy; then |
| 156 | iniset $SAHARA_CONF_FILE heat ca_file $SSL_BUNDLE_FILE |
| 157 | fi |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 158 | else |
| 159 | iniset $SAHARA_CONF_FILE DEFAULT infrastructure_engine direct |
| 160 | fi |
| 161 | |
Andrew Lazarev | 4f7e0f2 | 2015-02-06 16:16:01 -0800 | [diff] [blame] | 162 | if is_ssl_enabled_service "cinder" || is_service_enabled tls-proxy; then |
| 163 | iniset $SAHARA_CONF_FILE cinder ca_file $SSL_BUNDLE_FILE |
| 164 | fi |
| 165 | |
| 166 | if is_ssl_enabled_service "nova" || is_service_enabled tls-proxy; then |
| 167 | iniset $SAHARA_CONF_FILE nova ca_file $SSL_BUNDLE_FILE |
| 168 | fi |
| 169 | |
| 170 | if is_ssl_enabled_service "swift" || is_service_enabled tls-proxy; then |
| 171 | iniset $SAHARA_CONF_FILE swift ca_file $SSL_BUNDLE_FILE |
| 172 | fi |
| 173 | |
| 174 | if is_ssl_enabled_service "key" || is_service_enabled tls-proxy; then |
| 175 | iniset $SAHARA_CONF_FILE keystone ca_file $SSL_BUNDLE_FILE |
| 176 | fi |
| 177 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 178 | iniset $SAHARA_CONF_FILE DEFAULT use_syslog $SYSLOG |
| 179 | |
Luigi Toscano | b4bef1f | 2014-04-03 19:24:57 +0200 | [diff] [blame] | 180 | # Format logging |
| 181 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then |
| 182 | setup_colorized_logging $SAHARA_CONF_FILE DEFAULT |
| 183 | fi |
| 184 | |
Ihar Hrachyshka | 157c84b | 2014-10-06 13:29:39 +0200 | [diff] [blame] | 185 | recreate_database sahara |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 186 | $SAHARA_BIN_DIR/sahara-db-manage --config-file $SAHARA_CONF_FILE upgrade head |
| 187 | } |
| 188 | |
| 189 | # install_sahara() - Collect source and prepare |
| 190 | function install_sahara { |
| 191 | git_clone $SAHARA_REPO $SAHARA_DIR $SAHARA_BRANCH |
| 192 | setup_develop $SAHARA_DIR |
| 193 | } |
| 194 | |
Sergey Lukjanov | a90898d | 2014-08-05 16:14:12 +0400 | [diff] [blame] | 195 | # install_python_saharaclient() - Collect source and prepare |
| 196 | function install_python_saharaclient { |
Sean Dague | ee5ae7b | 2014-11-13 13:23:27 -0500 | [diff] [blame] | 197 | if use_library_from_git "python-saharaclient"; then |
| 198 | git_clone_by_name "python-saharaclient" |
| 199 | setup_dev_lib "python-saharaclient" |
| 200 | fi |
Sergey Lukjanov | a90898d | 2014-08-05 16:14:12 +0400 | [diff] [blame] | 201 | } |
| 202 | |
Andrew Lazarev | b313048 | 2014-12-16 14:36:59 -0800 | [diff] [blame] | 203 | # sahara_register_images() - Registers images in sahara image registry |
| 204 | function sahara_register_images { |
| 205 | if is_service_enabled heat && [[ ! -z "$HEAT_CFN_IMAGE_URL" ]]; then |
| 206 | # Register heat image for Fake plugin |
| 207 | local fake_plugin_properties="--property _sahara_tag_0.1=True" |
| 208 | fake_plugin_properties+=" --property _sahara_tag_fake=True" |
| 209 | fake_plugin_properties+=" --property _sahara_username=fedora" |
| 210 | openstack --os-url $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT image set $(basename "$HEAT_CFN_IMAGE_URL" ".qcow2") $fake_plugin_properties |
| 211 | fi |
| 212 | } |
| 213 | |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 214 | # start_sahara() - Start running processes, including screen |
| 215 | function start_sahara { |
Chris Dent | 2f27a0e | 2014-09-09 13:46:02 +0100 | [diff] [blame] | 216 | run_process sahara "$SAHARA_BIN_DIR/sahara-all --config-file $SAHARA_CONF_FILE" |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | # stop_sahara() - Stop running processes |
| 220 | function stop_sahara { |
| 221 | # Kill the Sahara screen windows |
Sean Dague | 9a413ab | 2015-02-04 12:44:18 -0500 | [diff] [blame] | 222 | stop_process sahara |
Sergey Lukjanov | 7ff8443 | 2014-03-10 20:04:51 +0400 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | |
| 226 | # Restore xtrace |
| 227 | $XTRACE |
| 228 | |
| 229 | # Local variables: |
| 230 | # mode: shell-script |
| 231 | # End: |