Skip to content

Commit 59727ba

Browse files
emontyDean Troyer
authored andcommitted
Don't hack the image url
It's actually breaking usage against HP Public Cloud. Change-Id: Ic172786c6d1272798b768078a0bcf246f8d64ca8
1 parent 5b8f18f commit 59727ba

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎openstackclient/api/image_v1.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
class APIv1(api.BaseAPI):
2020
"""Image v1 API"""
2121

22+
_endpoint_suffix = 'v1'
23+
2224
def __init__(self, endpoint=None, **kwargs):
2325
super(APIv1, self).__init__(endpoint=endpoint, **kwargs)
2426

27+
self.endpoint = self.endpoint.rstrip('/')
28+
self._munge_url()
29+
30+
def _munge_url(self):
2531
# Hack this until discovery is up
26-
self.endpoint = '/'.join([self.endpoint.rstrip('/'), 'v1'])
32+
if self._endpoint_suffix not in self.endpoint.split('/')[-1]:
33+
self.endpoint = '/'.join([self.endpoint, self._endpoint_suffix])
2734

2835
def image_list(
2936
self,

‎openstackclient/api/image_v2.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
class APIv2(image_v1.APIv1):
2020
"""Image v2 API"""
2121

22-
def __init__(self, endpoint=None, **kwargs):
23-
super(APIv2, self).__init__(endpoint=endpoint, **kwargs)
22+
_endpoint_suffix = 'v2'
2423

24+
def _munge_url(self):
2525
# Hack this until discovery is up, and ignore parent endpoint setting
26-
self.endpoint = '/'.join([endpoint.rstrip('/'), 'v2'])
26+
if 'v2' not in self.endpoint.split('/')[-1]:
27+
self.endpoint = '/'.join([self.endpoint, 'v2'])
2728

2829
def image_list(
2930
self,

0 commit comments

Comments
 (0)