summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2011-09-14 22:33:58 +0000
committerJohannes Erdfelt <johannes.erdfelt@rackspace.com>2011-09-14 22:33:58 +0000
commit084606b2f69f05c5604489224f2d9ea2e984c8c2 (patch)
tree91d5414828c81dabefe5b6aa0b2ba00140bbde2d /nova/api
parenta5b339fb75e1e5f525a758ea1fb2fb35d1b9044a (diff)
parentb7997e4f3257304229045d75e23749520630ed10 (diff)
downloadnova-084606b2f69f05c5604489224f2d9ea2e984c8c2.tar.gz
nova-084606b2f69f05c5604489224f2d9ea2e984c8c2.tar.xz
nova-084606b2f69f05c5604489224f2d9ea2e984c8c2.zip
Merge with trunk
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/common.py24
-rw-r--r--nova/api/openstack/views/images.py10
2 files changed, 15 insertions, 19 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py
index 66e18c557..3ef9bdee5 100644
--- a/nova/api/openstack/common.py
+++ b/nova/api/openstack/common.py
@@ -190,30 +190,16 @@ def limited_by_marker(items, request, max_limit=FLAGS.osapi_max_limit):
def get_id_from_href(href):
- """Return the id portion of a url as an int.
+ """Return the id or uuid portion of a url.
Given: 'http://www.foo.com/bar/123?q=4'
- Returns: 123
+ Returns: '123'
- In order to support local hrefs, the href argument can be just an id:
- Given: '123'
- Returns: 123
+ Given: 'http://www.foo.com/bar/abc123?q=4'
+ Returns: 'abc123'
"""
- 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 as error:
- LOG.debug(_("Failed to parse ID from %(href)s: %(error)s") % locals())
- raise
+ return urlparse.urlsplit("%s" % href).path.split('/')[-1]
def remove_version_from_href(href):
diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/views/images.py
index 8983b2957..86e8d7f3a 100644
--- a/nova/api/openstack/views/images.py
+++ b/nova/api/openstack/views/images.py
@@ -71,6 +71,7 @@ class ViewBuilder(object):
}
self._build_server(image, image_obj)
+ self._build_image_id(image, image_obj)
if detail:
image.update({
@@ -96,6 +97,12 @@ class ViewBuilderV10(ViewBuilder):
except (KeyError, ValueError):
pass
+ def _build_image_id(self, image, image_obj):
+ try:
+ image['id'] = int(image_obj['id'])
+ except ValueError:
+ pass
+
class ViewBuilderV11(ViewBuilder):
"""OpenStack API v1.1 Image Builder"""
@@ -119,6 +126,9 @@ class ViewBuilderV11(ViewBuilder):
except KeyError:
return
+ def _build_image_id(self, image, image_obj):
+ image['id'] = "%s" % image_obj['id']
+
def generate_href(self, image_id):
"""Return an href string pointing to this object."""
return os.path.join(self.base_url, self.project_id,