Beispiel #1
0
    def add_sdn_resources(self, slice_urn, nodes):
        """
        Inserts one or more nodes with SDNRM resources information.

        @param slice_urn URN identifier of a given slice
        @param nodes Structure containing a list of SDNRM nodes and
                     its attributes
        """
        # Cannot use information extracted from the manifest here!
        # Look into the db-table containing the requested dpids and matches.
        if slice_urn not in self.__stored:
            logger.error("Slice monitoring: unable to find topology " +
                         "info from %s!" % slice_urn)
            return

        topology = self.__stored.get(slice_urn)
        groups, matches = db_sync_manager.get_slice_sdn(slice_urn)
        link_ids = []
        # Nodes info
        logger.debug("add_sdn_resources Groups(%d)=%s" % (len(groups), groups))
        logger.debug("add_sdn_resources Matches=%d" % (len(matches),))

        for m in matches:
            logger.debug("Match=%s" % (m,))
            self.__update_match_with_groups(m, groups)

            # TODO Check db.topology.slice (maybe some information stored?)
            for dpid in m.get("dpids"):
                if MonitoringUtils.check_existing_tag_in_topology(
                        topology, "node", "switch", dpid.get("component_id")):
                    break
                logger.debug("Dpid=%s" % (dpid,))

                node_ = etree.SubElement(
                    topology, "node", id=dpid.get("component_id"),
                    type="switch")

                # NOTE: do not append ports to dpid, different
                # format is used between XEN-CRM and KVM-CRM
                link_ids.append(
                    self.__create_link_id(dpid.get("dpid"), ""))

                self.__add_packet_info(node_, m.get("packet"))

        logger.info("add_sdn_resources Link identifiers(%d)=%s" %
                    (len(link_ids), link_ids,))

        # SDN-SDN link info
        ext_link_ids = self.__extend_link_ids(link_ids)
        logger.info("add_sdn_resources Extended link identifiers(%d)=%s" %
                    (len(ext_link_ids), ext_link_ids,))
        for l in ext_link_ids:
            sdn_link = db_sync_manager.get_sdn_link_by_sdnkey(l)
            if sdn_link:
                logger.debug("SDN link=%s" % (sdn_link,))
                if len(sdn_link.get("dpids")) == 2 and\
                   len(sdn_link.get("ports")) == 2:
                    ep1 = self.__create_link_id(
                        sdn_link.get("dpids")[0].get("component_id"),
                        sdn_link.get("ports")[0].get("port_num"))
                    ep2 = self.__create_link_id(
                        sdn_link.get("dpids")[1].get("component_id").
                        sdn_link.get("ports")[1].get("port_num"))
                    # Local SDN-SDN links not inserted under nested link
#                    if self.__check_ids_same_domain(ep1, ep2):
                    self.__add_link_info(topology, ep1, ep2,
                                         self.SDN2SDN_LINK_TYPE)
#                    else:
#                        self.__sdn_links.append(
#                            {'id': sdn_link.get("component_id"),
#                             'source': ep1,
#                             'destination': ep2})
            else:
                logger.info("Slice monitoring: cannot find link that " +
                            "ends with %s" % l)
