Exemplo n.º 1
0
 def format_structure(self):
     # Restore the full CID of the source and destination TN interfaces
     for mapping in self.mapping_tn_se_of:
         for src_dst_value in self.src_dst_values:
             # Domains connected through static links may not have "tn" data
             if "tn" in mapping[src_dst_value]:
                mapping[src_dst_value]["tn"] = self.format_verify_tn_interface(mapping[src_dst_value]["tn"])
     # Remove paths where either source or destination are invalid
     self.mapping_tn_se_of = FilterUtils.prune_invalid_paths(self.mapping_tn_se_of)
     self.mapping_tn_se_of = FilterUtils.prune_unlinked_dpids(self.mapping_tn_se_of, self.src_of_cids, \
         self.dst_of_cids, self.of_cids_check_by_auth)
     return self.mapping_tn_se_of
Exemplo n.º 2
0
 def format_structure(self):
     # Restore the full CID of the source and destination TN interfaces
     for mapping in self.mapping_tn_se_of:
         for src_dst_value in self.src_dst_values:
             # Domains connected through static links may not have "tn" data
             if "tn" in mapping[src_dst_value]:
                 mapping[src_dst_value][
                     "tn"] = self.format_verify_tn_interface(
                         mapping[src_dst_value]["tn"])
     # Remove paths where either source or destination are invalid
     self.mapping_tn_se_of = FilterUtils.prune_invalid_paths(
         self.mapping_tn_se_of)
     self.mapping_tn_se_of = FilterUtils.prune_unlinked_dpids(self.mapping_tn_se_of, self.src_of_cids, \
         self.dst_of_cids, self.of_cids_check_by_auth)
     return self.mapping_tn_se_of
Exemplo n.º 3
0
 def get_se_interfaces_cids(self, clean=False):
     # Return a list with the component_id values for the SE interfaces
     se_interfaces = set()
     for se_link in self.se_links:
         se_interfaces.add(
             FilterUtils.get_se_interfaces_cid_from_link(se_link, clean))
     return se_interfaces
Exemplo n.º 4
0
 def get_se_interfaces_cids(self, clean=False):
     # Return a list with the component_id values for the SE interfaces
     se_interfaces = set()
     for se_link in self.se_links:
         se_interfaces.add(
             FilterUtils.get_se_interfaces_cid_from_link(se_link, clean))
     return se_interfaces
Exemplo n.º 5
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]}})
Exemplo n.º 6
0
 def find_se_interfaces_for_domain_names(self, src_domain, dst_domain):
     return FilterUtils.find_se_interfaces_for_domain_names(
         self.se_links, OrgUtils.organisation_name_mappings,
         src_domain, dst_domain)
Exemplo n.º 7
0
 def find_se_interfaces_for_tn_interface(self, tn_interface):
     return FilterUtils.find_se_interfaces_for_tn_interface(
         self.se_links, tn_interface)
Exemplo n.º 8
0
 def filter_tn_interfaces_by_type(self, tn_interfaces_cids, link_type=""):
     return FilterUtils.filter_tn_interfaces_by_type(
         tn_interfaces_cids, link_type)
Exemplo n.º 9
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)
Exemplo n.º 10
0
 def find_se_sdn_links_for_se_node(self,
                                   se_node,
                                   negative_filter=[],
                                   possitive_filter=[""]):
     return FilterUtils.find_se_sdn_links_for_se_node(
         self.se_links, se_node, negative_filter, possitive_filter)
Exemplo n.º 11
0
 def find_sdn_interfaces_for_se_interface(self,
                                          se_interface,
                                          negative_filter=[],
                                          possitive_filter=[""]):
     return FilterUtils.find_sdn_interfaces_for_se_interface(
         self.se_links, se_interface, negative_filter, possitive_filter)
Exemplo n.º 12
0
 def find_se_interfaces_for_domain_names(self, src_domain, dst_domain):
     mappings = self.organisation_name_mappings
     return FilterUtils.find_se_interfaces_for_domain_names(
         self.se_links, mappings, src_domain, dst_domain)
Exemplo n.º 13
0
 def find_se_interfaces_for_tn_interface(self, tn_interface):
     return FilterUtils.find_se_interfaces_for_tn_interface(
         self.se_links, tn_interface)
Exemplo n.º 14
0
 def filter_tn_interfaces_by_type(self, tn_interfaces_cids, link_type=""):
     return FilterUtils.filter_tn_interfaces_by_type(
         tn_interfaces_cids, link_type)
Exemplo n.º 15
0
 def find_tn_interfaces_for_domain(self, domain_name):
     # Given a domain name (e.g. "kddi", "aist"), find possible TN interfaces
     tn_interfaces_cids = self.get_tn_interfaces_cids(clean=True)
     domain_names_alt = self.get_organisation_mappings(domain_name)
     return FilterUtils.find_tn_interfaces_for_domain(
         tn_interfaces_cids, domain_names_alt, domain_name)
Exemplo n.º 16
0
 def find_sdn_interfaces_for_se_interface(self, se_interface,
                                          negative_filter=[],
                                          possitive_filter=[""]):
     return FilterUtils.find_sdn_interfaces_for_se_interface(
         self.se_links, se_interface, negative_filter, possitive_filter)
Exemplo n.º 17
0
 def find_se_sdn_links_for_se_node(self, se_node, negative_filter=[],
                                   possitive_filter=[""]):
     return FilterUtils.find_se_sdn_links_for_se_node(
         self.se_links, se_node, negative_filter, possitive_filter)
Exemplo n.º 18
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]
                }
            })