~cerberus/nova/disk_config

« back to all changes in this revision

Viewing changes to nova/api/openstack/views/images.py

  • Committer: matt.dietz at rackspace
  • Date: 2011-09-21 19:48:25 UTC
  • mfrom: (1511.1.98 nova)
  • Revision ID: matt.dietz@rackspace.com-20110921194825-zv1w4qonfh6o1j2u
Merge from trunk, updated failing tests and pep8

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import os.path
19
19
 
20
20
from nova.api.openstack import common
 
21
from nova import utils
21
22
 
22
23
 
23
24
class ViewBuilder(object):
139
140
        image = ViewBuilder.build(self, image_obj, detail)
140
141
        href = self.generate_href(image_obj["id"])
141
142
        bookmark = self.generate_bookmark(image_obj["id"])
 
143
        alternate = self.generate_alternate(image_obj["id"])
142
144
 
143
145
        image["links"] = [
144
146
            {
149
151
                "rel": "bookmark",
150
152
                "href": bookmark,
151
153
            },
 
154
            {
 
155
                "rel": "alternate",
 
156
                "type": "application/vnd.openstack.image",
 
157
                "href": alternate,
 
158
            },
152
159
 
153
160
        ]
154
161
 
158
165
        return image
159
166
 
160
167
    def generate_bookmark(self, image_id):
161
 
        """Create an url that refers to a specific flavor id."""
 
168
        """Create a URL that refers to a specific flavor id."""
162
169
        return os.path.join(common.remove_version_from_href(self.base_url),
163
170
            self.project_id, "images", str(image_id))
 
171
 
 
172
    def generate_alternate(self, image_id):
 
173
        """Create an alternate link for a specific flavor id."""
 
174
        glance_url = utils.generate_glance_url()
 
175
 
 
176
        return "%s/%s/images/%s" % (glance_url, self.project_id,
 
177
                str(image_id))