Beispiel #1
0
    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(URNUtils.get_felix_authority_from_urn(x) for x in src_dpids_avail)
                src_dpids_auth_req = set(URNUtils.get_felix_authority_from_urn(x) for x in dpids_src_list)
                dst_dpids_auth_avail = set(URNUtils.get_felix_authority_from_urn(x) for x in dst_dpids_avail)
                dst_dpids_auth_req = set(URNUtils.get_felix_authority_from_urn(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
Beispiel #2
0
    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(
                    URNUtils.get_felix_authority_from_urn(x)
                    for x in src_dpids_avail)
                src_dpids_auth_req = set(
                    URNUtils.get_felix_authority_from_urn(x)
                    for x in dpids_src_list)
                dst_dpids_auth_avail = set(
                    URNUtils.get_felix_authority_from_urn(x)
                    for x in dst_dpids_avail)
                dst_dpids_auth_req = set(
                    URNUtils.get_felix_authority_from_urn(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
Beispiel #3
0
    def find_interdomain_paths_from_stps_and_dpids(stp, dpid_constraints):
        # If STPs involved in the request use heterogeneous types for a given
        # connection (e.g. NSI and GRE), warn user and raise exception
        stps_gre = TNUtils.determine_stp_gre(
            [stp.get("src_name"), stp.get("dst_name")])
        if any(stps_gre) and not all(stps_gre):
            e = "Mapper SDN-SE-TN: attempting to connect 2 STPs"
            e += " of different type (e.g. GRE and NSI)"
            raise geni_ex.GENIv3GeneralError(e)

        pathfinder_options = {}
        src_auth = URNUtils.get_felix_authority_from_ogf_urn(
            stp.get("src_name"))
        dst_auth = URNUtils.get_felix_authority_from_ogf_urn(
            stp.get("dst_name"))

        # Perform a loose match, based on authorities of DPIDs
        # (not on exact DPIDs; as those should be automatically added)
        pathfinder_options["of_switch_cids_check_by_auth"] = True
        pathfinder_options["link_type"] = stp.get("link_type")
        for dpid_constraint in dpid_constraints:
            dpid_constraint_auth = set(
                URNUtils.get_felix_authority_from_urn(x)
                for x in dpid_constraint["ids"])
            # If authority of contraints (list of DPIDs) matches with those of STPs, continue
            if dpid_constraint_auth == set([src_auth]):
                pathfinder_options["src_of_switch_cids"] = dpid_constraint[
                    "ids"]
            elif dpid_constraint_auth == set([dst_auth]):
                pathfinder_options["dst_of_switch_cids"] = dpid_constraint[
                    "ids"]

        paths = TNUtils.find_path_stps(stp.get("src_name"), stp.get("dst_name"), \
            stp.get("link_type"), pathfinder_options)
        return paths
Beispiel #4
0
    def find_interdomain_paths_from_stps_and_dpids(stp, dpid_constraints):
        # If STPs involved in the request use heterogeneous types for a given
        # connection (e.g. NSI and GRE), warn user and raise exception
        stps_gre = TNUtils.determine_stp_gre([stp.get("src_name"), stp.get("dst_name")])
        if any(stps_gre) and not all(stps_gre):
            e = "Mapper SDN-SE-TN: attempting to connect 2 STPs"
            e += " of different type (e.g. GRE and NSI)"
            raise geni_ex.GENIv3GeneralError(e)

        pathfinder_options = {}
        src_auth = URNUtils.get_felix_authority_from_ogf_urn(stp.get("src_name"))
        dst_auth = URNUtils.get_felix_authority_from_ogf_urn(stp.get("dst_name"))

        # Perform a loose match, based on authorities of DPIDs
        # (not on exact DPIDs; as those should be automatically added)
        pathfinder_options["of_switch_cids_check_by_auth"] = True
        pathfinder_options["link_type"] = stp.get("link_type")
        for dpid_constraint in dpid_constraints:
            dpid_constraint_auth = set(URNUtils.get_felix_authority_from_urn(x) for x in dpid_constraint["ids"])
            # If authority of contraints (list of DPIDs) matches with those of STPs, continue
            if dpid_constraint_auth == set([src_auth]):
                pathfinder_options["src_of_switch_cids"] = dpid_constraint["ids"]
            elif dpid_constraint_auth == set([dst_auth]):
                pathfinder_options["dst_of_switch_cids"] = dpid_constraint["ids"]

        paths = TNUtils.find_path_stps(stp.get("src_name"), stp.get("dst_name"), \
            stp.get("link_type"), pathfinder_options)
        return paths
Beispiel #5
0
    def __group_peers_by_domain(self):
        for peer in self.peers_info:
            filter_params = {
                "_id": peer.get("_id"),
            }
            domain_peer = db_sync_manager.get_domain_info(filter_params)
            peer_domain_urn = domain_peer.get("domain_urn")
            authority = URNUtils.get_felix_authority_from_urn(peer_domain_urn)
            # If authority (domain name) does not exist yet, create
            if not self.peers_by_domain.get(authority):
                self.peers_by_domain[authority] = []
            # Extend list of peers with new one
            self.peers_by_domain[authority].append(peer_domain_urn)

            # Stores last_update_time for the physical topology
            # on a given domain
            try:
                last_update_time = self._get_timestamp()
                db_sync_manager.store_physical_info(peer_domain_urn,
                                                    last_update_time)
            except Exception as e:
                logger.error(
                    "Error storing last_update_time for phy-topology.")
                logger.error("Exception: %s" % e)

        # XXX: (M)MS assumes one TNRM per island
        # With this, (M)MS receives at least one TNRM per island
        type_resource_peer_tnrm = self.urn_type_resources_variations.get(
            "tnrm")
        for peer in self.peers:
            filter_params = {
                "_ref_peer": peer.get("_id"),
            }
            domain_peer = db_sync_manager.get_domain_info(filter_params)
            peer_domain_urn = domain_peer.get("domain_urn")
            peer_is_tnrm = any(
                [rt in peer_domain_urn for rt in type_resource_peer_tnrm])
            # MRO: TNRM added at this level. Use information from peer to add it as a TNRM per domain
            if peer_is_tnrm:
                # Add the TNRM peer to each authority that does not have it yet
                for authority in self.peers_by_domain:
                    if peer_domain_urn not in self.peers_by_domain.get(
                            authority):
                        self.peers_by_domain[authority].append(peer_domain_urn)
Beispiel #6
0
    def add_link(self, rspec, link, inner_call=True):
        """
        Translates incoming dictionary:

        {"src_name": "urn:publicid:IDN+fms:src_auth:mapper+domain+domain1",
         "dst_name": "urn:publicid:IDN+fms:src_auth:mapper+domain+domain2",
         "link_type": "(gre|nsi)")

        into the expected tree structure:

        <link component_id="urn:publicid:IDN+fms:src_auth:mapper+link+domain1_domain2">
          <component_manager name="urn:publicid:IDN+fms:src_auth:mapper+authority+cm"/>
          <link_type name="urn:felix+virtual_link+type+(gre|nsi)"/>
          <interface_ref component_id="urn:publicid:IDN+fms:src_auth:mapper+domain+domain1"/>
          <interface_ref component_id="urn:publicid:IDN+fms:src_auth:mapper+domain+domain2"/>
        </link>

        and embeds it into the advertisement RSpec
        """
        l = etree.SubElement(rspec, "{%s}link" % (self.xmlns))

        # Retrieve list of connected domains per link
        end_links = [link.get("src_name"), link.get("dst_name")]
        link_doms = map(lambda x: x.split("+")[-1], end_links)
        src_auth = URNUtils.get_felix_authority_from_urn(link.get("src_name"))
        component_id = "urn:publicid:IDN+fms:%s:mapper+link+%s_%s" % (
            src_auth, link_doms[0], link_doms[1])
        l.attrib["component_id"] = component_id

        if inner_call and link.get("component_manager_uuid") is not None:
            l.attrib["{%s}component_manager_uuid" % (self.__proto)] =\
                link.get("component_manager_uuid")

        m = etree.SubElement(l, "{%s}component_manager" % (self.xmlns))
        m.attrib[
            "name"] = "urn:publicid:IDN+fms:%s:mapper+authority+cm" % src_auth

        t = etree.SubElement(l, "{%s}link_type" % (self.xmlns))
        t.attrib["name"] = "urn:felix+virtual_link+type+%s" % link.get(
            "link_type")

        for i in end_links:
            interface = etree.SubElement(l, "{%s}interface_ref" % (self.xmlns))
            interface.attrib["component_id"] = i
    def add_link(self, rspec, link, inner_call=True):
        """
        Translates incoming dictionary:

        {"src_name": "urn:publicid:IDN+fms:src_auth:mapper+domain+domain1",
         "dst_name": "urn:publicid:IDN+fms:src_auth:mapper+domain+domain2",
         "link_type": "(gre|nsi)")

        into the expected tree structure:

        <link component_id="urn:publicid:IDN+fms:src_auth:mapper+link+domain1_domain2">
          <component_manager name="urn:publicid:IDN+fms:src_auth:mapper+authority+cm"/>
          <link_type name="urn:felix+virtual_link+type+(gre|nsi)"/>
          <interface_ref component_id="urn:publicid:IDN+fms:src_auth:mapper+domain+domain1"/>
          <interface_ref component_id="urn:publicid:IDN+fms:src_auth:mapper+domain+domain2"/>
        </link>

        and embeds it into the advertisement RSpec
        """
        l = etree.SubElement(rspec, "{%s}link" % (self.xmlns))

        # Retrieve list of connected domains per link
        end_links = [link.get("src_name"), link.get("dst_name")]
        link_doms = map(lambda x: x.split("+")[-1], end_links)
        src_auth = URNUtils.get_felix_authority_from_urn(link.get("src_name"))
        component_id = "urn:publicid:IDN+fms:%s:mapper+link+%s_%s" % (src_auth, link_doms[0], link_doms[1])
        l.attrib["component_id"] = component_id

        if inner_call and link.get("component_manager_uuid") is not None:
            l.attrib["{%s}component_manager_uuid" % (self.__proto)] =\
                link.get("component_manager_uuid")

        m = etree.SubElement(l, "{%s}component_manager" % (self.xmlns))
        m.attrib["name"] = "urn:publicid:IDN+fms:%s:mapper+authority+cm" % src_auth

        t = etree.SubElement(l, "{%s}link_type" % (self.xmlns))
        t.attrib["name"] = "urn:felix+virtual_link+type+%s" % link.get("link_type")

        for i in end_links:
            interface = etree.SubElement(l, "{%s}interface_ref" % (self.xmlns))
            interface.attrib["component_id"] = i
Beispiel #8
0
    def __group_peers_by_domain(self):
        for peer in self.peers_info:
            filter_params = {"_id": peer.get("_id")}
            domain_peer = db_sync_manager.get_domain_info(filter_params)
            peer_domain_urn = domain_peer.get("domain_urn")
            authority = URNUtils.get_felix_authority_from_urn(peer_domain_urn)
            # If authority (domain name) does not exist yet, create
            if not self.peers_by_domain.get(authority):
                self.peers_by_domain[authority] = []
            # Extend list of peers with new one
            self.peers_by_domain[authority].append(peer_domain_urn)

            # Stores last_update_time for the physical topology
            # on a given domain
            try:
                last_update_time = self._get_timestamp()
                db_sync_manager.store_physical_info(peer_domain_urn,
                                                    last_update_time)
            except Exception as e:
                logger.error("Error storing last_update_time in phy-topology.")
                logger.error("Exception: %s" % e)

        # XXX: (M)MS assumes one TNRM per island
        # With this, (M)MS receives at least one TNRM per island
        type_resource_peer_tnrm = \
            self.urn_type_resources_variations.get("tnrm")
        for peer in self.peers:
            filter_params = {"_ref_peer": peer.get("_id")}
            domain_peer = db_sync_manager.get_domain_info(filter_params)
            peer_domain_urn = domain_peer.get("domain_urn")
            peer_is_tnrm = any(
                [rt in peer_domain_urn for rt in type_resource_peer_tnrm])
            # MRO: TNRM added at this level. Use information from peer to add
            # it as a TNRM per domain
            if peer_is_tnrm:
                # Add the TNRM peer to each authority that does not have it yet
                for authority in self.peers_by_domain:
                    if peer_domain_urn not in self.\
                            peers_by_domain.get(authority):
                        self.peers_by_domain[authority].append(peer_domain_urn)
Beispiel #9
0
 def __check_ids_same_domain(self, src_id, dst_id):
     auth_src = URNUtils.get_felix_authority_from_urn(src_id)
     auth_dst = URNUtils.get_felix_authority_from_urn(dst_id)
     return auth_src == auth_dst
Beispiel #10
0
 def __check_ids_same_domain(self, src_id, dst_id):
     auth_src = URNUtils.get_felix_authority_from_urn(src_id)
     auth_dst = URNUtils.get_felix_authority_from_urn(dst_id)
     return auth_src == auth_dst
Beispiel #11
0
 def __get_island_name(self, urn):
     return URNUtils.get_felix_authority_from_urn(urn)
Beispiel #12
0
 def __get_island_name(self, urn):
     return URNUtils.get_felix_authority_from_urn(urn)
Beispiel #13
0
 def get_authority(urn):
     return URNUtils.get_felix_authority_from_urn(urn)