Example #1
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)
Example #2
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)
Example #3
0
    def do_action(self):
        self.debug("Configured peers=%d" % (len(self.peers)))
        nodes = []
        links = []
        for peer in self.peers:
            self.debug("Peer=%s" % (peer, ))
            result, self.adaptor_uri = self.__get_resources(peer)
            if result is None:
                self.error(
                    "Peer is not returning any resource via ListResources!")
                continue
            # Decode the Adv RSpec per RM (RO level)
            if peer.get("type") == self.allowed_peers.get("PEER_CRM"):
                (nodes, links) = self.__decode_com_rspec(result)
                self.__store_com_resources(peer.get("_id"), nodes, links)
            elif peer.get("type") == self.allowed_peers.get("PEER_SDNRM"):
                (nodes, links) = self.__decode_sdn_rspec(result)
                self.__store_sdn_resources(peer.get("_id"), nodes, links)
            elif peer.get("type") == self.allowed_peers.get("PEER_SERM"):
                (nodes, links) = self.__decode_se_rspec(result)
                self.__store_se_resources(peer.get("_id"), nodes, links)
            elif peer.get("type") == self.allowed_peers.get("PEER_TNRM"):
                (nodes, links) = self.__decode_tn_rspec(result)
                self.__store_tn_resources(peer.get("_id"), nodes, links)
            # Decode the Adv RSpec per RO (MRO level)
            elif peer.get("type") == self.allowed_peers.get("PEER_RO"):
                # we need to manage different kind of resorces here,
                # potentially c,sdn,se,tn in the same RSpec
                (nodes,
                 links) = self.__manage_ro_resources(result, peer.get("_id"))
            else:
                self.error("Unknown peer type=%s" % (peer.get("type"), ))

            ##
            # Physical Monitoring
            #

            # Store mapping <domain URN: adaptor URI> for identification
            # later on
            # The second is retrieved by examinining its resources (valid for RM only)
            try:
                # Nodes and links received for either RO and MRO levels.
                # Use a set to expel the repeated URNs.
                set_component_ids = set()
                for node in nodes:
                    if node.get("component_manager_id"):
                        set_component_ids.add(node.get("component_manager_id"))
                    elif node.get("component_id"):
                        set_component_ids.add(node.get("component_id"))
                list_urns = list(set_component_ids)
                for urn in list_urns:
                    self.__set_domain_component_id(urn)
                    db_sync_manager.store_domain_info(self.adaptor_uri,
                                                      self.domain_urn)
                    self.debug("Storing mapping <%s:%s> for domain info" %
                               (self.adaptor_uri, self.domain_urn))
            except Exception as e:
                self.error("Error storing mapping domain_urn:resource_rm.")
                self.error("Exception: %s" % e)

            # 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(self.domain_urn,
                                                    last_update_time)
            except Exception as e:
                self.error("Error storing last_update_time for phy-topology.")
                self.error("Exception: %s" % e)
Example #4
0
    def do_action(self):
        self.debug("Configured peers=%d" % (len(self.peers)))
        nodes = []
        links = []
        for peer in self.peers:
            self.debug("Peer=%s" % (peer,))
            result, self.adaptor_uri = self.__get_resources(peer)
            if result is None:
                self.error("Peer is not returning any resource via ListResources!")
                continue
            # Decode the Adv RSpec per RM (RO level)
            if peer.get("type") == self.allowed_peers.get("PEER_CRM"):
                (nodes, links) = self.__decode_com_rspec(result)
                self.__store_com_resources(peer.get("_id"), nodes, links)
            elif peer.get("type") == self.allowed_peers.get("PEER_SDNRM"):
                (nodes, links) = self.__decode_sdn_rspec(result)
                self.__store_sdn_resources(peer.get("_id"), nodes, links)
            elif peer.get("type") == self.allowed_peers.get("PEER_SERM"):
                (nodes, links) = self.__decode_se_rspec(result)
                self.__store_se_resources(peer.get("_id"), nodes, links)
            elif peer.get("type") == self.allowed_peers.get("PEER_TNRM"):
                (nodes, links) = self.__decode_tn_rspec(result)
                self.__store_tn_resources(peer.get("_id"), nodes, links)
            # Decode the Adv RSpec per RO (MRO level)
            elif peer.get("type") == self.allowed_peers.get("PEER_RO"):
                # we need to manage different kind of resorces here,
                # potentially c,sdn,se,tn in the same RSpec
                (nodes, links) = self.__manage_ro_resources(result, peer.get("_id"))
            else:
                self.error("Unknown peer type=%s" % (peer.get("type"),))

            ##
            # Physical Monitoring
            #

            # Store mapping <domain URN: adaptor URI> for identification
            # later on
            # The second is retrieved by examinining its resources (valid for RM only)
            try:
                # Nodes and links received for either RO and MRO levels.
                # Use a set to expel the repeated URNs.
                set_component_ids = set()
                for node in nodes:
                    if node.get("component_manager_id"):
                        set_component_ids.add(node.get("component_manager_id"))
                    elif node.get("component_id"):
                        set_component_ids.add(node.get("component_id"))
                list_urns = list(set_component_ids)
                for urn in list_urns:
                    self.__set_domain_component_id(urn)
                    db_sync_manager.store_domain_info(self.adaptor_uri,
                                                      self.domain_urn)
                    self.debug("Storing mapping <%s:%s> for domain info" %
                               (self.adaptor_uri, self.domain_urn))
            except Exception as e:
                self.error("Error storing mapping domain_urn:resource_rm.")
                self.error("Exception: %s" % e)

            # 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(self.domain_urn,
                                                    last_update_time)
            except Exception as e:
                self.error("Error storing last_update_time for phy-topology.")
                self.error("Exception: %s" % e)