'Maps volume to instance.
Maps a volume to the nova volume node as host,
and return the created lun id'

def _vol_map_and_get_lun_id(self, volume, connector, host):

    vol_name = volume['name']
    LOG.debug('_vol_map_and_get_lun_id    %(volume)s', {'volume': vol_name})
    try:
        mapped_vols = self._call_xiv_xcli('vol_mapping_list', vol=vol_name).as_dict('host')
        if (host['name'] in mapped_vols):
            LOG.info("Volume    '%(volume)s'    was    already    attached    to    the    host    '%(host)s'.", {'host': host['name'], 'volume': volume['name']})
            return int(mapped_vols[host['name']].lun)
    except errors.VolumeBadNameError:
        LOG.error("Volume    not    found.    '%s'", volume['name'])
        raise self.meta['exception'].VolumeNotFound(volume_id=volume['id'])
    used_luns = [int(mapped.get('lun')) for mapped in self._call_xiv_xcli('mapping_list', host=host['name']).as_list]
    luns = six.moves.xrange(MIN_LUNID, MAX_LUNID)
    for lun_id in luns:
        if (lun_id not in used_luns):
            self._call_xiv_xcli('map_vol', lun=lun_id, host=host['name'], vol=vol_name)
            self._event_volume_attached()
            return lun_id
    msg = _('All    free    LUN    IDs    were    already    mapped.')
    LOG.error(msg)
    raise self._get_exception()(msg)
