Exemplo n.º 1
0
    def nodes(self):
        nodes_ = []
        for n in self.rspec.findall(".//{%s}node" % (self.none)):
            s_ = None
            sliver_ = n.find("{%s}sliver_type" % (self.none))
            if sliver_ is not None:
                s_ = sliver_.attrib.get("name")

            n_ = Node(n.attrib.get("client_id"),
                      n.attrib.get("component_manager_id"),
                      n.attrib.get("exclusive"), s_)

            for i in n.iterfind("{%s}interface" % (self.none)):
                i_ = Interface(i.attrib.get("client_id"))
                for sv in i.iterfind("{%s}link_shared_vlan" % (self.__sv)):
                    if sv.attrib.get("vlantag") == "0":
                        staticPort = i.attrib.get("client_id").split("_")[-1]
                        staticPortVlan = self.SEStaticLinkManager.chooseVlan(
                            staticPort)
                        i_.add_vlan(staticPortVlan, sv.attrib.get("name"))
                    else:
                        i_.add_vlan(sv.attrib.get("vlantag"),
                                    sv.attrib.get("name"))
                n_.add_interface(i_.serialize())

            nodes_.append(n_.serialize())

        return nodes_
Exemplo n.º 2
0
    def nodes(self):
        nodes_ = []
        for n in self.rspec.findall(".//{%s}node" % (self.none)):
            s_ = None
            sliver_ = n.find("{%s}sliver_type" % (self.none))
            if sliver_ is not None:
                s_ = sliver_.attrib.get("name")

            n_ = Node(n.attrib.get("client_id"),
                      n.attrib.get("component_manager_id"),
                      n.attrib.get("exclusive"), s_)

            for i in n.iterfind("{%s}interface" % (self.none)):
                i_ = Interface(i.attrib.get("client_id"))
                for sv in i.iterfind("{%s}link_shared_vlan" % (self.__sv)):
                    if sv.attrib.get("vlantag") == "0":
                        staticPort = i.attrib.get("client_id").split("_")[-1]
                        staticPortVlan = self.SEStaticLinkManager.chooseVlan(staticPort)
                        i_.add_vlan(staticPortVlan,
                                    sv.attrib.get("name"))
                    else:
                        i_.add_vlan(sv.attrib.get("vlantag"),
                                    sv.attrib.get("name"))
                n_.add_interface(i_.serialize())

            nodes_.append(n_.serialize())

        return nodes_
Exemplo n.º 3
0
    def nodes(self):
        nodes_ = []
        for n in self.rspec.iterchildren("{%s}node" % (self.none)):
            s_ = None
            sliver_type = n.find("{%s}sliver_type" % (self.none))
            if sliver_type is not None:
                s_ = sliver_type.attrib.get("name")

            n_ = Node(n.attrib.get("component_id"),
                      n.attrib.get("component_manager_id"),
                      n.attrib.get("exclusive"), s_)

            for i in n.iterfind("{%s}interface" % (self.none)):
                i_ = Interface(i.attrib.get("component_id"))
                n_.add_interface(i_.serialize())

            nodes_.append(n_.serialize())

        return nodes_
Exemplo n.º 4
0
    def get_nodes(self, rspec):
        nodes_ = []
        for n in rspec.findall(".//{%s}node" % (self.none)):
            s_ = None
            sliver_ = n.find("{%s}sliver_type" % (self.none))
            if sliver_ is not None:
                s_ = sliver_.attrib.get("name")

            n_ = Node(n.attrib.get("client_id"),
                      n.attrib.get("component_manager_id"),
                      n.attrib.get("exclusive"), s_)

            for i in n.iterfind("{%s}interface" % (self.none)):
                i_ = Interface(i.attrib.get("client_id"))
                for sv in i.iterfind("{%s}link_shared_vlan" % (self.__sv)):
                    i_.add_vlan(sv.attrib.get("vlantag"),
                                sv.attrib.get("name"))
                n_.add_interface(i_.serialize())

            nodes_.append(n_.serialize())

        return nodes_
