Merge "Fixes image api URL endpoint for certain scenario"

This commit is contained in:
Jenkins 2017-01-04 23:05:24 +00:00 committed by Gerrit Code Review
commit b957ba8d92
4 changed files with 8 additions and 8 deletions

View File

@ -19,7 +19,7 @@ from openstackclient.api import api
class APIv1(api.BaseAPI): class APIv1(api.BaseAPI):
"""Image v1 API""" """Image v1 API"""
_endpoint_suffix = 'v1' _endpoint_suffix = '/v1'
def __init__(self, endpoint=None, **kwargs): def __init__(self, endpoint=None, **kwargs):
super(APIv1, self).__init__(endpoint=endpoint, **kwargs) super(APIv1, self).__init__(endpoint=endpoint, **kwargs)
@ -29,8 +29,8 @@ class APIv1(api.BaseAPI):
def _munge_url(self): def _munge_url(self):
# Hack this until discovery is up # Hack this until discovery is up
if self._endpoint_suffix not in self.endpoint.split('/')[-1]: if not self.endpoint.endswith(self._endpoint_suffix):
self.endpoint = '/'.join([self.endpoint, self._endpoint_suffix]) self.endpoint = self.endpoint + self._endpoint_suffix
def image_list( def image_list(
self, self,

View File

@ -19,12 +19,12 @@ from openstackclient.api import image_v1
class APIv2(image_v1.APIv1): class APIv2(image_v1.APIv1):
"""Image v2 API""" """Image v2 API"""
_endpoint_suffix = 'v2' _endpoint_suffix = '/v2'
def _munge_url(self): def _munge_url(self):
# Hack this until discovery is up, and ignore parent endpoint setting # Hack this until discovery is up, and ignore parent endpoint setting
if 'v2' not in self.endpoint.split('/')[-1]: if not self.endpoint.endswith(self._endpoint_suffix):
self.endpoint = '/'.join([self.endpoint, 'v2']) self.endpoint = self.endpoint + self._endpoint_suffix
def image_list( def image_list(
self, self,

View File

@ -21,7 +21,7 @@ from openstackclient.tests.unit import utils
FAKE_PROJECT = 'xyzpdq' FAKE_PROJECT = 'xyzpdq'
FAKE_URL = 'http://gopher.com' FAKE_URL = 'http://gopher.dev10.com'
class TestImageAPIv1(utils.TestCase): class TestImageAPIv1(utils.TestCase):

View File

@ -21,7 +21,7 @@ from openstackclient.tests.unit import utils
FAKE_PROJECT = 'xyzpdq' FAKE_PROJECT = 'xyzpdq'
FAKE_URL = 'http://gopher.com' FAKE_URL = 'http://gopher.dev20.com'
class TestImageAPIv2(utils.TestCase): class TestImageAPIv2(utils.TestCase):