'Create an attachment.
This method can be used to create an empty attachment (reserve) or to
create and initialize a volume attachment based on the provided input
parameters.
If the caller does not yet have the connector information but needs to
reserve an attachment for the volume (ie Nova BootFromVolume) the
create can be called with just the volume-uuid and the server
identifier. This will reserve an attachment, mark the volume as
reserved and prevent any new attachment_create calls from being made
until the attachment is updated (completed).
The alternative is that the connection can be reserved and initialized
all at once with a single call if the caller has all of the required
information (connector data) at the time of the call.
NOTE: In Nova terms server == instance, the server_id parameter
referenced below is the UUID of the Instance, for non-nova consumers
this can be a server UUID or some other arbitrary unique identifier.
Expected format of the input parameter \'body\':
.. code-block:: json
"attachment":
"volume_uuid": "volume-uuid",
"instance_uuid": "nova-server-uuid",
"connector": "null|<connector-object>"
Example connector:
.. code-block:: json
"connector":
"initiator": "iqn.1993-08.org.debian:01:cad181614cec",
"ip":"192.168.1.20",
"platform": "x86_64",
"host": "tempest-1",
"os_type": "linux2",
"multipath": false,
"mountpoint": "/dev/vdb",
"mode": "null|rw|ro"
NOTE all that\'s required for a reserve is volume_uuid
and a instance_uuid.
returns: A summary view of the attachment object'

@wsgi.Controller.api_version(API_VERSION)
@wsgi.response(202)
def create(self, req, body):

    context = req.environ['cinder.context']
    instance_uuid = body['attachment'].get('instance_uuid', None)
    if (not instance_uuid):
        raise webob.exc.HTTPBadRequest(explanation=_("Must    specify    'instance_uuid'    to    create    attachment."))
    volume_uuid = body['attachment'].get('volume_uuid', None)
    if (not volume_uuid):
        raise webob.exc.HTTPBadRequest(explanation=_("Must    specify    'volume_uuid'    to    create    attachment."))
    volume_ref = objects.Volume.get_by_id(context, volume_uuid)
    connector = body['attachment'].get('connector', None)
    err_msg = None
    try:
        attachment_ref = self.volume_api.attachment_create(context, volume_ref, instance_uuid, connector=connector)
    except exception.NotAuthorized:
        raise
    except exception.CinderException as ex:
        err_msg = (_('Unable    to    create    attachment    for    volume    (%s).') % ex.msg)
        LOG.exception(err_msg)
    except Exception as ex:
        err_msg = _('Unable    to    create    attachment    for    volume.')
        LOG.exception(err_msg)
    finally:
        if err_msg:
            raise webob.exc.HTTPInternalServerError(explanation=err_msg)
    return attachment_views.ViewBuilder.detail(attachment_ref)
