Exemple #1
0
    def startElement(self, name, attrs):
	self.ch = ""

        if "testbed_config" == name:
            self.inconfig = 1

        if self.inconfig != 1:
            return

        if "vlan" == name:
            self.port = ()
            self.vlan_name = nw(attrs.getValue('name'))
            try:
                self.ipv4 = nw(attrs.getValue('ipv4'))
                self.mask = nw(attrs.getValue('mask'))
            except:
                self.ipv4 = "0.0.0.0"
                self.mask = "0.0.0.0"

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

        if "ipv4" == name:
            port = (nw(attrs.getValue('port')),)
            self.port = self.port + (port)
Exemple #2
0
    def startElement(self, name, attrs):
	self.ch = ""
	self.interface = ""
        
	if "host" == name:
	    self.host = nw(attrs.getValue('name'))

        if "mac" == name:
	    self.interface = nw(attrs.getValue('name'))
	    self.port = nw(attrs.getValue('port'))
Exemple #3
0
    def endElement(self, name):
	if("mac" == name):
	    if "main" == self.interface or "control" == self.interface:
		if 1 == self.debug:
		    print self.host, self.interface, self.port, nw(self.ch)

		self.vlans[self.interface] = self.vlans[self.interface] +\
					     ((self.host, \
					      self.port, \
					      nw(self.ch)),)

        self.ch = ""
Exemple #4
0
    def endElement(self, name):
        if "testbed_config" == name:
            self.inconfig = 0

        if "kernel" == name:
            self.kernels += [[self.src, self.dst]]
            self.src = self.dst = ""
            self.inkernel = 0

        if 1 == self.inkernel:
            if "src" == name and 1 == self.insrc:
                self.src = nw(self.ch)
                self.insrc = 0
            if "dst" == name and 1 == self.indst:
                self.dst = nw(self.ch)
                self.indst = 0

        if "noconfig" == name:
            self.noconfig = self.noconfig + [nw(self.ch)]
            self.ch = ""
            return

        if "router" == name:
            self.router = nw(self.ch)
            self.ch = ""
            return

        if "vlan" == name:
            self.invlan = 0

        if "host" == name:
            self.inhost = 0

        if "ipv4" == name:
            address = nw(self.ch)

            dict = { \
                "vlan" : self.vlan, \
                "network" : self.network, \
                "mask" : self.mask, \
                "host" : self.host, \
                "vif" : self.vif, \
                "mac" : self.mac, \
                "port" : self.port, \
                "addr" : address}
            self.list = self.list + [dict]

        self.ch = ""
Exemple #5
0
    def endElement(self, name):
        if "testbed_config" == name:
            self.inconfig = 0

        if "vlan" == name:
            self.invlan = 0
            self.vlans = self.vlans + (self.vlan_name,)
            self.network = self.network + (self.ipv4,)
            if 1 == self.debug:
                print self.vlans
                print self.network

        if "host" == name:
            self.inhost = 0

        if "ipv4" == name:
            self.ports = self.ports + (self.port,)
            address = nw(self.ch)
            self.addresses = self.addresses + (address,)
            if 1 == self.debug:
                print self.ports
                print self.addresses

            self.verify(self.x, self.host_name, self.mac, self.port, \
                        self.interface)

            if "" != address:
                self.netcheck(address, self.ipv4, self.mask)

        self.ch = ""
Exemple #6
0
def getAttrValue(attrs, value):
    """
    Extract an xml attribute. If the attribute does't exist return the
    empty string.
    """
    
    try:
        result = nw(attrs.getValue(value))
    except:
        result = ""

    return result
Exemple #7
0
    def endElement(self, name):
	if self.debug:
	    self.level -= 1
	    if "" != nw(self.ch):
		print "\t"*self.level + nw(self.ch)
	    print "\t"*self.level + "</" + nw(name) + ">"
	
	#
	# Don't put an entry into the list if it is not connected to
	# the switch.
	#
	if "mac" == name and self.port != "":
	    self.xorp = self.xorp + [(self.host, \
				      nw(self.ch), \
				      self.port, \
				      self.portid, \
				      self.type, \
				      self.cable, \
				      self.name, \
				      self.available, \
				      )]

	self.ch = ""
Exemple #8
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
Exemple #9
0
    def endElement(self, name):
        if "testbed_physical" == name:
            self.inphysical = 0

        if "host" == name:
            self.inhost = 0

        if "mac" == name:
            mac = nw(self.ch)

            dict = { \
                "host" : self.host, \
                "vif" : self.vif, \
                "port" : self.port, \
                "cable" : self.cable, \
                "type" : self.type, \
                "man" : self.man, \
                "use" : self.use, \
                "mac" : mac}
            self.list = self.list + [dict]

        self.ch = ""
Exemple #10
0
    def startElement(self, name, attrs):
	self.ch = ""

        if "testbed_config" == name:
            self.inconfig = 1

        if self.inconfig != 1:
            return

        if "vlan" == name:
            self.invlan = 1
            self.vlan_name = nw(attrs.getValue('name'))
            try:
                self.ipv4 = nw(attrs.getValue('ipv4'))
                self.mask = nw(attrs.getValue('mask'))
            except:
                self.ipv4 = ""
                self.mask = ""
		
        if self.invlan != 1:
            return

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

        if self.inhost != 1:
            return

        if "ipv4" == name:
            self.mac = nw(attrs.getValue('mac'))
            self.port = nw(attrs.getValue('port'))
            try:
                self.interface = nw(attrs.getValue('name'))
            except:
                self.interface = ""