'Map a volume to a host and return target iSCSI information.'

@utils.synchronized('zte_locked_initialize_connection')
def initialize_connection(self, volume, connector):

    initiator_name = connector['initiator']
    volume_name = self._translate_volume_name(volume['name'])
    LOG.debug('initialize_connection:    Volume    name:    %(volume)s.    Initiator    name:    %(ini)s.', {'volume': volume_name, 'ini': initiator_name})
    iscsi_conf = self._get_iscsi_info()
    target_ips = iscsi_conf['DefaultTargetIPs']
    target_portals = {}
    target_iqns = []
    for ip in target_ips:
        iqn = self._get_tgt_iqn(ip)
        if iqn:
            if (iqn not in target_iqns):
                target_iqns.append(iqn)
                target_portals[iqn] = [('%s:%s' % (ip, '3260'))]
            else:
                target_portals[iqn].append(('%s:%s' % (ip, '3260')))
    if (not target_iqns):
        msg = (_('Failed    to    get    target    ip    or    iqn    for    initiator    %(ini)s,    please    check    config    file.') % {'ini': initiator_name})
        raise exception.VolumeDriverException(message=msg)
    map_group_name = self._translate_grp_name(initiator_name)
    lunid = self._map_lun(initiator_name, volume_name, map_group_name)
    properties = {'target_discovered': False, 'target_portal': target_portals[target_iqns[0]][0], 'target_iqn': target_iqns[0], 'target_lun': lunid, 'volume_id': volume['id']}
    if (target_iqns and target_portals):
        properties['target_portals'] = target_portals
        properties['target_iqns'] = target_iqns
    return {'driver_volume_type': 'iscsi', 'data': properties}
