'Allow connection to connector and return connection info.'

def initialize_connection(self, volume, connector):

    properties = {}
    properties['target_lun'] = None
    properties['target_discovered'] = True
    properties['target_portal'] = ''
    properties['target_iqn'] = None
    properties['volume_id'] = volume['id']
    dpl_server = self.configuration.san_ip
    dpl_iscsi_port = self.configuration.iscsi_port
    (ret, output) = self.dpl.assign_vdev(self._conver_uuid2hex(volume['id']), connector['initiator'].lower(), volume['id'], ('%s:%d' % (dpl_server, dpl_iscsi_port)), 0)
    if (ret == errno.EAGAIN):
        (ret, event_uuid) = self._get_event_uuid(output)
        if len(event_uuid):
            ret = 0
            status = self._wait_event(self.dpl.get_vdev_status, self._conver_uuid2hex(volume['id']), event_uuid)
            if (status['state'] == 'error'):
                ret = errno.EFAULT
                msg = (_('Flexvisor    failed    to    assign    volume    %(id)s:    %(status)s.') % {'id': volume['id'], 'status': status})
                raise exception.VolumeBackendAPIException(data=msg)
        else:
            ret = errno.EFAULT
            msg = (_('Flexvisor    failed    to    assign    volume    %(id)s    due    to    unable    to    query    status    by    event    id.') % {'id': volume['id']})
            raise exception.VolumeBackendAPIException(data=msg)
    elif (ret != 0):
        msg = (_('Flexvisor    assign    volume    failed.:%(id)s:%(status)s.') % {'id': volume['id'], 'status': ret})
        raise exception.VolumeBackendAPIException(data=msg)
    if (ret == 0):
        (ret, output) = self.dpl.get_vdev(self._conver_uuid2hex(volume['id']))
    if (ret == 0):
        for tgInfo in output['exports']['Network/iSCSI']:
            if (tgInfo['permissions'] and isinstance(tgInfo['permissions'][0], dict)):
                for assign in tgInfo['permissions']:
                    if (connector['initiator'].lower() in assign.keys()):
                        for tgportal in tgInfo.get('portals', {}):
                            properties['target_portal'] = tgportal
                            break
                        properties['target_lun'] = int(assign[connector['initiator'].lower()])
                        break
                if (properties['target_portal'] != ''):
                    properties['target_iqn'] = tgInfo['target_identifier']
                    break
            else:
                if (connector['initiator'].lower() in tgInfo['permissions']):
                    for tgportal in tgInfo.get('portals', {}):
                        properties['target_portal'] = tgportal
                        break
                if (properties['target_portal'] != ''):
                    properties['target_lun'] = int(tgInfo['logical_unit_number'])
                    properties['target_iqn'] = tgInfo['target_identifier']
                    break
    if (not ((ret == 0) or properties['target_portal'])):
        msg = (_('Flexvisor    failed    to    assign    volume    %(volume)s    iqn    %(iqn)s.') % {'volume': volume['id'], 'iqn': connector['initiator']})
        raise exception.VolumeBackendAPIException(data=msg)
    return {'driver_volume_type': 'iscsi', 'data': properties}
