def _build_ini_tgt_map(self, wwns, need_add_con, nsinfos, cfgmap_from_fabrics):
    tgt_port_wwns = []
    init_targ_map_total = {}
    fabric_maps = {}
    for contr in controller_list:
        port_list_from_contr = self.client.get_fc_ports_from_contr(contr)
        if port_list_from_contr:
            fabric_map = self.zm.get_san_context(port_list_from_contr)
            fabric_maps[contr] = fabric_map
    for wwn in wwns:
        init_targ_map = {}
        tmp_port_list = []
        tgt_port_for_map = []
        tmp_flag = False
        need_new_zone = False
        for contr in fabric_maps:
            (fc_port_for_zone, tmp_flag) = self._get_one_fc_port_for_zone(wwn, contr, nsinfos, cfgmap_from_fabrics, fabric_maps)
            if tmp_flag:
                need_new_zone = True
            if fc_port_for_zone:
                tgt_port_wwns.append(fc_port_for_zone)
                if (not tmp_flag):
                    tgt_port_for_map.append(fc_port_for_zone)
                if tmp_flag:
                    tmp_port_list.append(fc_port_for_zone)
        init_targ_map[wwn] = tmp_port_list
        LOG.debug(('tmp_port_list: %s' % tmp_port_list))
        init_targ_map_total[wwn] = tgt_port_for_map
        if (need_new_zone and need_add_con):
            LOG.debug(('Got init_targ_map to create zone: %s' % init_targ_map))
            self.zm.add_connection(init_targ_map)
    tgt_port_wwns = list(set(tgt_port_wwns))
    return (tgt_port_wwns, init_targ_map_total)
def _build_ini_tgt_map(self, wwns, need_add_con, nsinfos, cfgmap_from_fabrics):
    tgt_port_wwns = []
    init_targ_map_total = {}
    fabric_maps = {}
    for contr in controller_list:
        port_list_from_contr = self.client.get_fc_ports_from_contr(contr)
        if port_list_from_contr:
            fabric_map = self.zm.get_san_context(port_list_from_contr)
            fabric_maps[contr] = fabric_map
    for wwn in wwns:
        init_targ_map = {}
        tmp_port_list = []
        tgt_port_for_map = []
        tmp_flag = False
        need_new_zone = False
        for contr in fabric_maps:
            (fc_port_for_zone, tmp_flag) = self._get_one_fc_port_for_zone(wwn, contr, nsinfos, cfgmap_from_fabrics, fabric_maps)
            if tmp_flag:
                need_new_zone = True
            if fc_port_for_zone:
                tgt_port_wwns.append(fc_port_for_zone)
                if (not tmp_flag):
                    tgt_port_for_map.append(fc_port_for_zone)
                if tmp_flag:
                    tmp_port_list.append(fc_port_for_zone)
        init_targ_map[wwn] = tmp_port_list
        LOG.debug(('tmp_port_list: %s' % tmp_port_list))
        init_targ_map_total[wwn] = tgt_port_for_map
        if (need_new_zone and need_add_con):
            LOG.debug(('Got init_targ_map to create zone: %s' % init_targ_map))
            self.zm.add_connection(init_targ_map)
    tgt_port_wwns = list(set(tgt_port_wwns))
    return (tgt_port_wwns, init_targ_map_total)