From 3eca8aa5f1f2ecb3c0d44856f9792ca5fa266efd Mon Sep 17 00:00:00 2001 From: David Ames Date: Wed, 16 May 2018 23:11:01 +0000 Subject: [PATCH] Fix updating keystone catalog endpoints GSSS was failing to update the keystone catalog endpoints when using keystone v3. There was a lot of outdated code that needed to be updated. However, there was also existing code to update the keystone relation which accomplishes the same thing. Keystone is the right place to handle the various differences between v2 and v3. This change updates the sync script to simple update the keystone relation in order to register and update catalog endpoints. --- scripts/glance-simplestreams-sync.py | 49 +++------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/scripts/glance-simplestreams-sync.py b/scripts/glance-simplestreams-sync.py index c97bd99..c9ee55b 100755 --- a/scripts/glance-simplestreams-sync.py +++ b/scripts/glance-simplestreams-sync.py @@ -290,51 +290,10 @@ def update_product_streams_service(ksc, services, region): "product-streams endpoint: {}".format(e)) raise - for endpoint_type in ['publicURL', 'internalURL']: - catalog[endpoint_type] += "/{}".format(SWIFT_DATA_DIR) - - endpoints = [endpoint._info for endpoint in ksc.endpoints.list() - if endpoint._info['region'] == region] - ps_services = [s for s in services - if s['name'] == PRODUCT_STREAMS_SERVICE_NAME] - if len(ps_services) != 1: - log.error("found {} product-streams services. expecting one." - " - not updating endpoint.".format(len(ps_services))) - return - - ps_service_id = ps_services[0]['id'] - - ps_endpoints = [endpoint for endpoint in endpoints - if endpoint['service_id'] == ps_service_id] - - if len(ps_endpoints) != 1: - log.warning("found {} product-streams endpoints in region {}," - " expecting one - not updating" - " endpoint".format(len(ps_endpoints), region)) - return - - create_args = dict(region=region, - service_id=ps_service_id, - publicurl=catalog['publicURL'], - adminurl=catalog['adminURL'], - internalurl=catalog['internalURL']) - ps_endpoint = ps_endpoints[0] - - endpoint_already_exists = all( - create_args[key] == ps_endpoint.get(key) for key in create_args) - - if endpoint_already_exists: - log.info("Endpoint already set to desired values, moving on.") - else: - status_set('maintenance', 'Updating product-streams endpoint') - - log.info("Deleting existing product-streams endpoint: ") - ksc.endpoints.delete(ps_endpoints[0]['id']) - log.info("creating product-streams endpoint: {}".format(create_args)) - ksc.endpoints.create(**create_args) - update_endpoint_urls(region, catalog['publicURL'], - catalog['adminURL'], - catalog['internalURL']) + # Update the relation to keystone to update the catalog URLs + update_endpoint_urls(region, catalog['publicURL'], + catalog['adminURL'], + catalog['internalURL']) def juju_run_cmd(cmd):