示例#1
0
文件: se.py 项目: ict-felix/stack
    def __create_link(self, if1, if2, vlan1, vlan2, sliver_id):
        """
        Generates the SE link in a proper format:
            Old: <urn_dpid_1>_<port1>_<dpid2>_<port2>_<vlan1>_<vlan2>
            New: <urn_dpid_1>_<port1>?vlan=<vlan1>-<dpid2>_<port2>?vlan=<vlan2>
        """
        i = if1.rindex("_")
        n1, port1 = if1[0:i], if1[i+1:len(if1)]
        i = if2.rindex("_")
        n2, port2 = if2[0:i], if2[i+1:len(if2)]
        dpid2 = n2[n2.rindex("+")+1:]

        # Format of the link
        # urn:publicid:IDN+fms:psnc:serm+link+<dpid1>_<p1>?vlan=X-<dpid2>_<p2>?vlan=Y
#        cid = n1 + "_" + port1 + "-" + dpid2 + "_" + port2
#        cid = "%s_%s-%s_%s" % (n1, port1, dpid2, port2)
        cid = "%s_%s?vlan=%s-%s_%s?vlan=%s" % \
            (n1, port1, vlan1, dpid2, port2, vlan2)

        logger.debug("cid=%s, node-id=%s, vlan1=%s, vlan2=%s, \
                     port-num1=%s, port-num2=%s" %
                     (cid, n1, vlan1, vlan2, port1, port2,))
        typee, cm_name = db_sync_manager.get_se_link_info(n1 + "_" + port1)

        l = SELink(cid, typee, cm_name, sliver=sliver_id)
        l.add_interface_ref(if1)
        l.add_interface_ref(if2)
        return l
示例#2
0
    def get_links(self, rspec):
        links_ = []
        for l in rspec.findall(".//{%s}link" % (self.none)):
            manager_ = l.find("{%s}component_manager" % (self.none))
            if manager_ is None:
                self.raise_exception("Component-Mgr tag not found in link!")

            if not self.check_se_link_resource(l, manager_):
                logger.info("Skipping this link, not a SE-res: %s", (l, ))
                continue

            type_ = l.find("{%s}link_type" % (self.none))
            if type_ is None:
                self.raise_exception("Link-Type tag not found in link!")

            l_ = SELink(l.attrib.get("client_id"), type_.attrib.get("name"),
                        manager_.attrib.get("name"))

            self.update_protogeni_cm_uuid(l, l_)

            [
                l_.add_interface_ref(i.attrib.get("client_id"))
                for i in l.iterfind("{%s}interface_ref" % (self.none))
            ]

            [
                l_.add_property(p.attrib.get("source_id"),
                                p.attrib.get("dest_id"),
                                p.attrib.get("capacity"))
                for p in l.iterfind("{%s}property" % (self.none))
            ]

            links_.append(l_.serialize())

        return links_
示例#3
0
    def links(self):
        links_ = []
        for l in self.rspec.findall(".//{%s}link" % (self.none)):
            manager_ = l.find("{%s}component_manager" % (self.none))
            if manager_ is None:
                self.raise_exception("Component-Mgr tag not found in link!")

            if not self.check_se_link_resource(l, manager_):
                logger.info("Skipping this link, not a SE-res: %s", (l,))
                continue

            type_ = l.find("{%s}link_type" % (self.none))
            if type_ is None:
                self.raise_exception("Link-Type tag not found in link!")

            l_ = SELink(l.attrib.get("client_id"), type_.attrib.get("name"),
                        manager_.attrib.get("name"), l.attrib.get("vlantag"),
                        l.attrib.get("sliver_id"))

            self.update_protogeni_cm_uuid(l, l_)

            [l_.add_interface_ref(i.attrib.get("client_id"))
             for i in l.iterfind("{%s}interface_ref" % (self.none))]

            # NOTE: property tag not used
#            [l_.add_property(p.attrib.get("source_id"),
#                             p.attrib.get("dest_id"),
#                             p.attrib.get("capacity"))
#             for p in l.iterfind("{%s}property" % (self.none))]

            links_.append(l_.serialize())

        return links_
示例#4
0
    def get_links(self, rspec):
        links_ = []
        for l in rspec.findall(".//{%s}link" % (self.none)):
            manager_ = l.find("{%s}component_manager" % (self.none))
            if manager_ is None:
                self.raise_exception("Component-Mgr tag not found in virtual link!")

            if not self.check_vlink_resource(l, manager_):
                logger.info("Skipping this link, not a virtual link: %s", (l,))
                continue

            type_ = l.find("{%s}link_type" % (self.none))
            if type_ is None:
                self.raise_exception("Link-Type tag not found in link!")

            l_ = SELink(l.attrib.get("client_id"), type_.attrib.get("name"),
                        manager_.attrib.get("name"))

            [l_.add_interface_ref(i.attrib.get("client_id"))
             for i in l.iterfind("{%s}interface_ref" % (self.none))]

            [l_.add_property(p.attrib.get("source_id"),
                             p.attrib.get("dest_id"),
                             p.attrib.get("capacity"))
             for p in l.iterfind("{%s}property" % (self.none))]

            links_.append(l_.serialize())

        return links_
