Browse code

Catalog Index Service - glance devstack

Implements: blueprint catalog-index-service

The changes to lib/glance incorporate the new g-search service.
The g-search service is optional.
To enable it add the following line to devstack/local.conf:
enable_service g-search

In addition to deploying g-search, the changes will also populate a
search type of keystone service and adds in appropriate endpoints.

Change-Id: I0272d56bc2e50e8174db78bd449f65f60f7f4000

Wayne Okuma authored on 2015/03/31 16:28:39
Showing 2 changed files
... ...
@@ -49,8 +49,10 @@ GLANCE_CONF_DIR=${GLANCE_CONF_DIR:-/etc/glance}
49 49
 GLANCE_METADEF_DIR=$GLANCE_CONF_DIR/metadefs
50 50
 GLANCE_REGISTRY_CONF=$GLANCE_CONF_DIR/glance-registry.conf
51 51
 GLANCE_API_CONF=$GLANCE_CONF_DIR/glance-api.conf
52
+GLANCE_SEARCH_CONF=$GLANCE_CONF_DIR/glance-search.conf
52 53
 GLANCE_REGISTRY_PASTE_INI=$GLANCE_CONF_DIR/glance-registry-paste.ini
53 54
 GLANCE_API_PASTE_INI=$GLANCE_CONF_DIR/glance-api-paste.ini
55
+GLANCE_SEARCH_PASTE_INI=$GLANCE_CONF_DIR/glance-search-paste.ini
54 56
 GLANCE_CACHE_CONF=$GLANCE_CONF_DIR/glance-cache.conf
55 57
 GLANCE_POLICY_JSON=$GLANCE_CONF_DIR/policy.json
56 58
 GLANCE_SCHEMA_JSON=$GLANCE_CONF_DIR/schema-image.json
