'Adds a new image to Glance. Four scenarios exist when creating an
image:
1. If the image data is available directly for upload, create can be
passed the image data as the request body and the metadata as the
request headers. The image will initially be \'queued\', during
upload it will be in the \'saving\' status, and then \'killed\' or
\'active\' depending on whether the upload completed successfully.
2. If the image data exists somewhere else, you can upload indirectly
from the external source using the x-glance-api-copy-from header.
Once the image is uploaded, the external store is not subsequently
consulted, i.e. the image content is served out from the configured
glance image store.  State transitions are as for option #1.
3. If the image data exists somewhere else, you can reference the
source using the x-image-meta-location header. The image content
will be served out from the external store, i.e. is never uploaded
to the configured glance image store.
4. If the image data is not available yet, but you\'d like reserve a
spot for it, you can omit the data and a record will be created in
the \'queued\' state. This exists primarily to maintain backwards
compatibility with OpenStack/Rackspace API semantics.
The request body *must* be encoded as application/octet-stream,
otherwise an HTTPBadRequest is returned.
Upon a successful save of the image data and metadata, a response
containing metadata about the image is returned, including its
opaque identifier.
:param req: The WSGI/Webob Request object
:param image_meta: Mapping of metadata about image
:param image_data: Actual image data that is to be stored
:raises HTTPBadRequest: if x-image-meta-location is missing
and the request body is not application/octet-stream
image data.'

@utils.mutating
def create(self, req, image_meta, image_data):

    self._enforce(req, 'add_image')
    is_public = image_meta.get('is_public')
    if is_public:
        self._enforce(req, 'publicize_image')
    if Controller._copy_from(req):
        self._enforce(req, 'copy_from')
    if (image_data or Controller._copy_from(req)):
        self._enforce(req, 'upload_image')
    self._enforce_create_protected_props(image_meta['properties'].keys(), req)
    self._enforce_image_property_quota(image_meta, req=req)
    image_meta = self._reserve(req, image_meta)
    id = image_meta['id']
    image_meta = self._handle_source(req, id, image_meta, image_data)
    location_uri = image_meta.get('location')
    if location_uri:
        self.update_store_acls(req, id, location_uri, public=is_public)
    image_meta = redact_loc(image_meta)
    return {'image_meta': image_meta}