Exemplo n.º 5
0
    def get_nodes(self, rspec):
        nodes_ = []
        for n in rspec.findall(".//{%s}node" % (self.none)):
            s_ = None
            sliver_ = n.find("{%s}sliver_type" % (self.none))
            if sliver_ is not None:
                s_ = sliver_.attrib.get("name")

            n_ = Node(n.attrib.get("client_id"),
                      n.attrib.get("component_manager_id"),
                      n.attrib.get("exclusive"), s_)

            for i in n.iterfind("{%s}interface" % (self.none)):
                i_ = Interface(i.attrib.get("client_id"))
                for sv in i.iterfind("{%s}link_shared_vlan" % (self.__sv)):
                    i_.add_vlan(sv.attrib.get("vlantag"),
                                sv.attrib.get("name"))
                n_.add_interface(i_.serialize())

            nodes_.append(n_.serialize())

        return nodes_
Exemplo n.º 6
0
    def nodes(self, links=None):
        nodes_ = []
        for n in self.rspec.findall(".//{%s}node" % (self.none)):
            s_ = None
            sliver_ = n.find("{%s}sliver_type" % (self.none))
            if sliver_ is not None:
                s_ = sliver_.attrib.get("name")

            n_ = Node(n.attrib.get("client_id"),
                      n.attrib.get("component_manager_id"),
                      n.attrib.get("exclusive"), s_)

            for i in n.iterfind("{%s}interface" % (self.none)):
                i_ = Interface(i.attrib.get("client_id"))
                # Try if this is the old Rspec format
                svChildrenNumber = len(list(i.iterfind("{%s}link_shared_vlan" % (self.__sv))))

                ### Checking if there are "sharedvlan" tags (old RSpec format)
                if svChildrenNumber == 1:
                    self.logger.debug("Probably old RSpec format in \"<node ...>\"")
                    try:

                        for sv in i.iterfind("{%s}link_shared_vlan" % (self.__sv)):
                            
                            if sv.attrib.get("vlantag") == "0":
                                staticPort = i.attrib.get("client_id").split("_")[-1]
                                if staticPort in self.staticVlans:
                                    self.logger.debug("choosing static port VLAN")
                                    staticPortVlan = self.SEStaticLinkManager.chooseVlan(staticPort)
                                    self.staticVlans[staticPort] = staticPortVlan
                                i_.add_vlan(staticPortVlan,
                                            sv.attrib.get("name"))
                            else:
                                i_.add_vlan(sv.attrib.get("vlantag"),
                                            sv.attrib.get("name"))
                        n_.add_interface(i_.serialize())
                    # On Exception try new Rspec format
                    except:
                        for link in links:
                            pass

                ### Checking if "sharedvlan" tags are missing (new RSpec format)
                elif svChildrenNumber == 0:
                    self.logger.debug(">>>>> Probably new RSpec format in \"<node ...>\"")
                    clientId = i.attrib.get("client_id")
                    self.searchVlanForPort(clientId)
                    vlanInRspec = self.searchVlanForPort(clientId)
                    port = clientId.split("_")[-1]
                    if vlanInRspec == "0":
                        if port in self.staticVlans:
                            vlanInRspec = self.staticVlans[port]
                        else:
                            self.logger.debug("choosing static port VLAN")
                            staticPortVlan = self.SEStaticLinkManager.chooseVlan(port)
                            self.staticVlans[port] = staticPortVlan
                            vlanInRspec = staticPortVlan
                    i_.add_vlan(vlanInRspec, clientId + "+vlan")
                    n_.add_interface(i_.serialize())

                ### Checking if there are more than one "sharedvlan" tag for each Interface (invalid RSpec format)
                elif svChildrenNumber > 1:
                    self.logger.debug(">>>>> Invalid RSpec format. Too many <sharedvlan> tags in \"<node ...>\".")

            nodes_.append(n_.serialize())

        return nodes_