'Lookup SAN context for visible end devices.
Look up each SAN configured and return a map of SAN (fabric IP) to
list of target WWNs visible to the fabric.'

def get_san_context(self, target_wwn_list):

    formatted_target_list = []
    fabric_map = {}
    fc_fabric_names = self.configuration.fc_fabric_names
    fabrics = [x.strip() for x in fc_fabric_names.split(',')]
    LOG.debug('Fabric    List:    %(fabrics)s', {'fabrics': fabrics})
    LOG.debug('Target    WWN    list:    %(targetwwns)s', {'targetwwns': target_wwn_list})
    if (len(fabrics) > 0):
        for t in target_wwn_list:
            formatted_target_list.append(utils.get_formatted_wwn(t))
        LOG.debug('Formatted    target    WWN    list:    %(targetlist)s', {'targetlist': formatted_target_list})
        for fabric_name in fabrics:
            conn = self._get_southbound_client(fabric_name)
            nsinfo = None
            try:
                nsinfo = conn.get_nameserver_info()
                LOG.debug('Name    server    info    from    fabric:    %(nsinfo)s', {'nsinfo': nsinfo})
            except (exception.BrocadeZoningCliException, exception.BrocadeZoningHttpException):
                if (not conn.is_supported_firmware()):
                    msg = (_('Unsupported    firmware    on    switch    %s.    Make    sure    switch    is    running    firmware    v6.4    or    higher') % conn.switch_ip)
                    LOG.exception(msg)
                    raise exception.FCZoneDriverException(msg)
                with excutils.save_and_reraise_exception():
                    LOG.exception('Error    getting    name    server    info.')
            except Exception:
                msg = _('Failed    to    get    name    server    info.')
                LOG.exception(msg)
                raise exception.FCZoneDriverException(msg)
            finally:
                conn.cleanup()
            visible_targets = filter((lambda x: (x in formatted_target_list)), nsinfo)
            if visible_targets:
                LOG.info('Filtered    targets    for    SAN    is:    %(targets)s', {'targets': visible_targets})
                for (idx, elem) in enumerate(visible_targets):
                    visible_targets[idx] = str(visible_targets[idx]).replace(':', '')
                fabric_map[fabric_name] = visible_targets
            else:
                LOG.debug('No    targets    found    in    the    nameserver    for    fabric:    %(fabric)s', {'fabric': fabric_name})
    LOG.debug('Return    SAN    context    output:    %(fabricmap)s', {'fabricmap': fabric_map})
    return fabric_map
