'Driver entry point to attach a volume to an instance.'

@debugger
def initialize_connection(self, volume, connector):

    if getattr(self.configuration, 'use_chap_auth', False):
        chap_username = getattr(self.configuration, 'chap_username', '')
        chap_password = getattr(self.configuration, 'chap_password', '')
    else:
        chap_username = ''
        chap_password = ''
    if (volume['provider_location'] is None):
        params = list()
        (pool, project, volume_name) = self._get_pool_project_volume_name(volume)
        params.append(('%s/%s/%s/%s' % (pool, TEGILE_LOCAL_CONTAINER_NAME, project, volume_name)))
        initiator_info = {'initiatorName': connector['initiator'], 'chapUserName': chap_username, 'chapSecret': chap_password}
        params.append(initiator_info)
        mapping_info = self._api_executor.send_api_request(method='getISCSIMappingForVolume', params=params)
        target_portal = mapping_info['target_portal']
        target_iqn = mapping_info['target_iqn']
        target_lun = mapping_info['target_lun']
    else:
        (target_portal, target_iqn, target_lun) = volume['provider_location'].split()
    connection_data = dict()
    connection_data['target_portal'] = target_portal
    connection_data['target_iqn'] = target_iqn
    connection_data['target_lun'] = int(target_lun)
    connection_data['target_discovered'] = (False,)
    connection_data['volume_id'] = (volume['id'],)
    connection_data['discard'] = False
    if getattr(self.configuration, 'use_chap_auth', False):
        connection_data['auth_method'] = 'CHAP'
        connection_data['auth_username'] = chap_username
        connection_data['auth_password'] = chap_password
    return {'driver_volume_type': 'iscsi', 'data': connection_data}
