File utils-ver-from-ep-strip-prj.diff of Package python-glanceclient
From: Kurt Garloff <t-systems@garloff.de>
Subject: Strip off project_id when determining version from endpoint path
When using openstack --os-token $OS_TOKEN --os-url nova/v2/$OS_PROJECT_ID server list,
nova client asks glance for images, but glance tries to determine API version from
nova URL. We should strip off project IDs ...
Note that this only happens to help by luck: glance API version coincides with version
determined from nova URL.
Index: python-glanceclient-2.9.1/glanceclient/common/utils.py
===================================================================
--- python-glanceclient-2.9.1.orig/glanceclient/common/utils.py
+++ python-glanceclient-2.9.1/glanceclient/common/utils.py
@@ -379,8 +379,12 @@ def strip_version(endpoint):
url_parts = urlparse.urlparse(endpoint)
(scheme, netloc, path, __, __, __) = url_parts
path = path.lstrip('/')
+ # Strip off project ID if included here ...
+ idx = path.find('/')
+ if idx > 0:
+ path = path[:idx]
# regex to match 'v1' or 'v2.0' etc
- if re.match('v\d+\.?\d*', path):
+ if re.match('v\d+\.?\d*$', path):
version = float(path.lstrip('v'))
endpoint = scheme + '://' + netloc
return endpoint, version