discovery: allow to discover all endpoints
This allow the Keystone endpoints discoverer to discover all the URLs if no service type is specified. Blueprint: ceilometer-healthcheck-middleware Change-Id: I6e1e5f6261ca55c5a0a0c70822f80257061d56c2
This commit is contained in:
parent
f49d43b595
commit
6ae9609857
@ -1,4 +1,4 @@
|
||||
# Copyright 2014 Red Hat, Inc
|
||||
# Copyright 2014-2015 Red Hat, Inc
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
@ -32,15 +32,14 @@ class EndpointDiscovery(plugin.DiscoveryBase):
|
||||
nova.floating_ips.list() and therefore gets all floating IPs at once.
|
||||
"""
|
||||
|
||||
def discover(self, manager, param=None):
|
||||
if not param:
|
||||
return []
|
||||
@staticmethod
|
||||
def discover(manager, param=None):
|
||||
endpoints = manager.keystone.service_catalog.get_urls(
|
||||
service_type=param,
|
||||
endpoint_type=cfg.CONF.service_credentials.os_endpoint_type,
|
||||
region_name=cfg.CONF.service_credentials.os_region_name)
|
||||
if not endpoints:
|
||||
LOG.warning(_LW('No endpoints found for service %s'), param)
|
||||
LOG.warning(_LW('No endpoints found for service %s'),
|
||||
"<all services>" if param is None else param)
|
||||
return []
|
||||
else:
|
||||
return endpoints
|
||||
return endpoints
|
||||
|
@ -29,12 +29,12 @@ class TestEndpointDiscovery(base.BaseTestCase):
|
||||
self.discovery = endpoint.EndpointDiscovery()
|
||||
self.manager = mock.MagicMock()
|
||||
self.CONF = self.useFixture(fixture_config.Config()).conf
|
||||
|
||||
def test_keystone_called(self):
|
||||
self.CONF.set_override('os_endpoint_type', 'test-endpoint-type',
|
||||
group='service_credentials')
|
||||
self.CONF.set_override('os_region_name', 'test-region-name',
|
||||
group='service_credentials')
|
||||
|
||||
def test_keystone_called(self):
|
||||
self.discovery.discover(self.manager, param='test-service-type')
|
||||
expected = [mock.call(service_type='test-service-type',
|
||||
endpoint_type='test-endpoint-type',
|
||||
@ -42,3 +42,12 @@ class TestEndpointDiscovery(base.BaseTestCase):
|
||||
self.assertEqual(expected,
|
||||
self.manager.keystone.service_catalog.get_urls
|
||||
.call_args_list)
|
||||
|
||||
def test_keystone_called_no_service_type(self):
|
||||
self.discovery.discover(self.manager)
|
||||
expected = [mock.call(service_type=None,
|
||||
endpoint_type='test-endpoint-type',
|
||||
region_name='test-region-name')]
|
||||
self.assertEqual(expected,
|
||||
self.manager.keystone.service_catalog.get_urls
|
||||
.call_args_list)
|
||||
|
Loading…
Reference in New Issue
Block a user