Beispiel #2
0
    def add_sdn_resources(self, slice_urn, nodes):
        """
        Inserts one or more nodes with SDNRM resources information.

        @param slice_urn URN identifier of a given slice
        @param nodes Structure containing a list of SDNRM nodes and
                     its attributes
        """
        # Cannot use information extracted from the manifest here!
        # Look into the db-table containing the requested dpids and matches.
        if slice_urn not in self.__stored:
            logger.error("Slice monitoring: unable to find topology " +
                         "info from %s!" % slice_urn)
            return

        topology = self.__stored.get(slice_urn)
        groups, matches = db_sync_manager.get_slice_sdn(slice_urn)
        link_ids = []
        # Nodes info
        logger.debug("add_sdn_resources Groups(%d)=%s" % (len(groups), groups))
        logger.debug("add_sdn_resources Matches=%d" % (len(matches), ))

        for m in matches:
            logger.debug("Match=%s" % (m, ))
            self.__update_match_with_groups(m, groups)

            ## TODO Check db.topology.slice (maybe some information stored?)
            for dpid in m.get("dpids"):
                if MonitoringUtils.check_existing_tag_in_topology(
                        topology, "node", "switch", dpid.get("component_id")):
                    break
                logger.debug("Dpid=%s" % (dpid, ))

                node_ = etree.SubElement(topology,
                                         "node",
                                         id=dpid.get("component_id"),
                                         type="switch")

                for p in dpid.get("ports"):
                    ifid = dpid.get("component_id") + "_" + str(p.get("num"))
                    if_ = etree.SubElement(node_, "interface", id=ifid)

                    etree.SubElement(if_, "port", num=str(p.get("num")))

                    link_ids.append(
                        self.__create_link_id(dpid.get("dpid"), p.get("num")))

                self.__add_packet_info(node_, m.get("packet"))

        logger.info("add_sdn_resources Link identifiers(%d)=%s" % (
            len(link_ids),
            link_ids,
        ))
        # C-SDN link info
        for l in link_ids:
            com_link = db_sync_manager.get_com_link_by_sdnkey(l)
            if com_link:
                logger.debug("COM link=%s" % (com_link, ))
                for eps in com_link.get("links"):
                    if MonitoringUtils.check_existing_tag_in_topology(topology, "link",\
                        self.MS_LINK_TYPE, [eps.get("source_id"), eps.get("dest_id")]):
                        break

                    # Modify link on-the-fly to add the DPID port as needed
                    eps = MonitoringUtilsLinks._set_dpid_port_from_link(
                        com_link.get("component_id"), eps)

                    eps_src_id, eps_dst_id = self.__get_eps_ids(
                        eps.get("source_id"), eps.get("dest_id"))

                    logger.info("eps_src_id=%s, eps_dst_id=%s" % (
                        eps_src_id,
                        eps_dst_id,
                    ))
                    self.__add_link_info(topology, eps_src_id, eps_dst_id,
                                         com_link.get("link_type"))

        # SDN-SDN link info
        ext_link_ids = self.__extend_link_ids(link_ids)
        logger.info("add_sdn_resources Extended link identifiers(%d)=%s" % (
            len(ext_link_ids),
            ext_link_ids,
        ))
        for l in ext_link_ids:
            sdn_link = db_sync_manager.get_sdn_link_by_sdnkey(l)
            if sdn_link:
                logger.debug("SDN link=%s" % (sdn_link, ))
                if len(sdn_link.get("dpids")) == 2 and\
                   len(sdn_link.get("ports")) == 2:
                    ep1 = self.__create_link_id(
                        sdn_link.get("dpids")[0].get("component_id"),
                        sdn_link.get("ports")[0].get("port_num"))
                    ep2 = self.__create_link_id(
                        sdn_link.get("dpids")[1].get("component_id").sdn_link.
                        get("ports")[1].get("port_num"))
                    # Local SDN-SDN links are not inserted under the nested link
                    #                    if self.__check_ids_same_domain(ep1, ep2):
                    self.__add_link_info(topology, ep1, ep2,
                                         self.SDN2SDN_LINK_TYPE)
#                    else:
#                        self.__sdn_links.append(
#                            {'id': sdn_link.get("component_id"),
#                             'source': ep1,
#                             'destination': ep2})
            else:
                logger.info("Slice monitoring: cannot find link that " +
                            "ends with %s" % l)
