~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-06-17 13:29:16 UTC
  • mto: (94.1.1 raring-proposed)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20110617132916-u3vv6rxmtvnfn4cj
Tags: upstream-2011.3~d2~20110617.1191
ImportĀ upstreamĀ versionĀ 2011.3~d2~20110617.1191

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import hashlib
19
19
import os
20
20
 
 
21
from nova import exception
21
22
from nova.compute import power_state
22
23
import nova.compute
23
24
import nova.context
41
42
 
42
43
    def build(self, inst, is_detail):
43
44
        """Return a dict that represenst a server."""
44
 
        if is_detail:
45
 
            server = self._build_detail(inst)
 
45
        if inst.get('_is_precooked', False):
 
46
            server = dict(server=inst)
46
47
        else:
47
 
            server = self._build_simple(inst)
 
48
            if is_detail:
 
49
                server = self._build_detail(inst)
 
50
            else:
 
51
                server = self._build_simple(inst)
48
52
 
49
 
        self._build_extra(server, inst)
 
53
            self._build_extra(server, inst)
50
54
 
51
55
        return server
52
56
 
78
82
 
79
83
        ctxt = nova.context.get_admin_context()
80
84
        compute_api = nova.compute.API()
 
85
 
81
86
        if compute_api.has_finished_migration(ctxt, inst['id']):
82
87
            inst_dict['status'] = 'RESIZE-CONFIRM'
83
88
 
112
117
    """Model an Openstack API V1.0 server response."""
113
118
 
114
119
    def _build_image(self, response, inst):
115
 
        if 'image_id' in dict(inst):
116
 
            response['imageId'] = inst['image_id']
 
120
        if 'image_ref' in dict(inst):
 
121
            image_ref = inst['image_ref']
 
122
            if str(image_ref).startswith('http'):
 
123
                raise exception.ListingImageRefsNotSupported()
 
124
            response['imageId'] = int(image_ref)
117
125
 
118
126
    def _build_flavor(self, response, inst):
119
127
        if 'instance_type' in dict(inst):
130
138
        self.base_url = base_url
131
139
 
132
140
    def _build_image(self, response, inst):
133
 
        if "image_id" in dict(inst):
134
 
            image_id = inst.get("image_id")
135
 
            response["imageRef"] = self.image_builder.generate_href(image_id)
 
141
        if 'image_ref' in dict(inst):
 
142
            image_href = inst['image_ref']
 
143
            if str(image_href).isdigit():
 
144
                image_href = int(image_href)
 
145
            response['imageRef'] = image_href
136
146
 
137
147
    def _build_flavor(self, response, inst):
138
148
        if "instance_type" in dict(inst):