Permalink
Browse files

makes api return default endpoint types. fixes bug 994151

Change-Id: I409a5415ffeb21ea81ecf540caa2cd5ac3336d90
  • Loading branch information...
1 parent 2698f2b commit 0f952bcdc525c59380742f96945a24146aab6193 @heckj heckj committed May 3, 2012
Showing with 15 additions and 6 deletions.
  1. +6 −1 horizon/api/base.py
  2. +9 −5 horizon/tests/api_tests/base_tests.py
View
@@ -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:
@@ -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')

0 comments on commit 0f952bc

Please sign in to comment.