示例#5
0
    def get_links(self, rspec):
        links_ = []

        for l in rspec.findall(".//{%s}link" % (self.none)):
            manager_ = l.find("{%s}component_manager" % (self.none))

            if manager_ is None:
                self.raise_exception("Component-Mgr tag not found in link!")

            if not self.check_se_link_resource(l, manager_):
                logger.info("Skipping this link, not a SE-res: %s", (l,))
                continue

            type_ = l.find("{%s}link_type" % (self.none))
            if type_ is None:
                self.raise_exception("Link-Type tag not found in link!")

            # Note: client_id for a link may follow one of the formats:
            # Original: "urn:publicid:IDN+fms:psnc:serm+link+
            # <dpid1>_6_<dpid2>_7",
            # New: "urn:publicid:IDN+fms:psnc:serm+link+
            # <dpid1>_6?vlan=1_<dpid2>_7?vlan=2",
            # In case of receiving the new one, it must be translated to
            # the original one (advertised by SERM); otherwise it will not be
            # possible to find the link in the Mongo serm.link collection
            client_id = l.attrib.get("client_id")
            # client_id_2 = URNUtils.convert_se_link_id_to_adv_id(client_id)

            l_ = SELink(client_id, type_.attrib.get("name"), manager_.attrib.get("name"))
            self.update_protogeni_cm_uuid(l, l_)

            # FIXME: VLAN seems not properly added to interface
            for i in l.iterfind("{%s}interface_ref" % (self.none)):
                # 1st check new SERM RSpec format
                client_id, vlan = URNUtils.get_fields_from_domain_iface_id(i.attrib.get("client_id"))
                if not vlan:
                    vlan = i.attrib.get("{%s}vlan" % (self.__felix))

                l_.add_interface_ref(client_id, vlan)

            [
                l_.add_property(p.attrib.get("source_id"), p.attrib.get("dest_id"), p.attrib.get("capacity"))
                for p in l.iterfind("{%s}property" % (self.none))
            ]

            links_.append(l_.serialize())

        return links_
示例#6
0
    def links(self):
        links_ = []
        for l in self.rspec.iterchildren("{%s}link" % (self.none)):
            c_ = None
            component_manager = l.find("{%s}component_manager" % (self.none))
            if component_manager is not None:
                c_ = component_manager.attrib.get("name")

            link_type = l.find("{%s}link_type" % (self.none))
            if link_type is None:
                self.raise_exception("Link_type tag not found!")

            l_ = SELink(l.attrib.get("component_id"),
                        link_type.attrib.get("name"), c_)

            self.__update_protogeni_cm_uuid(l, l_)

            for ref in l.iterchildren("{%s}interface_ref" % (self.none)):
                l_.add_interface_ref(ref.attrib.get("component_id"))

            for p in l.iterchildren("{%s}property" % (self.none)):
                l_.add_property(p.attrib.get("source_id"),
                                p.attrib.get("dest_id"),
                                p.attrib.get("capacity"))

            links_.append(l_.serialize())

        return links_
示例#7
0
    def __create_link(self, if1, if2, vlan1, vlan2, sliver_id):
        """
        Generates the SE link in a proper format:
            <urn_dpid_1>_<port1>_<dpid2>_<port2>_<vlan1>_<vlan2>
        """
        i = if1.rindex("_")
        n1, num1 = if1[0:i], if1[i+1:len(if1)]
        i = if2.rindex("_")
        n2, num2 = if2[0:i], if2[i+1:len(if2)]
        dpid2 = n2[n2.rindex("+")+1:]

        cid = n1 + "_" + num1 + "_" + dpid2 + "_" + num2
        logger.debug("cid=%s, node-id=%s, port-num1=%s, port-num2=%s" %
                     (cid, n1, num1, num2,))
        typee, cm_name = db_sync_manager.get_se_link_info(n1 + "_" + num1)

        l = SELink(cid, typee, cm_name, sliver=sliver_id)
        l.add_interface_ref(if1, vlan1)
        l.add_interface_ref(if2, vlan2)
        return l
示例#8
0
    def links(self):
        links_ = []
        for l in self.rspec.iterchildren("{%s}link" % (self.none)):
            c_ = None
            component_manager = l.find("{%s}component_manager" % (self.none))
            if component_manager is not None:
                c_ = component_manager.attrib.get("name")

            link_type = l.find("{%s}link_type" % (self.none))
            if link_type is None:
                self.raise_exception("Link_type tag not found!")

            l_ = SELink(l.attrib.get("component_id"), link_type.attrib.get("name"), c_)

            self.__update_protogeni_cm_uuid(l, l_)

            for ref in l.iterchildren("{%s}interface_ref" % (self.none)):
                l_.add_interface_ref(ref.attrib.get("component_id"))

            for p in l.iterchildren("{%s}property" % (self.none)):
                l_.add_property(p.attrib.get("source_id"), p.attrib.get("dest_id"), p.attrib.get("capacity"))

            links_.append(l_.serialize())

        return links_