Merge "discovery: allow to discover all endpoints"

This commit is contained in:
Jenkins 2015-02-03 22:22:53 +00:00 committed by Gerrit Code Review
commit a3a4e0e283
2 changed files with 17 additions and 9 deletions

View File

@ -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

View File

@ -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)