~danwent/nova/qmanager

« back to all changes in this revision

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

  • Committer: Dan Wendlandt
  • Date: 2011-08-23 03:31:24 UTC
  • mfrom: (1343.1.133 nova)
  • Revision ID: dan@nicira.com-20110823033124-mgfx108h423trjmy
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
class ViewBuilder(object):
24
24
    """Base class for generating responses to OpenStack API image requests."""
25
25
 
26
 
    def __init__(self, base_url):
 
26
    def __init__(self, base_url, project_id=""):
27
27
        """Initialize new `ViewBuilder`."""
28
 
        self._url = base_url
 
28
        self.base_url = base_url
 
29
        self.project_id = project_id
29
30
 
30
31
    def _format_dates(self, image):
31
32
        """Update all date fields to ensure standardized formatting."""
54
55
 
55
56
    def generate_href(self, image_id):
56
57
        """Return an href string pointing to this object."""
57
 
        return os.path.join(self._url, "images", str(image_id))
 
58
        return os.path.join(self.base_url, "images", str(image_id))
58
59
 
59
60
    def build(self, image_obj, detail=False):
60
61
        """Return a standardized image structure for display by the API."""
117
118
        except KeyError:
118
119
            return
119
120
 
 
121
    def generate_href(self, image_id):
 
122
        """Return an href string pointing to this object."""
 
123
        return os.path.join(self.base_url, self.project_id,
 
124
                            "images", str(image_id))
 
125
 
120
126
    def build(self, image_obj, detail=False):
121
127
        """Return a standardized image structure for display by the API."""
122
128
        image = ViewBuilder.build(self, image_obj, detail)
142
148
 
143
149
    def generate_bookmark(self, image_id):
144
150
        """Create an url that refers to a specific flavor id."""
145
 
        return os.path.join(common.remove_version_from_href(self._url),
146
 
            "images", str(image_id))
 
151
        return os.path.join(common.remove_version_from_href(self.base_url),
 
152
            self.project_id, "images", str(image_id))