'Adds the image metadata to the registry and assigns
an image identifier if one is not supplied in the request
headers. Sets the image\'s status to `queued`.
:param req: The WSGI/Webob Request object
:param id: The opaque image identifier
:param image_meta: The image metadata
:raises HTTPConflict: if image already exists
:raises HTTPBadRequest: if image metadata is not valid'

def _reserve(self, req, image_meta):

    location = self._external_source(image_meta, req)
    scheme = image_meta.get('store')
    if (scheme and (scheme not in store.get_known_schemes())):
        msg = (_('Required    store    %s    is    invalid') % scheme)
        LOG.warn(msg)
        raise HTTPBadRequest(explanation=msg, content_type='text/plain')
    image_meta['status'] = ('active' if (image_meta.get('size') == 0) else 'queued')
    if location:
        try:
            backend = store.get_store_from_location(location)
        except (store.UnknownScheme, store.BadStoreUri):
            LOG.debug('Invalid    location    %s', location)
            msg = (_('Invalid    location    %s') % location)
            raise HTTPBadRequest(explanation=msg, request=req, content_type='text/plain')
        self.get_store_or_400(req, backend)
        image_meta['size'] = self._get_size(req.context, image_meta, location)
    else:
        image_meta['size'] = image_meta.get('size', 0)
    try:
        image_meta = registry.add_image_metadata(req.context, image_meta)
        self.notifier.info('image.create', redact_loc(image_meta))
        return image_meta
    except exception.Duplicate:
        msg = (_('An    image    with    identifier    %s    already    exists') % image_meta['id'])
        LOG.warn(msg)
        raise HTTPConflict(explanation=msg, request=req, content_type='text/plain')
    except exception.Invalid as e:
        msg = (_('Failed    to    reserve    image.    Got    error:    %s') % encodeutils.exception_to_unicode(e))
        LOG.exception(msg)
        raise HTTPBadRequest(explanation=msg, request=req, content_type='text/plain')
    except exception.Forbidden:
        msg = _('Forbidden    to    reserve    image.')
        LOG.warn(msg)
        raise HTTPForbidden(explanation=msg, request=req, content_type='text/plain')
