~nova-coresec/nova/ppa-lucid

« back to all changes in this revision

Viewing changes to nova/objectstore/image.py

  • Committer: Soren Hansen
  • Date: 2010-10-20 02:31:51 UTC
  • mfrom: (195.1.88 ubuntu-packaging)
  • Revision ID: soren.hansen@rackspace.com-20101020023151-pzo6st38dd8xdo81
Merge ubuntu packaging branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        try:
73
73
            return (self.metadata['isPublic'] and readonly) or \
74
74
                   context.user.is_admin() or \
75
 
                   self.metadata['imageOwnerId'] == context.project.id
 
75
                   self.metadata['imageOwnerId'] == context.project_id
76
76
        except:
77
77
            return False
78
78
 
133
133
 
134
134
        @type public: bool
135
135
        @param public: determine if this is a public image or private
136
 
        
 
136
 
137
137
        @rtype: str
138
138
        @return: a string with the image id
139
139
        """
140
 
        
 
140
 
141
141
        image_type = 'machine'
142
142
        image_id = utils.generate_uid('ami')
143
143
 
162
162
            'imageType': image_type,
163
163
            'state': 'available'
164
164
        }
165
 
        
 
165
 
166
166
        if type(kernel) is str and len(kernel) > 0:
167
167
            info['kernelId'] = kernel
168
168
 
191
191
            if kernel_id == 'true':
192
192
                image_type = 'kernel'
193
193
        except:
194
 
            pass
 
194
            kernel_id = None
195
195
 
196
196
        try:
197
197
            ramdisk_id = manifest.find("machine_configuration/ramdisk_id").text
198
198
            if ramdisk_id == 'true':
199
199
                image_type = 'ramdisk'
200
200
        except:
201
 
            pass
 
201
            ramdisk_id = None
202
202
 
203
203
        info = {
204
204
            'imageId': image_id,
205
205
            'imageLocation': image_location,
206
 
            'imageOwnerId': context.project.id,
 
206
            'imageOwnerId': context.project_id,
207
207
            'isPublic': False, # FIXME: grab public from manifest
208
208
            'architecture': 'x86_64', # FIXME: grab architecture from manifest
209
209
            'imageType' : image_type
210
210
        }
211
211
 
 
212
        if kernel_id:
 
213
            info['kernelId'] = kernel_id
 
214
 
 
215
        if ramdisk_id:
 
216
            info['ramdiskId'] = ramdisk_id
 
217
 
212
218
        def write_state(state):
213
219
            info['imageState'] = state
214
220
            with open(os.path.join(image_path, 'info.json'), "w") as f:
243
249
    @staticmethod
244
250
    def decrypt_image(encrypted_filename, encrypted_key, encrypted_iv, cloud_private_key, decrypted_filename):
245
251
        key, err = utils.execute(
246
 
                'openssl rsautl -decrypt -inkey %s' % cloud_private_key, 
 
252
                'openssl rsautl -decrypt -inkey %s' % cloud_private_key,
247
253
                process_input=encrypted_key,
248
254
                check_exit_code=False)
249
255
        if err:
250
256
            raise exception.Error("Failed to decrypt private key: %s" % err)
251
257
        iv, err = utils.execute(
252
 
                'openssl rsautl -decrypt -inkey %s' % cloud_private_key, 
 
258
                'openssl rsautl -decrypt -inkey %s' % cloud_private_key,
253
259
                process_input=encrypted_iv,
254
260
                check_exit_code=False)
255
261
        if err: