summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2011-09-20 13:56:15 -0500
committerJosh Kearney <josh@jk0.org>2011-09-20 13:56:15 -0500
commit13e346df0bc88279242ed1c56ad39b36a22c8a39 (patch)
tree5c14a1720772cfb36e6bce9b4ccf79ae7580c091 /nova/api
parentbb018b14fb8786090b2cf8b23723fa97defef9ce (diff)
Refactored alternate link generation.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/views/images.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/views/images.py
index 86e8d7f3a..c41123f5e 100644
--- a/nova/api/openstack/views/images.py
+++ b/nova/api/openstack/views/images.py
@@ -18,6 +18,10 @@
import os.path
from nova.api.openstack import common
+from nova import flags
+
+
+FLAGS = flags.FLAGS
class ViewBuilder(object):
@@ -139,6 +143,7 @@ class ViewBuilderV11(ViewBuilder):
image = ViewBuilder.build(self, image_obj, detail)
href = self.generate_href(image_obj["id"])
bookmark = self.generate_bookmark(image_obj["id"])
+ alternate = self.generate_alternate(image_obj["id"])
image["links"] = [
{
@@ -149,6 +154,11 @@ class ViewBuilderV11(ViewBuilder):
"rel": "bookmark",
"href": bookmark,
},
+ {
+ "rel": "alternate",
+ "type": "application/vnd.openstack.image",
+ "href": alternate,
+ },
]
@@ -158,6 +168,13 @@ class ViewBuilderV11(ViewBuilder):
return image
def generate_bookmark(self, image_id):
- """Create an url that refers to a specific flavor id."""
+ """Create a URL that refers to a specific flavor id."""
return os.path.join(common.remove_version_from_href(self.base_url),
self.project_id, "images", str(image_id))
+
+ def generate_alternate(self, image_id):
+ """Create an alternate link for a specific flavor id."""
+ # TODO(jk0): This will eventually need to take SSL into consideration
+ # when supported in glance.
+ return "http://%s:%d/%s/images/%s" % (FLAGS.glance_host,
+ FLAGS.glance_port, self.project_id, str(image_id))