コード例 #1
0
ファイル: xthpconfig.py プロジェクト: BillTheBest/xorp.ct
    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()
コード例 #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()
コード例 #3
0
ファイル: xthpconfig.py プロジェクト: BillTheBest/xorp.ct
    def spit(self):
        # Print out the header

        # It is a useful debugging aid to store the name of
        # the original config script in the switch config.

        # Three fields are obvious candidates:
        # NAME          15
        # CONTACT       43
        # LOCATION      33
        # The number is the length of this field. So the contact field is
        # used as the longest field. It should be noted that when the
        # NAME field was exceeded the switch continually rebooted. The
        # field lengths were determined by filling the fields using the
        # web interface.
        
        if 43 < len(self.script_name):
            script = self.script_name[len(self.script_name) - 43:]
        else:
            script = self.script_name
        
        print \
"""; J4121A Configuration Editor; Created on release #C.08.22

SYSTEM (
NAME=~xorpsw1~
CONTACT=~%s~
LOCATION=~xorp testbed~
SUPPORT_URL=~http://xorpc.icir.org/testbed/config.xml.txt~
DST_RULE=1
)

CONSOLE (
)""" % script

        for i in range(1, hp_ports + 1):
            print \
"""
CCT (
NAME=%s
PORT_ID=%d
TYPE=62
)""" % (portid2port(i), i)


        print \
"""
STP (
)

IPX (

IPX_NW (
NODE_ADDR=0001e722d880
INIT=1
GW_ENCAP=5
)"""

        # XXXXX
        # Generate some stupid IPX NODE_ADDR we don't deal with overflow
        #

        vlan_id = 2
        addr = 0x81
        for i in self.vlans[1:]: # Start from the second entry
            print """
IPX_NW (
VLAN_ID=%d
NODE_ADDR=0001e722d8%x
INIT=1
GW_ENCAP=5
)""" % (vlan_id, addr)
            vlan_id += 1
            addr += 1

        global hp_control_ipv4, hp_control_mask

        print ")"

        print \
"""
IP (
TIMEP=3

IP_NW (
INIT=%d
ADDR=%s
SNET_MSK=%s
)""" % (hp_init, hp_control_ipv4, hp_control_mask)

        # Print out vlan info

        vlan_id = 2
        for i in self.vlans[1:]: # Start from the second entry
            print """
IP_NW (
VLAN_ID=%d
INIT=2
ADDR=%s
SNET_MSK=%s
GATEWAY=0.0.0.0
)""" % (vlan_id, i[0][1], i[0][2])
            vlan_id += 1

        print ")"

        print \
"""
SNMPS (
ROW_STATUS=1
NAME=public
VIEW=5
MODE=5
)

TRAPS (
)
"""

        # More vlan maps
        vlan_id = 2
        for i in self.vlans:
            if i[0][0] == self.vlans[0][0][0]: # First entry default VLAN 1
                print \
"""VLAN (
NAME=%s
PORT_MAP=%s
MODE=%s
)
""" % (i[0][0], portmap(hp_ports), mode(hp_ports,i[1]))
            else:
                print \
"""VLAN (
VLAN_ID=%d
NAME=%s
VLAN_QID=%d
PORT_MAP=%s
MODE=%s
)
""" % (vlan_id, i[0][0], vlan_id, portmap(hp_ports), mode(hp_ports,i[1]))
                vlan_id += 1
                

        print \
"""PROBE (
INIT=2
PROBE_TYPE=1
MONITORED_PORT_MASK=000000000000000000000000
)

IGMP (
)"""

        vlan_id = 2
        for i in self.vlans[1:]:
            print \
"""
IGMP (
VLAN_ID=%d
)""" % vlan_id
            vlan_id += 1

        print \
"""
ABC (

ABC_NW (
ABC_CONF=4
)"""

        vlan_id = 2
        for i in self.vlans[1:]:
            print \
