~hudson-openstack/glance/milestone-proposed

« back to all changes in this revision

Viewing changes to glance/server.py

Prevent users from uploading images with a bad or missing store. Allow deletion from registry when backend cannot be used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
        :raises HTTPBadRequest if image metadata is not valid
193
193
        """
194
194
        image_meta = utils.get_image_meta_from_headers(req)
 
195
 
 
196
        if 'location' in image_meta:
 
197
            store = get_store_from_location(image_meta['location'])
 
198
            # check the store exists before we hit the registry, but we
 
199
            # don't actually care what it is at this point
 
200
            self.get_store_or_400(req, store)
 
201
 
195
202
        image_meta['status'] = 'queued'
196
203
 
197
204
        # Ensure that the size attribute is set to zero for all
453
460
        # to delete the image if the backend doesn't yet store it.
454
461
        # See https://bugs.launchpad.net/glance/+bug/747799
455
462
        if image['location']:
456
 
            delete_from_backend(image['location'])
 
463
            try:
 
464
                delete_from_backend(image['location'])
 
465
            except (UnsupportedBackend, exception.NotFound):
 
466
                msg = "Failed to delete image from store (%s). " + \
 
467
                      "Continuing with deletion from registry."
 
468
                logger.error(msg % (image['location'],))
457
469
 
458
470
        registry.delete_image_metadata(self.options, id)
459
471