summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-08-12 16:09:01 +0000
committerTarmac <>2011-08-12 16:09:01 +0000
commit7610b839a05bbde730b28d73586ba8ba096d0044 (patch)
tree3dd666fee7411220c00dd53c44cc536c6a3c5cb1 /nova/api
parent1f116df9b65fc317db26492115bc36ce465ba296 (diff)
parent954e8e24c6b8ceb541c539ce7c26da4b35b5f0b1 (diff)
Fixing a 500 error when -1 is supplied for flavorRef on server create.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/common.py15
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):