'Prepare volume for connection from host represented by connector.
This method calls the driver initialize_connection and returns
it to the caller.  The connector parameter is a dictionary with
information about the host that will connect to the volume in the
following format::
.. code:: json
\'ip\': ip,
\'initiator\': initiator,
ip: the ip address of the connecting machine
initiator: the iscsi initiator name of the connecting machine.
This can be None if the connecting machine does not support iscsi
connections.
driver is responsible for doing any necessary security setup and
returning a connection_info dictionary in the following format::
.. code:: json
\'driver_volume_type\': driver_volume_type,
\'data\': data,
driver_volume_type: a string to identify the type of volume.  This
can be used by the calling code to determine the
strategy for connecting to the volume. This could
be \'iscsi\', \'rbd\', \'sheepdog\', etc.
data: this is the data that the calling code will use to connect
to the volume. Keep in mind that this will be serialized to
json in various places, so it should not contain any non-json
data types.'

def initialize_connection(self, context, volume, connector):

    utils.require_driver_initialized(self.driver)
    try:
        self.driver.validate_connector(connector)
    except exception.InvalidConnectorException as err:
        raise exception.InvalidInput(reason=six.text_type(err))
    except Exception as err:
        err_msg = (_('Validate    volume    connection    failed    (error:    %(err)s).') % {'err': six.text_type(err)})
        LOG.exception(err_msg, resource=volume)
        raise exception.VolumeBackendAPIException(data=err_msg)
    try:
        model_update = self.driver.create_export(context.elevated(), volume, connector)
    except exception.CinderException as ex:
        msg = (_('Create    export    of    volume    failed    (%s)') % ex.msg)
        LOG.exception(msg, resource=volume)
        raise exception.VolumeBackendAPIException(data=msg)
    try:
        if model_update:
            volume.update(model_update)
            volume.save()
    except Exception as ex:
        LOG.exception('Model    update    failed.', resource=volume)
        try:
            self.driver.remove_export(context.elevated(), volume)
        except Exception:
            LOG.exception('Could    not    remove    export    after    DB    model    failed.')
        raise exception.ExportFailure(reason=six.text_type(ex))
    try:
        conn_info = self.driver.initialize_connection(volume, connector)
    except Exception as err:
        err_msg = (_('Driver    initialize    connection    failed    (error:    %(err)s).') % {'err': six.text_type(err)})
        LOG.exception(err_msg, resource=volume)
        self.driver.remove_export(context.elevated(), volume)
        raise exception.VolumeBackendAPIException(data=err_msg)
    conn_info = self._parse_connection_options(context, volume, conn_info)
    LOG.info('Initialize    volume    connection    completed    successfully.', resource=volume)
    return conn_info
