diff options
| author | William Wolf <throughnothing@gmail.com> | 2011-08-12 13:07:24 -0400 |
|---|---|---|
| committer | William Wolf <throughnothing@gmail.com> | 2011-08-12 13:07:24 -0400 |
| commit | 3cbf0267efdef7d36a88faeb545342619f82f108 (patch) | |
| tree | c81663c39757891e27de1c64a2f67ab865fb009c /nova/api | |
| parent | cfa71424fd1724b809c0794fb4ae56f1b1c30e8a (diff) | |
| parent | bf334c786091ace63dd943e5e5893a239a22d21e (diff) | |
| download | nova-3cbf0267efdef7d36a88faeb545342619f82f108.tar.gz nova-3cbf0267efdef7d36a88faeb545342619f82f108.tar.xz nova-3cbf0267efdef7d36a88faeb545342619f82f108.zip | |
merge from trunk
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/common.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index dfdd62201..b2a675653 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -169,13 +169,20 @@ def get_id_from_href(href): Returns: 123 """ - if re.match(r'\d+$', str(href)): + 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: 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')) + except ValueError as error: + LOG.debug(_("Failed to parse ID from %(href)s: %(error)s") % locals()) + raise def remove_version_from_href(href): |
