summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorStephanie Reese <reese.sm@gmail.com>2011-07-15 06:52:32 +0000
committerTarmac <>2011-07-15 06:52:32 +0000
commitad700b0ecec0ffd8ed9c08caeb8f1f75fc4b482f (patch)
treea7c99d8f6437ccdb713146b944458bca37dfce91 /nova/api
parent168a2184b462b0cd8e09da3c3962146fcb6f3665 (diff)
parent0aeec37c27e91d031ef53eeec9952c4f470990a1 (diff)
Fixes Bug #810149 that had an incomplete regex
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/common.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 79969d393..8e12ce0c0 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -137,15 +137,22 @@ def get_id_from_href(href):
def remove_version_from_href(href):
- """Removes the api version from the href.
+ """Removes the first api version from the href.
Given: 'http://www.nova.com/v1.1/123'
Returns: 'http://www.nova.com/123'
+ Given: 'http://www.nova.com/v1.1'
+ Returns: 'http://www.nova.com'
+
"""
try:
- #matches /v#.#
- new_href = re.sub(r'[/][v][0-9]*.[0-9]*', '', href)
+ #removes the first instance that matches /v#.#/
+ new_href = re.sub(r'[/][v][0-9]+\.[0-9]+[/]', '/', href, count=1)
+
+ #if no version was found, try finding /v#.# at the end of the string
+ if new_href == href:
+ new_href = re.sub(r'[/][v][0-9]+\.[0-9]+$', '', href, count=1)
except:
LOG.debug(_("Error removing version from href: %s") % href)
msg = _('could not parse version from href')