summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorNaveed Massjouni <naveedm9@gmail.com>2011-03-22 13:18:08 -0400
committerNaveed Massjouni <naveedm9@gmail.com>2011-03-22 13:18:08 -0400
commit493e87976b7eb273f4115d46c91ad73671abb796 (patch)
tree05a57d456b572eb25a9c5296f4d6bfb6681a4488 /nova
parent4e33ab9fc16d580fbcf57da8e6e2228ad27cc1af (diff)
Now using urlparse to parse a url to grab id out of it.
Diffstat (limited to 'nova')
-rw-r--r--nova/api/openstack/common.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index b224cbfb4..99fba8fef 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -17,6 +17,7 @@
import re
from nova import exception
+from urlparse import urlparse
from webob import exc
import webob.exc
@@ -78,7 +79,7 @@ def get_image_id_from_image_hash(image_service, context, image_hash):
def get_id_from_href(href):
- m = re.match(r'http.+/.+/(\d)+$', href)
- if not m:
+ try:
+ return int(urlparse(href).path.split('/')[-1])
+ except:
raise exc.HTTPBadRequest(_('could not parse id from href'))
- return int(m.group(1))