Beispiel #1
0
 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 = [ PathFinderTNtoSDNFormatUtils.clean_tn_stp_cid(iface.get("component_id")) for iface in se_link.get("interface_ref") ]
         if tn_interface in se_link_interfaces:
             se_link_interfaces = [ PathFinderTNtoSDNFormatUtils.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)
Beispiel #2
0
 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)
Beispiel #3
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 = [ PathFinderTNtoSDNFormatUtils.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 PathFinderTNtoSDNFilterUtils.get_organisation_mappings(mappings, src_domain) ])
         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 PathFinderTNtoSDNFilterUtils.get_organisation_mappings(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 = [ PathFinderTNtoSDNFormatUtils.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)
Beispiel #4
0
 def get_se_interfaces_cid_from_link(se_link, clean=False):
     # Return a list with a set of two component_id values for the given SE link
     interfaces = se_link.get("interface_ref", {})
     processed_interfaces = []
     for interface in interfaces:
         processed_interface = interface.get("component_id", "")
         if clean == True:
             # Some of the SE links are SE-TN links
             processed_interface = FormatUtils.clean_tn_stp_cid(processed_interface)
         processed_interfaces.append(processed_interface)
     return list(set(processed_interfaces))
Beispiel #5
0
 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 = [
             PathFinderTNtoSDNFormatUtils.clean_tn_stp_cid(
                 iface.get("component_id"))
             for iface in se_link.get("interface_ref")
         ]
         if tn_interface in se_link_interfaces:
             se_link_interfaces = [
                 PathFinderTNtoSDNFormatUtils.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)
Beispiel #6
0
 def get_se_interfaces_cid_from_link(se_link, clean=False):
     # Return a list with a set of two component_id values for the given SE link
     interfaces = se_link.get("interface_ref", {})
     processed_interfaces = []
     for interface in interfaces:
         processed_interface = interface.get("component_id", "")
         if clean == True:
             # Some of the SE links are SE-TN links
             processed_interface = PathFinderTNtoSDNFormatUtils.clean_tn_stp_cid(
                 processed_interface)
         processed_interfaces.append(processed_interface)
     return list(set(processed_interfaces))
Beispiel #7
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 = [
             PathFinderTNtoSDNFormatUtils.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 PathFinderTNtoSDNFilterUtils.
             get_organisation_mappings(mappings, src_domain)
         ])
         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 PathFinderTNtoSDNFilterUtils.
             get_organisation_mappings(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 = [
                 PathFinderTNtoSDNFormatUtils.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)
    def find_path_tn(self):
        # Retrieve list of CIDs for TNRM interfaces
        tn_interfaces_cids = self.get_tn_interfaces_cids(clean=True)

        # Get proper TN interfaces for both SRC and DST TN interfaces
        self.mapping_tn_se_of_src_partial = {}
        self.mapping_tn_se_of_dst_partial = {}

        # Get proper TN interfaces for (SRC, DST) TN interface
        for src_dst_value in self.src_dst_values:
            # Do a first clean of SRC and DST interface
            src_dst_cid = FormatUtils.clean_tn_stp_cid(getattr(self, "%s_dom" % src_dst_value))
            dst_src_tn_interface_found = False
            # Playing a bit with the language to be able
            # to have all the processing in a single place
            for tn_interface_cid in tn_interfaces_cids:
                if src_dst_cid in tn_interface_cid and src_dst_cid.startswith("urn"):
                    dst_src_tn_interface_found = True
                    break

            if dst_src_tn_interface_found == True:
                setattr(self, "tn_candidates_%s" % src_dst_value, [ src_dst_cid ])
            else:
                # Set is converted to list for easyness
                list_interfaces = map(list, self.find_tn_interfaces_for_domain(src_dst_cid))[0]
                # NOTE: only the first TN interface is retrieved...
                # Filter by link type, if requested by user
                setattr(self, "tn_candidates_%s" % src_dst_value, list(\
                    self.filter_tn_interfaces_by_type(list_interfaces, self.link_type)))

            # Initialize structure with dictionary and append SRC and DST interfaces to the set
            setattr(self, "mapping_tn_se_of_%s_partial" % src_dst_value, { "tn": set() })
            for tn_candidate in getattr(self, "tn_candidates_%s" % src_dst_value):
                mapping_partial = getattr(self, "mapping_tn_se_of_%s_partial" % src_dst_value)
                mapping_partial["tn"].add(tn_candidate)

        # Place every path into the final structure
        #combinations_src_dst_stps = zip(self.mapping_tn_se_of_src_partial["tn"], self.mapping_tn_se_of_dst_partial["tn"])
        # Find all possible combinations (order-independent)
        src_stps = self.mapping_tn_se_of_src_partial["tn"]
        dst_stps = self.mapping_tn_se_of_dst_partial["tn"]
        combinations_src_dst_stps = CombinationUtils.yield_combinations_stp_pairs(src_stps, dst_stps)
        # Filter out combinations whose STP have different types (i.e. NSI-GRE)
        combinations_src_dst_stps_filter = []
        for src_dst_stp in combinations_src_dst_stps:
            stp_link_tmp = FilterUtils.ensure_same_type_tn_interfaces([src_dst_stp[0], src_dst_stp[1]])
            if len(stp_link_tmp) == 2:
                combinations_src_dst_stps_filter.append(stp_link_tmp)
        combinations_src_dst_stps = combinations_src_dst_stps_filter
        for tn_src_dst_pair in combinations_src_dst_stps:
            # Tuple: 1st element (src), 2nd element (dst)
            self.mapping_tn_se_of.append({"src": {"tn": tn_src_dst_pair[0]}, "dst": {"tn": tn_src_dst_pair[1]}})
Beispiel #9
0
    def find_path_tn(self):
        # Retrieve list of CIDs for TNRM interfaces
        tn_interfaces_cids = self.get_tn_interfaces_cids(clean=True)

        # Get proper TN interfaces for both SRC and DST TN interfaces
        self.mapping_tn_se_of_src_partial = {}
        self.mapping_tn_se_of_dst_partial = {}

        # Get proper TN interfaces for (SRC, DST) TN interface
        for src_dst_value in self.src_dst_values:
            # Do a first clean of SRC and DST interface
            src_dst_cid = FormatUtils.clean_tn_stp_cid(
                getattr(self, "%s_dom" % src_dst_value))
            dst_src_tn_interface_found = False
            # Playing a bit with the language to be able
            # to have all the processing in a single place
            for tn_interface_cid in tn_interfaces_cids:
                if src_dst_cid in tn_interface_cid and src_dst_cid.startswith(
                        "urn"):
                    dst_src_tn_interface_found = True
                    break

            if dst_src_tn_interface_found == True:
                setattr(self, "tn_candidates_%s" % src_dst_value,
                        [src_dst_cid])
            else:
                # Set is converted to list for easyness
                list_interfaces = map(
                    list, self.find_tn_interfaces_for_domain(src_dst_cid))[0]
                # NOTE: only the first TN interface is retrieved...
                # Filter by link type, if requested by user
                setattr(self, "tn_candidates_%s" % src_dst_value, list(\
                    self.filter_tn_interfaces_by_type(list_interfaces, self.link_type)))

            # Initialize structure with dictionary and append SRC and DST interfaces to the set
            setattr(self, "mapping_tn_se_of_%s_partial" % src_dst_value,
                    {"tn": set()})
            for tn_candidate in getattr(self,
                                        "tn_candidates_%s" % src_dst_value):
                mapping_partial = getattr(
                    self, "mapping_tn_se_of_%s_partial" % src_dst_value)
                mapping_partial["tn"].add(tn_candidate)

        # Place every path into the final structure
        #combinations_src_dst_stps = zip(self.mapping_tn_se_of_src_partial["tn"], self.mapping_tn_se_of_dst_partial["tn"])
        # Find all possible combinations (order-independent)
        src_stps = self.mapping_tn_se_of_src_partial["tn"]
        dst_stps = self.mapping_tn_se_of_dst_partial["tn"]
        combinations_src_dst_stps = CombinationUtils.yield_combinations_stp_pairs(
            src_stps, dst_stps)
        # Filter out combinations whose STP have different types (i.e. NSI-GRE)
        combinations_src_dst_stps_filter = []
        for src_dst_stp in combinations_src_dst_stps:
            stp_link_tmp = FilterUtils.ensure_same_type_tn_interfaces(
                [src_dst_stp[0], src_dst_stp[1]])
            if len(stp_link_tmp) == 2:
                combinations_src_dst_stps_filter.append(stp_link_tmp)
        combinations_src_dst_stps = combinations_src_dst_stps_filter
        for tn_src_dst_pair in combinations_src_dst_stps:
            # Tuple: 1st element (src), 2nd element (dst)
            self.mapping_tn_se_of.append({
                "src": {
                    "tn": tn_src_dst_pair[0]
                },
                "dst": {
                    "tn": tn_src_dst_pair[1]
                }
            })