~ubuntu-branches/ubuntu/precise/glance/precise-updates

« back to all changes in this revision

Viewing changes to glance/api/v1/images.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2012-06-24 03:14:33 UTC
  • mfrom: (1.1.38)
  • Revision ID: package-import@ubuntu.com-20120624031433-2w4c7hzhb2d28yo0
Tags: 2012.1.3+stable~20120821-120fcf-0ubuntu1
* New upstream snapshot. (LP: #1041120)
* Resynchronzie with stable/essex:
  - Glance add uploads a double image if using ssl and images is smaller
    than 4k. (LP: #1007093)
  - If response.environ is None, instance fails to spawn.
    (LP: #1010560)
  - exception.BadStoreURL exposes sensitive information to end users.
    (LP: #1012268)
  - glance-cache.conf needs metadata encryption key (LP: #1012752)
  - image.upload notification doesn't report size (LP: #1018246)
  - Admins should be able to share image regardless of ownership.
    (LP: #1021054)
  - Glance scrubber date formatting fails with postgres (LP: #1022369)
  - Support zero-size image creation. (LP: #1025353)
  - Image id not contained in swift chunk debug message. (LP: #1028433)
  - qpid_heartbeat setting is ineffective. (LP: #1032314)
  - Image properties that reference image ids are not updated to UUIDs.
    (LP: #975651)
  - Migration 012_id_to_uuid attempts to convert IDs twice for non-sqlite 
    databases. (LP: #975655)
  - multiprocess glance-api failed to exit when stopped by ctrl+c.
    (LP: #978130)
  - /usr/bin/glance's built-in pager breaks redirection.
    (LP: #978610)
  - Content-Length and Transfer-Encoding are mutually exclusive HTTP headers
    (LP: #981332)
  - glance add command - incorrect help text (LP: #997565)
* debian/patches/convert_properties_to_uuid.patch: Dropped no longer
  needed.
* debian/patches/fix-pep8-ubuntu.patch: Dropped no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
272
272
        self._enforce(req, 'get_image')
273
273
        image_meta = self.get_active_image_meta_or_404(req, id)
274
274
 
275
 
        image_iterator, size = self._get_from_store(image_meta['location'])
276
 
        image_meta['size'] = size or image_meta['size']
 
275
        if image_meta.get('size') == 0:
 
276
            image_iterator = iter([])
 
277
        else:
 
278
            image_iterator, size = self._get_from_store(image_meta['location'])
 
279
            image_meta['size'] = size or image_meta['size']
277
280
 
278
281
        del image_meta['location']
279
282
        return {
295
298
        :raises HTTPBadRequest if image metadata is not valid
296
299
        """
297
300
        location = self._external_source(image_meta, req)
 
301
 
 
302
        image_meta['status'] = ('active' if image_meta.get('size') == 0
 
303
                                else 'queued')
 
304
 
298
305
        if location:
299
306
            store = get_store_from_location(location)
300
307
            # check the store exists before we hit the registry, but we
309
316
            # to a non-zero value during upload
310
317
            image_meta['size'] = image_meta.get('size', 0)
311
318
 
312
 
        image_meta['status'] = 'queued'
313
 
 
314
319
        try:
315
320
            image_meta = registry.add_image_metadata(req.context, image_meta)
316
321
            return image_meta
410
415
            logger.debug(_("Updating image %(image_id)s data. "
411
416
                         "Checksum set to %(checksum)s, size set "
412
417
                         "to %(size)d"), locals())
413
 
            registry.update_image_metadata(req.context, image_id,
414
 
                                           {'checksum': checksum,
415
 
                                            'size': size})
 
418
            update_data = {'checksum': checksum,
 
419
                           'size': size}
 
420
            image_meta = registry.update_image_metadata(req.context,
 
421
                                                        image_id,
 
422
                                                        update_data)
416
423
            self.notifier.info('image.upload', image_meta)
417
424
 
418
425
            return location
905
912
                                             image_meta, response.request)
906
913
 
907
914
            # Add hook to process after response is fully sent
908
 
            if 'eventlet.posthooks' in response.environ:
909
 
                response.environ['eventlet.posthooks'].append(
 
915
            if 'eventlet.posthooks' in response.request.environ:
 
916
                response.request.environ['eventlet.posthooks'].append(
910
917
                    (notify_image_sent_hook, (), {}))
911
918
 
912
919
            try: