summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-08-12 11:44:49 -0400
committerBrian Waldon <brian.waldon@rackspace.com>2011-08-12 11:44:49 -0400
commit954e8e24c6b8ceb541c539ce7c26da4b35b5f0b1 (patch)
treedb50fd5c63e6d179fcd85f28fb036caf9566466b /nova/api
parent45d6ab8ffec6ff4b26500df7049ce4092b15f00c (diff)
rewriting parsing
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/common.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 23614d598..b2a675653 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -169,16 +169,20 @@ def get_id_from_href(href):
Returns: 123
"""
+ LOG.debug(_("Attempting to treat %(href)s as an integer ID.") % locals())
+
+ try:
+ return int(href)
+ except ValueError:
+ pass
+
+ LOG.debug(_("Attempting to treat %(href)s as a URL.") % locals())
+
try:
- href = str(href)
-
- if re.match(r'\d+$', href):
- return int(href)
- else:
- return int(urlparse.urlsplit(href).path.split('/')[-1])
- except ValueError, e:
- LOG.debug(_("Error extracting id from href: %s") % href)
- raise ValueError(_('could not parse id from href'))
+ return int(urlparse.urlsplit(href).path.split('/')[-1])
+ except ValueError as error:
+ LOG.debug(_("Failed to parse ID from %(href)s: %(error)s") % locals())
+ raise
def remove_version_from_href(href):