Browse code

Revert "Don't check for existing endpoints"

This reverts commit 7d1ec430046256ac3f536f4920a43936e28ef0c4.

This broke the sahara and layer4 dsvm jobs. The layer4 job
is voting on tempest changes so tempest is also broken.

Change-Id: Ide69f10cd85bf7ff0d86bc8cba56dedd26850362
Partial-Bug: #1573868

Matt Riedemann authored on 2016/04/23 10:45:40
Showing 7 changed files
... ...
@@ -987,35 +987,38 @@ function get_or_create_service {
987 987
 }
988 988
 
989 989
 # Create an endpoint with a specific interface
990
-# Usage: _create_endpoint_with_interface <service> <interface> <url> <region>
991
-function _create_endpoint_with_interface {
992
-    # Creates new endpoint
990
+# Usage: _get_or_create_endpoint_with_interface <service> <interface> <url> <region>
991
+function _get_or_create_endpoint_with_interface {
993 992
     local endpoint_id
994
-    endpoint_id=$(openstack endpoint create \
995
-                            $1 $2 $3 --region $4 -f value -c id)
996
-    echo $endpoint_id
997
-}
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
998 1003
 
999
-# TODO(sdague): remove in O
1000
-function get_or_create_endpoint {
1001
-    deprecated "get_or_create_endpoint is deprecated. Use create_endpoint instead"
1002
-    create_endpoint $@
1004
+    echo $endpoint_id
1003 1005
 }
1004 1006
 
1005 1007
 # Gets or creates endpoint
1006
-# Usage: create_endpoint <service> <region> <publicurl> <adminurl>
1007
-function create_endpoint {
1008
+# Usage: get_or_create_endpoint <service> <region> <publicurl> <adminurl> <internalurl>
1009
+function get_or_create_endpoint {
1008 1010
     # NOTE(jamielennnox): when converting to v3 endpoint creation we go from
1009 1011
     # creating one endpoint with multiple urls to multiple endpoints each with
1010 1012
     # a different interface.  To maintain the existing function interface we
1011
-    # create 2 endpoints and return the id of the public one. In reality
1013
+    # create 3 endpoints and return the id of the public one. In reality
1012 1014
     # returning the public id will not make a lot of difference as there are no
1013 1015
     # scenarios currently that use the returned id. Ideally this behaviour
1014 1016
     # should be pushed out to the service setups and let them create the
1015 1017
     # endpoints they need.
1016 1018
     local public_id
1017
-    public_id=$(_create_endpoint_with_interface $1 public $3 $2)
1018
-    _create_endpoint_with_interface $1 admin $4 $2
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
1019 1022
 
1020 1023
     # return the public id to indicate success, and this is the endpoint most likely wanted
1021 1024
     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
-        create_endpoint \
375
+        get_or_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
-        create_endpoint \
383
+        get_or_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
-        create_endpoint \
391
+        get_or_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
-        create_endpoint \
295
+        get_or_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
-        create_endpoint "artifact" \
308
+        get_or_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
-        create_endpoint \
391
+        get_or_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
-        create_endpoint \
399
+        get_or_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
-        create_endpoint \
537
+        get_or_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
-        create_endpoint \
421
+        get_or_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
-        create_endpoint \
429
+        get_or_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
-        create_endpoint \
449
+        get_or_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
-    create_endpoint \
636
+    get_or_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" \