Beispiel #3
0
    def add_sdn_resources(self, slice_urn, nodes):
        """
        Inserts one or more nodes with SDNRM resources information.

        @param slice_urn URN identifier of a given slice
        @param nodes Structure containing a list of SDNRM nodes and
                     its attributes
        """
        # Cannot use information extracted from the manifest here!
        # Look into the db-table containing the requested dpids and matches.
        if slice_urn not in self.__stored:
            logger.error("Slice monitoring: unable to find topology " +
                         "info from %s!" % slice_urn)
            return

        topology = self.__stored.get(slice_urn)
        groups, matches = db_sync_manager.get_slice_sdn(slice_urn)
        link_ids = []
        # Nodes info
        logger.debug("add_sdn_resources Groups(%d)=%s" % (len(groups), groups))
        logger.debug("add_sdn_resources Matches=%d" % (len(matches),))

        for m in matches:
            logger.debug("Match=%s" % (m,))
            self.__update_match_with_groups(m, groups)

            ## TODO Check db.topology.slice (maybe some information stored?)
            for dpid in m.get("dpids"):
                if MonitoringUtils.check_existing_tag_in_topology(topology, "node", "switch", dpid.get("component_id")):
                    break
                logger.debug("Dpid=%s" % (dpid,))

                node_ = etree.SubElement(
                    topology, "node", id=dpid.get("component_id"),
                    type="switch")

                for p in dpid.get("ports"):
                    ifid = dpid.get("component_id") + "_" + str(p.get("num"))
                    if_ = etree.SubElement(node_, "interface", id=ifid)

                    etree.SubElement(if_, "port", num=str(p.get("num")))

                    link_ids.append(
                        self.__create_link_id(dpid.get("dpid"), p.get("num")))

                self.__add_packet_info(node_, m.get("packet"))

        logger.info("add_sdn_resources Link identifiers(%d)=%s" %
                    (len(link_ids), link_ids,))
        # C-SDN link info
        for l in link_ids:
            com_link = db_sync_manager.get_com_link_by_sdnkey(l)
            if com_link:
                logger.debug("COM link=%s" % (com_link,))
                for eps in com_link.get("links"):
                    if MonitoringUtils.check_existing_tag_in_topology(topology, "link",\
                        self.MS_LINK_TYPE, [eps.get("source_id"), eps.get("dest_id")]):
                        break

                    # Modify link on-the-fly to add the DPID port as needed
                    eps = MonitoringUtilsLinks._set_dpid_port_from_link(
                        com_link.get("component_id"), eps)

                    eps_src_id, eps_dst_id = self.__get_eps_ids(
                        eps.get("source_id"), eps.get("dest_id"))

                    logger.info("eps_src_id=%s, eps_dst_id=%s" %
                                (eps_src_id, eps_dst_id,))
                    self.__add_link_info(topology, eps_src_id, eps_dst_id, com_link.get("link_type"))

        # SDN-SDN link info
        ext_link_ids = self.__extend_link_ids(link_ids)
        logger.info("add_sdn_resources Extended link identifiers(%d)=%s" %
                    (len(ext_link_ids), ext_link_ids,))
        for l in ext_link_ids:
            sdn_link = db_sync_manager.get_sdn_link_by_sdnkey(l)
            if sdn_link:
                logger.debug("SDN link=%s" % (sdn_link,))
                if len(sdn_link.get("dpids")) == 2 and\
                   len(sdn_link.get("ports")) == 2:
                    ep1 = self.__create_link_id(
                        sdn_link.get("dpids")[0].get("component_id"),
                        sdn_link.get("ports")[0].get("port_num"))
                    ep2 = self.__create_link_id(
                        sdn_link.get("dpids")[1].get("component_id").
                        sdn_link.get("ports")[1].get("port_num"))
                    # Local SDN-SDN links are not inserted under the nested link
#                    if self.__check_ids_same_domain(ep1, ep2):
                    self.__add_link_info(topology, ep1, ep2, self.SDN2SDN_LINK_TYPE)
#                    else:
#                        self.__sdn_links.append(
#                            {'id': sdn_link.get("component_id"),
#                             'source': ep1,
#                             'destination': ep2})
            else:
                logger.info("Slice monitoring: cannot find link that " +
                            "ends with %s" % l)