Support endpoint updates in bootstrap

The current bootstrap command does not update the endpoints, but
does update many other settings.

It's very convenient to have a way to update endpoints from the
bootstrap command. One such use case is when bootstrap is run from
a configuration management tool such as ansible, and the endpoint
URLs need to be updated.

Change-Id: I2b1cb53701c3e5fb2d91c14d9c792beadd1dbbc2
This commit is contained in:
Eric Brown 2017-03-04 23:05:57 -08:00 committed by Colleen Murphy
parent b357a96ac0
commit a3a66b9b8f
3 changed files with 34 additions and 4 deletions

View File

@ -317,9 +317,10 @@ class Bootstrapper(object):
LOG.info('Created %(interface)s endpoint %(url)s',
{'interface': interface, 'url': url})
else:
# NOTE(jamielennox): electing not to update existing
# endpoints here. There may be call to do so in future.
LOG.info('Skipping %s endpoint as already created',
interface)
endpoint_ref['url'] = url
PROVIDERS.catalog_api.update_endpoint(
endpoint_id=endpoint_ref['id'],
endpoint_ref=endpoint_ref)
LOG.info('%s endpoint updated', interface)
self.endpoints[interface] = endpoint_ref['id']

View File

@ -404,6 +404,21 @@ class CliBootStrapTestCaseWithEnvironment(CliBootStrapTestCase):
self._do_test_bootstrap(self.bootstrap)
def test_endpoints_created_with_new_endpoints(self):
service = unit.new_service_ref(name=self.service_name, type='identity')
PROVIDERS.catalog_api.create_service(service['id'], service)
region = unit.new_region_ref(id=self.region_id)
PROVIDERS.catalog_api.create_region(region)
endpoint = unit.new_endpoint_ref(interface='public',
service_id=service['id'],
url=uuid.uuid4().hex,
region_id=self.region_id)
PROVIDERS.catalog_api.create_endpoint(endpoint['id'], endpoint)
self._do_test_bootstrap(self.bootstrap)
updated_endpoint = PROVIDERS.catalog_api.get_endpoint(endpoint['id'])
self.assertEqual(updated_endpoint['url'], self.bootstrap.public_url)
class CliDomainConfigAllTestCase(unit.SQLDriverOverrides, unit.TestCase):

View File

@ -0,0 +1,14 @@
---
features:
- |
The ``keystone-manage bootstrap`` command can now be used to update
existing endpoints idempotently, which is useful in conjunction with
configuration management tools that use this command for both
initialization and lifecycle management of keystone.
upgrade:
- |
The ``keystone-manage bootstrap`` command will now update existing
endpoints rather than skipping them if they already exist but are different
from the values provided to the command. This is useful in conjunction with
configuration management tools that use this command for both
initialization and lifecycle management of keystone.