Browse code

Don't check for existing endpoints

We really should only have code that create endpoints once, making all
osc calls get_or_set adds 3 seconds per call for no really good
reason.

This also stops creating the internal endpoints in the service
catalog. It's a pattern that we're trying not to propogate, so lets
not have it in devstack any more.

Change-Id: Ia8cefe43753900d62117beae330db46deb6a9fc9

Sean Dague authored on 2016/04/22 22:19:10
Showing 7 changed files
... ...
@@ -987,38 +987,35 @@ function get_or_create_service {
987 987
 }
988 988
 
989 989
 # Create an endpoint with a specific interface
990
-# Usage: _get_or_create_endpoint_with_interface <service> <interface> <url> <region>
991
-function _get_or_create_endpoint_with_interface {
990
+# Usage: _create_endpoint_with_interface <service> <interface> <url> <region>
991
+function _create_endpoint_with_interface {
992
+    # Creates new endpoint
992 993
     local endpoint_id
993
-    endpoint_id=$(openstack endpoint list \
994
-        --service $1 \
995
-        --interface $2 \
996
-        --region $4 \
997
-        -c ID -f value)
998
-    if [[ -z "$endpoint_id" ]]; then
999
-        # Creates new endpoint
1000
-        endpoint_id=$(openstack endpoint create \
1001
-            $1 $2 $3 --region $4 -f value -c id)
1002
-    fi
1003
-
994
+    endpoint_id=$(openstack endpoint create \
995
+                            $1 $2 $3 --region $4 -f value -c id)
1004 996
     echo $endpoint_id
1005 997
 }
1006 998
 
1007
-# Gets or creates endpoint
1008
-# Usage: get_or_create_endpoint <service> <region> <publicurl> <adminurl> <internalurl>
999
+# TODO(sdague): remove in O
1009 1000
 function get_or_create_endpoint {
1001
+    deprecated "get_or_create_endpoint is deprecated. Use create_endpoint instead"
1002
+    create_endpoint $@
1003
+}
1004
+
1005
+# Gets or creates endpoint
1006
+# Usage: create_endpoint <service> <region> <publicurl> <adminurl>
1007
+function create_endpoint {
1010 1008
     # NOTE(jamielennnox): when converting to v3 endpoint creation we go from
1011 1009
     # creating one endpoint with multiple urls to multiple endpoints each with
1012 1010
     # a different interface.  To maintain the existing function interface we
1013
-    # create 3 endpoints and return the id of the public one. In reality
1011
+    # create 2 endpoints and return the id of the public one. In reality
1014 1012
     # returning the public id will not make a lot of difference as there are no
1015 1013
     # scenarios currently that use the returned id. Ideally this behaviour
1016 1014
     # should be pushed out to the service setups and let them create the
1017 1015
     # endpoints they need.
1018 1016
     local public_id
1019
-    public_id=$(_get_or_create_endpoint_with_interface $1 public $3 $2)
1020
-    _get_or_create_endpoint_with_interface $1 admin $4 $2
1021
-    _get_or_create_endpoint_with_interface $1 internal $5 $2
1017
+    public_id=$(_create_endpoint_with_interface $1 public $3 $2)
1018
+    _create_endpoint_with_interface $1 admin $4 $2
1022 1019
 
1023 1020
     # return the public id to indicate success, and this is the endpoint most likely wanted
1024 1021
     echo $public_id
... ...
@@ -372,7 +372,7 @@ function create_cinder_accounts {
372 372
         create_service_user "cinder"
373 373
 
374 374
         get_or_create_service "cinder" "volume" "Cinder Volume Service"
375
-        get_or_create_endpoint \
375
+        create_endpoint \
376 376
             "volume" \
377 377
             "$REGION_NAME" \
378 378
             "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(project_id)s" \
... ...
@@ -380,7 +380,7 @@ function create_cinder_accounts {
380 380
             "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v1/\$(project_id)s"
381 381
 
382 382
         get_or_create_service "cinderv2" "volumev2" "Cinder Volume Service V2"
383
-        get_or_create_endpoint \
383
+        create_endpoint \
384 384
             "volumev2" \
385 385
             "$REGION_NAME" \
386 386
             "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(project_id)s" \
... ...
@@ -388,7 +388,7 @@ function create_cinder_accounts {
388 388
             "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v2/\$(project_id)s"
389 389
 
390 390
         get_or_create_service "cinderv3" "volumev3" "Cinder Volume Service V3"
391
-        get_or_create_endpoint \
391
+        create_endpoint \
392 392
             "volumev3" \
393 393
             "$REGION_NAME" \
394 394
             "$CINDER_SERVICE_PROTOCOL://$CINDER_SERVICE_HOST:$CINDER_SERVICE_PORT/v3/\$(project_id)s" \
... ...
@@ -292,7 +292,7 @@ function create_glance_accounts {
292 292
         fi
293 293
 
294 294
         get_or_create_service "glance" "image" "Glance Image Service"
295
-        get_or_create_endpoint \
295
+        create_endpoint \
296 296
             "image" \
297 297
             "$REGION_NAME" \
298 298
             "$GLANCE_SERVICE_PROTOCOL://$GLANCE_HOSTPORT" \
... ...
@@ -305,7 +305,7 @@ function create_glance_accounts {
305 305
         create_service_user "glare"
306 306
         get_or_create_service "glare" "artifact" "Glance Artifact Service"
307 307
 
308
-        get_or_create_endpoint "artifact" \
308
+        create_endpoint "artifact" \
309 309
             "$REGION_NAME" \
310 310
             "$GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT" \
311 311
             "$GLANCE_SERVICE_PROTOCOL://$GLANCE_GLARE_HOSTPORT" \
... ...
@@ -388,7 +388,7 @@ function create_heat_accounts {
388 388
 
389 389
         create_service_user "heat" "admin"
390 390
         get_or_create_service "heat" "orchestration" "Heat Orchestration Service"
391
-        get_or_create_endpoint \
391
+        create_endpoint \
392 392
             "orchestration" \
393 393
             "$REGION_NAME" \
394 394
             "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(project_id)s" \
... ...
@@ -396,7 +396,7 @@ function create_heat_accounts {
396 396
             "$SERVICE_PROTOCOL://$HEAT_API_HOST:$HEAT_API_PORT/v1/\$(project_id)s"
397 397
 
398 398
         get_or_create_service "heat-cfn" "cloudformation" "Heat CloudFormation Service"
399
-        get_or_create_endpoint \
399
+        create_endpoint \
400 400
             "cloudformation"  \
401 401
             "$REGION_NAME" \
402 402
             "$SERVICE_PROTOCOL://$HEAT_API_CFN_HOST:$HEAT_API_CFN_PORT/v1" \
... ...
@@ -534,7 +534,7 @@ function create_neutron_accounts {
534 534
         create_service_user "neutron"
535 535
 
536 536
         get_or_create_service "neutron" "network" "Neutron Service"
537
-        get_or_create_endpoint \
537
+        create_endpoint \
538 538
             "network" \
539 539
             "$REGION_NAME" \
540 540
             "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/" \
... ...
@@ -418,7 +418,7 @@ function create_nova_accounts {
418 418
         fi
419 419
 
420 420
         get_or_create_service "nova_legacy" "compute_legacy" "Nova Compute Service (Legacy 2.0)"
421
-        get_or_create_endpoint \
421
+        create_endpoint \
422 422
             "compute_legacy" \
423 423
             "$REGION_NAME" \
424 424
             "$nova_api_url/v2/\$(project_id)s" \
... ...
@@ -426,7 +426,7 @@ function create_nova_accounts {
426 426
             "$nova_api_url/v2/\$(project_id)s"
427 427
 
428 428
         get_or_create_service "nova" "compute" "Nova Compute Service"
429
-        get_or_create_endpoint \
429
+        create_endpoint \
430 430
             "compute" \
431 431
             "$REGION_NAME" \
432 432
             "$nova_api_url/v2.1" \
... ...
@@ -446,7 +446,7 @@ function create_nova_accounts {
446 446
     # S3
447 447
     if is_service_enabled swift3; then
448 448
         get_or_create_service "s3" "s3" "S3"
449
-        get_or_create_endpoint \
449
+        create_endpoint \
450 450
             "s3" \
451 451
             "$REGION_NAME" \
452 452
             "http://$SERVICE_HOST:$S3_SERVICE_PORT" \
... ...
@@ -633,7 +633,7 @@ function create_swift_accounts {
633 633
     create_service_user "swift" "admin"
634 634
 
635 635
     get_or_create_service "swift" "object-store" "Swift Service"
636
-    get_or_create_endpoint \
636
+    create_endpoint \
637 637
         "object-store" \
638 638
         "$REGION_NAME" \
639 639
         "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/v1/AUTH_\$(project_id)s" \