diff options
Diffstat (limited to 'ironic')
-rw-r--r-- | ironic/common/glance_service/service_utils.py | 17 | ||||
-rw-r--r-- | ironic/conf/glance.py | 21 | ||||
-rw-r--r-- | ironic/tests/unit/common/test_glance_service.py | 9 | ||||
-rw-r--r-- | ironic/tests/unit/common/test_image_service.py | 4 |
4 files changed, 7 insertions, 44 deletions
diff --git a/ironic/common/glance_service/service_utils.py b/ironic/common/glance_service/service_utils.py index d4771064f..b23650d7d 100644 --- a/ironic/common/glance_service/service_utils.py +++ b/ironic/common/glance_service/service_utils.py @@ -97,9 +97,7 @@ def _get_api_server_iterator(): that will cycle through the list, looping around to the beginning if necessary. - If CONF.glance.glance_api_servers isn't set, we fall back to using this - as the server: CONF.glance.glance_host:CONF.glance.glance_port. - If CONF.glance.glance_host is also not set, fetch the endpoint from the + If CONF.glance.glance_api_servers isn't set, fetch the endpoint from the service catalog. :returns: iterator that cycles (indefinitely) over shuffled glance API @@ -107,21 +105,14 @@ def _get_api_server_iterator(): """ api_servers = [] - if not CONF.glance.glance_api_servers and not CONF.glance.glance_host: + if not CONF.glance.glance_api_servers: session = keystone.get_session('glance', auth=keystone.get_auth('glance')) api_servers = [keystone.get_service_url(session, service_type='image', endpoint_type='public')] else: - configured_servers = (CONF.glance.glance_api_servers or - ['%s:%s' % (CONF.glance.glance_host, - CONF.glance.glance_port)]) - for api_server in configured_servers: - if '//' not in api_server: - api_server = '%s://%s' % (CONF.glance.glance_protocol, - api_server) - api_servers.append(api_server) - random.shuffle(api_servers) + api_servers = random.sample(CONF.glance.glance_api_servers, + len(CONF.glance.glance_api_servers)) return itertools.cycle(api_servers) diff --git a/ironic/conf/glance.py b/ironic/conf/glance.py index 0bbbfdbac..7d5393b65 100644 --- a/ironic/conf/glance.py +++ b/ironic/conf/glance.py @@ -103,28 +103,11 @@ opts = [ 'value between 1 and 32, a single-tenant store will use ' 'multiple containers to store images, and this value ' 'will determine how many containers are created.')), - cfg.StrOpt('glance_host', - help=_('Default glance hostname or IP address. The service ' - 'catalog is used when not defined. Deprecated, ' - 'use glance_api_servers instead.'), - deprecated_for_removal=True), - cfg.PortOpt('glance_port', - default=9292, - help=_('Default glance port. Deprecated, use ' - 'glance_api_servers instead.'), - deprecated_for_removal=True), - cfg.StrOpt('glance_protocol', - default='http', - choices=['http', 'https'], - help=_('Default protocol to use when connecting to glance. ' - 'Set to https for SSL. Deprecated, use ' - 'glance_api_services instead.'), - deprecated_for_removal=True), cfg.ListOpt('glance_api_servers', help=_('A list of the glance api servers available to ironic. ' 'Prefix with https:// for SSL-based glance API ' - 'servers. Format is [hostname|IP]:port. If neither ' - 'this option nor glance_host is set, the service ' + 'servers. Format is [hostname|IP]:port. ' + 'If this option is not set, the service ' 'catalog is used. It is recommended to rely on the ' 'service catalog, if possible.')), cfg.BoolOpt('glance_api_insecure', diff --git a/ironic/tests/unit/common/test_glance_service.py b/ironic/tests/unit/common/test_glance_service.py index 81a343cb4..f8f5e1a88 100644 --- a/ironic/tests/unit/common/test_glance_service.py +++ b/ironic/tests/unit/common/test_glance_service.py @@ -97,7 +97,7 @@ class TestGlanceImageService(base.TestCase): self.context.project_id = 'fake' self.service = service.GlanceImageService(client, 1, self.context) - self.config(glance_host='localhost', group='glance') + self.config(glance_api_servers=['http://localhost'], group='glance') try: self.config(auth_strategy='keystone', group='glance') except Exception: @@ -876,13 +876,6 @@ class TestGlanceAPIServers(base.TestCase): service_type='image', endpoint_type='public') - def test__get_api_servers_with_host_port(self): - CONF.set_override('glance_host', 'example.com', 'glance') - CONF.set_override('glance_port', 42, 'glance') - CONF.set_override('glance_protocol', 'https', 'glance') - endpoint = service_utils._get_api_server() - self.assertEqual('https://example.com:42', endpoint) - def test__get_api_servers_one(self): CONF.set_override('glance_api_servers', ['https://10.0.0.1:9293'], 'glance') diff --git a/ironic/tests/unit/common/test_image_service.py b/ironic/tests/unit/common/test_image_service.py index da7ce1d86..6e7e522b6 100644 --- a/ironic/tests/unit/common/test_image_service.py +++ b/ironic/tests/unit/common/test_image_service.py @@ -362,7 +362,3 @@ class ServiceGetterTestCase(base.TestCase): def test_out_range_auth_strategy(self): self.assertRaises(ValueError, cfg.CONF.set_override, 'auth_strategy', 'fake', 'glance') - - def test_out_range_glance_protocol(self): - self.assertRaises(ValueError, cfg.CONF.set_override, - 'glance_protocol', 'fake', 'glance') |