makes api return default endpoint types. fixes bug 994151

Change-Id: I409a5415ffeb21ea81ecf540caa2cd5ac3336d90
This commit is contained in:
Joe Heck 2012-05-03 19:02:22 +00:00
parent 2698f2b350
commit 0f952bcdc5
2 changed files with 15 additions and 6 deletions

View File

@ -20,6 +20,8 @@
import logging
from django.conf import settings
from horizon import exceptions
@ -97,7 +99,10 @@ def get_service_from_catalog(catalog, service_type):
return None
def url_for(request, service_type, admin=False, endpoint_type='internalURL'):
def url_for(request, service_type, admin=False, endpoint_type=None):
endpoint_type = endpoint_type or getattr(settings,
'OPENSTACK_ENDPOINT_TYPE',
'publicURL')
catalog = request.user.service_catalog
service = get_service_from_catalog(catalog, service_type)
if service:

View File

@ -112,28 +112,32 @@ class ApiHelperTests(test.TestCase):
def test_url_for(self):
url = api_base.url_for(self.request, 'image')
self.assertEqual(url, 'http://int.glance.example.com:9292/v1')
self.assertEqual(url, 'http://public.glance.example.com:9292/v1')
url = api_base.url_for(self.request, 'image', admin=False)
self.assertEqual(url, 'http://int.glance.example.com:9292/v1')
self.assertEqual(url, 'http://public.glance.example.com:9292/v1')
url = api_base.url_for(self.request, 'image', admin=True)
self.assertEqual(url, 'http://admin.glance.example.com:9292/v1')
url = api_base.url_for(self.request, 'compute')
self.assertEqual(url, 'http://int.nova.example.com:8774/v2')
self.assertEqual(url, 'http://public.nova.example.com:8774/v2')
url = api_base.url_for(self.request, 'compute', admin=False)
self.assertEqual(url, 'http://int.nova.example.com:8774/v2')
self.assertEqual(url, 'http://public.nova.example.com:8774/v2')
url = api_base.url_for(self.request, 'compute', admin=True)
self.assertEqual(url, 'http://admin.nova.example.com:8774/v2')
url = api_base.url_for(self.request, 'volume')
self.assertEqual(url, 'http://public.nova.example.com:8776/v1')
url = api_base.url_for(self.request, 'volume',
endpoint_type="internalURL")
self.assertEqual(url, 'http://int.nova.example.com:8776/v1')
url = api_base.url_for(self.request, 'volume', admin=False)
self.assertEqual(url, 'http://int.nova.example.com:8776/v1')
self.assertEqual(url, 'http://public.nova.example.com:8776/v1')
url = api_base.url_for(self.request, 'volume', admin=True)
self.assertEqual(url, 'http://admin.nova.example.com:8776/v1')