示例#1
0
文件: filter.py 项目: ict-felix/stack
    def prune_unlinked_dpids(mapping_path_structure, dpids_src_list, dpids_dst_list, check_by_auth=False):
        """
        Prunes those paths that do not conform to the passed SRC and DST DPID list.
        That is, the resulting paths must contain at least all the required SRC and DST DPIDs.

        @param check_by_auth when True, checks if the path contains a DPID with the required authority
                             when False, looks for exact DPIDs on the path
        """
        new_mapping_path_structure = []
        for idx, mapping_path_element in enumerate(mapping_path_structure):
            # Source sets
            src_dpids_avail = set([ x["sdn"] for x in mapping_path_element["src"]["links"] ])
            # Destination sets
            dst_dpids_avail = set([ x["sdn"] for x in mapping_path_element["dst"]["links"] ])
            if check_by_auth:
                src_dpids_auth_avail = set(OrgUtils.get_authority(x) for x in src_dpids_avail)
                src_dpids_auth_req = set(OrgUtils.get_authority(x) for x in dpids_src_list)
                dst_dpids_auth_avail = set(OrgUtils.get_authority(x) for x in dst_dpids_avail)
                dst_dpids_auth_req = set(OrgUtils.get_authority(x) for x in dpids_dst_list)
                src_dpids_auth_match = src_dpids_auth_avail.intersection(src_dpids_auth_req)
                dst_dpids_auth_match = dst_dpids_auth_avail.intersection(dst_dpids_auth_req)
                # Loose check -> the authorities of the requested DPIDs must match
                full_match = len(src_dpids_auth_match) == len(src_dpids_auth_req) and len(dst_dpids_auth_match) == len(dst_dpids_auth_req)
            else:
                src_dpids_match = src_dpids_avail.intersection(dpids_src_list)
                dst_dpids_match = dst_dpids_avail.intersection(dpids_dst_list)
                # Tight check -> all requested DPIDs must be present (i.e. intersected with the available DPIDs)
                full_match = len(src_dpids_match) == len(dpids_src_list) and len(dst_dpids_match) == len(dpids_dst_list)
            if full_match:
                new_mapping_path_structure.append(mapping_path_element)
        return new_mapping_path_structure
示例#2
0
文件: filter.py 项目: ict-felix/stack
 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)
示例#3
0
文件: filter.py 项目: ict-felix/stack
 def find_se_interfaces_for_tn_interface(se_links, tn_interface):
     se_interfaces_match = 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") ]
         # Checks:
         # 1. TN interface is connected to some SE interface
         # 2. Same authority for both (e.g. control AIST/AIST2 DC case)
         if tn_interface in se_link_interfaces \
                 and OrgUtils.check_auth_alt_se_in_mappings(se_link_interfaces):
             se_link_interfaces = [ FormatUtils.clean_tn_stp_cid(iface.get("component_id")) for iface in se_link.get("interface_ref") ]
             # Remove link interface that matches with the passed TN interface
             se_link_interfaces.pop(se_link_interfaces.index(tn_interface))
             se_interfaces_match.add(se_link_interfaces[0])
     # Convert from set to tuple to avoid unhashable problems later on
     return tuple(se_interfaces_match)
示例#4
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)