... ...
@@ -67,6 +69,9 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$GLANCE_SERVICE_HOST:$GLANCE_SERVICE_PORT}
67 67
 GLANCE_SERVICE_PROTOCOL=${GLANCE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
68 68
 GLANCE_REGISTRY_PORT=${GLANCE_REGISTRY_PORT:-9191}
69 69
 GLANCE_REGISTRY_PORT_INT=${GLANCE_REGISTRY_PORT_INT:-19191}
70
+GLANCE_SEARCH_PORT=${GLANCE_SEARCH_PORT:-9393}
71
+GLANCE_SEARCH_PORT_INT=${GLANCE_SEARCH_PORT_INT:-19393}
72
+GLANCE_SEARCH_HOSTPORT=${GLANCE_SEARCH_HOSTPORT:-$GLANCE_SERVICE_HOST:$GLANCE_SEARCH_PORT}
70 73
 
71 74
 # Tell Tempest this project is present
72 75
 TEMPEST_SERVICES+=,glance
... ...
@@ -87,6 +92,10 @@ function cleanup_glance {
87 87
     # kill instances (nova)
88 88
     # delete image files (glance)
89 89
     sudo rm -rf $GLANCE_CACHE_DIR $GLANCE_IMAGE_DIR $GLANCE_AUTH_CACHE_DIR
90
+
91
+    if is_service_enabled g-search; then
92
+        ${TOP_DIR}/pkg/elasticsearch.sh stop
93
+    fi
90 94
 }
91 95
 
92 96
 # configure_glance() - Set config files, create data dirs, etc
... ...
@@ -218,14 +227,38 @@ function configure_glance {
218 218
         iniset $GLANCE_API_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/%(project_id)s"
219 219
         iniset $GLANCE_CACHE_CONF DEFAULT cinder_endpoint_template "https://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/%(project_id)s"
220 220
     fi
221
+
222
+    # Configure search
223
+    if is_service_enabled g-search; then
224
+        cp $GLANCE_DIR/etc/glance-search.conf $GLANCE_SEARCH_CONF
225
+        iniset $GLANCE_SEARCH_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
226
+        inicomment $GLANCE_SEARCH_CONF DEFAULT log_file
227
+        iniset $GLANCE_SEARCH_CONF DEFAULT use_syslog $SYSLOG
228
+        iniset $GLANCE_SEARCH_CONF DEFAULT sql_connection $dburl
229
+        iniset $GLANCE_SEARCH_CONF paste_deploy flavor keystone
230
+        configure_auth_token_middleware $GLANCE_SEARCH_CONF glance $GLANCE_AUTH_CACHE_DIR/search
231
+
232
+        if is_service_enabled tls-proxy; then
233
+            iniset $GLANCE_SEARCH_CONF DEFAULT bind_port $GLANCE_SEARCH_PORT_INT
234
+        fi
235
+        # Register SSL certificates if provided
236
+        if is_ssl_enabled_service glance; then
237
+            ensure_certificates GLANCE
238
+            iniset $GLANCE_SEARCH_CONF DEFAULT cert_file "$GLANCE_SSL_CERT"
239
+            iniset $GLANCE_SEARCH_CONF DEFAULT key_file "$GLANCE_SSL_KEY"
240
+        fi
241
+
242
+        cp $GLANCE_DIR/etc/glance-search-paste.ini $GLANCE_SEARCH_PASTE_INI
243
+    fi
221 244
 }
222 245
 
223 246
 # create_glance_accounts() - Set up common required glance accounts
224 247
 
225
-# Project              User         Roles
226
-# ------------------------------------------------------------------
227
-# SERVICE_TENANT_NAME  glance       service
228
-# SERVICE_TENANT_NAME  glance-swift ResellerAdmin (if Swift is enabled)
248
+# Project              User            Roles
249
+# ---------------------------------------------------------------------
250
+# SERVICE_TENANT_NAME  glance          service
251
+# SERVICE_TENANT_NAME  glance-swift    ResellerAdmin (if Swift is enabled)
252
+# SERVICE_TENANT_NAME  glance-search   search (if Search is enabled)
229 253
 
230 254
 function create_glance_accounts {
231 255
     if is_service_enabled g-api; then
... ...
@@ -251,13 +284,27 @@ function create_glance_accounts {
251 251
                 "$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT"
252 252
         fi
253 253
     fi
254
+
255
+    # Add glance-search service and endpoints
256
+    if is_service_enabled g-search; then
257
+        if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
258
+            local glance_search_service=$(get_or_create_service "glance-search" \
259
+                "search" "EXPERIMENTAL - Glance Graffiti Search Service")
260
+
261
+            get_or_create_endpoint $glance_search_service \
262
+                "$REGION_NAME" \
263
+                "$GLANCE_SERVICE_PROTOCOL://$GLANCE_SEARCH_HOSTPORT" \
264
+                "$GLANCE_SERVICE_PROTOCOL://$GLANCE_SEARCH_HOSTPORT" \
265
+                "$GLANCE_SERVICE_PROTOCOL://$GLANCE_SEARCH_HOSTPORT"
266
+        fi
267
+    fi
254 268
 }
255 269
 
256 270
 # create_glance_cache_dir() - Part of the init_glance() process
257 271
 function create_glance_cache_dir {
258 272
     # Create cache dir
259
-    sudo install -d -o $STACK_USER $GLANCE_AUTH_CACHE_DIR/api $GLANCE_AUTH_CACHE_DIR/registry
260
-    rm -f $GLANCE_AUTH_CACHE_DIR/api/* $GLANCE_AUTH_CACHE_DIR/registry/*
273
+    sudo install -d -o $STACK_USER $GLANCE_AUTH_CACHE_DIR/api $GLANCE_AUTH_CACHE_DIR/registry $GLANCE_AUTH_CACHE_DIR/search
274
+    rm -f $GLANCE_AUTH_CACHE_DIR/api/* $GLANCE_AUTH_CACHE_DIR/registry/* $GLANCE_AUTH_CACHE_DIR/search/*
261 275
 }
262 276
 
263 277
 # init_glance() - Initialize databases, etc.
... ...
@@ -280,6 +327,12 @@ function init_glance {
280 280
     $GLANCE_BIN_DIR/glance-manage db_load_metadefs
281 281
 
282 282
     create_glance_cache_dir
283
+
284
+    # Init glance search by exporting found metadefs/images to elasticsearch
285
+    if is_service_enabled g-search; then
286
+        ${TOP_DIR}/pkg/elasticsearch.sh start
287
+        $GLANCE_BIN_DIR/glance-index
288
+    fi
283 289
 }
284 290
 
285 291
 # install_glanceclient() - Collect source and prepare
... ...
@@ -301,11 +354,13 @@ function install_glance {
301 301
     fi
302 302
 
303 303
     git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH
304
-    setup_develop $GLANCE_DIR
305
-    if is_service_enabled g-graffiti; then
304
+
305
+    if is_service_enabled g-search; then
306 306
         ${TOP_DIR}/pkg/elasticsearch.sh download
307 307
         ${TOP_DIR}/pkg/elasticsearch.sh install
308 308
     fi
309
+
310
+    setup_develop $GLANCE_DIR
309 311
 }
310 312
 
311 313
 # start_glance() - Start running processes, including screen
... ...
@@ -314,18 +369,29 @@ function start_glance {
314 314
     if is_service_enabled tls-proxy; then
315 315
         start_tls_proxy '*' $GLANCE_SERVICE_PORT $GLANCE_SERVICE_HOST $GLANCE_SERVICE_PORT_INT &
316 316
         start_tls_proxy '*' $GLANCE_REGISTRY_PORT $GLANCE_SERVICE_HOST $GLANCE_REGISTRY_PORT_INT &
317
+
318
+        # Handle g-search
319
+        if is_service_enabled g-search; then
320
+            start_tls_proxy '*' $GLANCE_SEARCH_PORT $GLANCE_SERVICE_HOST $GLANCE_SEARCH_PORT_INT &
321
+        fi
317 322
     fi
318 323
 
319 324
     run_process g-reg "$GLANCE_BIN_DIR/glance-registry --config-file=$GLANCE_CONF_DIR/glance-registry.conf"
320 325
     run_process g-api "$GLANCE_BIN_DIR/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf"
321 326
 
322
-    if is_service_enabled g-graffiti; then
323
-        ${TOP_DIR}/pkg/elasticsearch.sh start
324
-    fi
325 327
     echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
326 328
     if ! wait_for_service $SERVICE_TIMEOUT $GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT; then
327 329
         die $LINENO "g-api did not start"
328 330
     fi
331
+
332
+    # Start g-search after g-reg/g-api
333
+    if is_service_enabled g-search; then
334
+        run_process g-search "$GLANCE_BIN_DIR/glance-search --config-file=$GLANCE_CONF_DIR/glance-search.conf"
335
+        echo "Waiting for g-search ($GLANCE_SEARCH_HOSTPORT) to start..."
336
+        if ! wait_for_service $SERVICE_TIMEOUT $GLANCE_SERVICE_PROTOCOL://$GLANCE_SEARCH_HOSTPORT; then
337
+            die $LINENO "g-search did not start"
338
+        fi
339
+    fi
329 340
 }
330 341
 
331 342
 # stop_glance() - Stop running processes
... ...
@@ -333,6 +399,10 @@ function stop_glance {
333 333
     # Kill the Glance screen windows
334 334
     stop_process g-api
335 335
     stop_process g-reg
336
+
337
+    if is_service_enabled g-search; then
338
+        stop_process g-search
339
+    fi
336 340
 }
337 341
 
338 342
 # Restore xtrace
... ...
@@ -7,6 +7,8 @@
7 7
 TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
8 8
 FILES=$TOP_DIR/files
9 9
 source $TOP_DIR/functions
10
+DEST=${DEST:-/opt/stack}
11
+source $TOP_DIR/lib/infra
10 12
 
11 13
 # Package source and version, all pkg files are expected to have
12 14
 # something like this, as well as a way to override them.