"""
ABC_NW (
VLAN_ID=%d
ABC_CONF=4
)""" % vlan_id
            vlan_id += 1

        print \
""")
コード例 #4
0
    def spit(self):
        # Print out the header

        # It is a useful debugging aid to store the name of
        # the original config script in the switch config.

        # Three fields are obvious candidates:
        # NAME          15
        # CONTACT       43
        # LOCATION      33
        # The number is the length of this field. So the contact field is
        # used as the longest field. It should be noted that when the
        # NAME field was exceeded the switch continually rebooted. The
        # field lengths were determined by filling the fields using the
        # web interface.

        if 43 < len(self.script_name):
            script = self.script_name[len(self.script_name) - 43:]
        else:
            script = self.script_name

        print \
"""; J4121A Configuration Editor; Created on release #C.08.22

SYSTEM (
NAME=~xorpsw1~
CONTACT=~%s~
LOCATION=~xorp testbed~
SUPPORT_URL=~http://xorpc.icir.org/testbed/config.xml.txt~
DST_RULE=1
)

CONSOLE (
)""" % script

        for i in range(1, hp_ports + 1):
            print \
"""
CCT (
NAME=%s
PORT_ID=%d
TYPE=62
)""" % (portid2port(i), i)


        print \
"""
STP (
)

IPX (

IPX_NW (
NODE_ADDR=0001e722d880
INIT=1
GW_ENCAP=5
)"""

        # XXXXX
        # Generate some stupid IPX NODE_ADDR we don't deal with overflow
        #

        vlan_id = 2
        addr = 0x81
        for i in self.vlans[1:]:  # Start from the second entry
            print """
IPX_NW (
VLAN_ID=%d
NODE_ADDR=0001e722d8%x
INIT=1
GW_ENCAP=5
)""" % (vlan_id, addr)
            vlan_id += 1
            addr += 1

        global hp_control_ipv4, hp_control_mask

        print ")"

        print \
"""
IP (
TIMEP=3

IP_NW (
INIT=%d
ADDR=%s
SNET_MSK=%s
)""" % (hp_init, hp_control_ipv4, hp_control_mask)

        # Print out vlan info

        vlan_id = 2
        for i in self.vlans[1:]:  # Start from the second entry
            print """
IP_NW (
VLAN_ID=%d
INIT=2
ADDR=%s
SNET_MSK=%s
GATEWAY=0.0.0.0
)""" % (vlan_id, i[0][1], i[0][2])
            vlan_id += 1

        print ")"

        print \
"""
SNMPS (
ROW_STATUS=1
NAME=public
VIEW=5
MODE=5
)

TRAPS (
)
"""

        # More vlan maps
        vlan_id = 2
        for i in self.vlans:
            if i[0][0] == self.vlans[0][0][0]:  # First entry default VLAN 1
                print \
"""VLAN (
NAME=%s
PORT_MAP=%s
MODE=%s
)
""" % (i[0][0], portmap(hp_ports), mode(hp_ports,i[1]))
            else:
                print \
"""VLAN (
VLAN_ID=%d
NAME=%s
VLAN_QID=%d
PORT_MAP=%s
MODE=%s
)
""" % (vlan_id, i[0][0], vlan_id, portmap(hp_ports), mode(hp_ports,i[1]))
                vlan_id += 1


        print \
"""PROBE (
INIT=2
PROBE_TYPE=1
MONITORED_PORT_MASK=000000000000000000000000
)

IGMP (
)"""

        vlan_id = 2
        for i in self.vlans[1:]:
            print \
"""
IGMP (
VLAN_ID=%d
)""" % vlan_id
            vlan_id += 1

        print \
"""
ABC (

ABC_NW (
ABC_CONF=4
)"""

        vlan_id = 2
        for i in self.vlans[1:]:
            print \
"""
ABC_NW (
VLAN_ID=%d
ABC_CONF=4
)""" % vlan_id
            vlan_id += 1

        print \
""")