makes api return default endpoint types. fixes bug 994151
Change-Id: I409a5415ffeb21ea81ecf540caa2cd5ac3336d90
This commit is contained in:
parent
2698f2b350
commit
0f952bcdc5
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +99,10 @@ def get_service_from_catalog(catalog, service_type):
|
|||||||
return None
|
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
|
catalog = request.user.service_catalog
|
||||||
service = get_service_from_catalog(catalog, service_type)
|
service = get_service_from_catalog(catalog, service_type)
|
||||||
if service:
|
if service:
|
||||||
|
@ -112,28 +112,32 @@ class ApiHelperTests(test.TestCase):
|
|||||||
|
|
||||||
def test_url_for(self):
|
def test_url_for(self):
|
||||||
url = api_base.url_for(self.request, 'image')
|
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)
|
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)
|
url = api_base.url_for(self.request, 'image', admin=True)
|
||||||
self.assertEqual(url, 'http://admin.glance.example.com:9292/v1')
|
self.assertEqual(url, 'http://admin.glance.example.com:9292/v1')
|
||||||
|
|
||||||
url = api_base.url_for(self.request, 'compute')
|
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)
|
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)
|
url = api_base.url_for(self.request, 'compute', admin=True)
|
||||||
self.assertEqual(url, 'http://admin.nova.example.com:8774/v2')
|
self.assertEqual(url, 'http://admin.nova.example.com:8774/v2')
|
||||||
|
|
||||||
url = api_base.url_for(self.request, 'volume')
|
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')
|
self.assertEqual(url, 'http://int.nova.example.com:8776/v1')
|
||||||
|
|
||||||
url = api_base.url_for(self.request, 'volume', admin=False)
|
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)
|
url = api_base.url_for(self.request, 'volume', admin=True)
|
||||||
self.assertEqual(url, 'http://admin.nova.example.com:8776/v1')
|
self.assertEqual(url, 'http://admin.nova.example.com:8776/v1')
|
||||||
|
Loading…
Reference in New Issue
Block a user