Ejemplo n.º 1
0
    def start(self):
        parser = make_parser()
        parser.setFeature(feature_namespaces, 0)
        parser.setContentHandler(self)
        parser.parse(self.fname)

        # Before we write out the config file we need to create another
        # VLAN which contains all the ports which have not been included
        # in any vlans. The switch seems to require this.
        ports = {}
        for i in range(1, hp_ports + 1):
            ports[i] = 0

        for i in self.vlans:
            for j in i[1]:
                ports[port2portid(j)] = 1

        port = ()
        for i in range(1, hp_ports + 1):
            if 0 == ports[i]:
                port = port + (portid2port(i), )

        self.vlans = self.vlans + \
                         (((("OTHER", "0.0.0.0", "0.0.0.0"),) + \
                           (port,)),)

        self.spit()
Ejemplo n.º 2
0
    def start(self):
	parser = make_parser()
	parser.setFeature(feature_namespaces, 0)
	parser.setContentHandler(self)
	parser.parse(self.fname)

        # Before we write out the config file we need to create another
        # VLAN which contains all the ports which have not been included
        # in any vlans. The switch seems to require this.
        ports = {}
        for i in range(1, hp_ports + 1):
            ports[i] = 0

        for i in self.vlans:
            for j in i[1]:
                ports[port2portid(j)] =  1

        port = ()
        for i in range(1, hp_ports + 1):
            if 0 == ports[i]:
                port = port + (portid2port(i),)

        self.vlans = self.vlans + \
                         (((("OTHER", "0.0.0.0", "0.0.0.0"),) + \
                           (port,)),)

        self.spit()
Ejemplo n.º 3
0
    def startElement(self, name, attrs):
	self.ch = ""

	if "host" == name:
	    self.host = nw(attrs.getValue('name'))


	# We can have entries for cards which are not currently
	# connected to the switch.
	try:
            if "mac" == name:
                self.port = nw(attrs.getValue('port'))
                # Generate the portid from the port number
                self.portid = port2portid(self.port)
                self.type = nw(attrs.getValue("type"))
                self.cable = nw(attrs.getValue("cable"))
                try:
                    self.name = nw(attrs.getValue("name"))
                except:
                    self.name = "unknown"
                try:
                    self.available = nw(attrs.getValue("use"))
                except:
                    self.available = "yes"
        except:
	    self.port = ""
	    self.portid = ""

        if self.debug:
	    whole = "\t"*self.level + "<%s" % nw(name)
	    self.level += 1

	if self.debug:
	    for i in attrs.getNames():
		whole += " %s=%s" % (i ,nw(attrs.getValue(i)))

	if self.debug:
	    whole += ">"
	    print whole