Exemplo n.º 1
0
 def find_se_interfaces_for_domain_names(se_links, mappings, src_domain, dst_domain):
     se_interfaces_matches = set()
     for se_link in se_links:
         #if tn_interface in se_link.get("component_id"):
         se_link_interfaces = [ FormatUtils.clean_tn_stp_cid(iface.get("component_id")) for iface in se_link.get("interface_ref") ]
         # Both source and destination must exist in an SE-SE link
         src_alias = [ src_domain ]
         src_alias.extend([ dom for dom in OrgUtils.get_organisation_mappings(src_domain) ])
         # Looking for matches in src and dst domains. Using ":" as delimiter
         src_alias_match = any([ ":"+alias+":" in iface for alias in src_alias for iface in se_link_interfaces ])
         dst_alias = [ dst_domain ]
         dst_alias.extend([ dom for dom in OrgUtils.get_organisation_mappings(dst_domain) ])
         dst_alias_match = any([ ":"+alias+":" in iface for alias in dst_alias for iface in se_link_interfaces ])
         if src_alias_match and dst_alias_match:
             se_link_interfaces = [ FormatUtils.clean_tn_stp_cid(iface.get("component_id")) for iface in se_link.get("interface_ref") ]
             candidate_set = (se_link_interfaces[0], se_link_interfaces[1])
             if not set(candidate_set).issubset(se_interfaces_matches):
                 se_interfaces_matches.add(tuple(candidate_set))
     # Convert from set to tuple to avoid unhashable problems later on
     return tuple(se_interfaces_matches)
Exemplo n.º 2
0
 def find_tn_interfaces_for_domain(self, domain_name):
     # Given a domain name (e.g. "kddi", "aist"), find possible TN ifaces
     tn_interfaces_cids = self.get_tn_interfaces_cids(clean=True)
     domain_names_alt = OrgUtils.get_organisation_mappings(domain_name)
     return FilterUtils.find_tn_interfaces_for_domain(
         tn_interfaces_cids, domain_names_alt, domain_name)