def process_chunk(chunk): line = chunk[0] commands = [] if "vlan" in line: vlan = VLAN(chunk, iface_map) commands = vlan.generate_junos() elif "interface ve" in line: ve = VE(chunk) elif "interface ethernet" in line: iface = INTERFACE(chunk) # print(iface) elif "lag" in line: lag = LAG(chunk, iface_map) commands = lag.generate_junos() for c in commands: print(c) elif "snmp-server" in line: snmp = SNMP(chunk) elif "router ospf" in line: ospf = OSPF(chunk, debug=0) commands = ospf.generate_junos() elif "router bgp" in line: bgp = BGP(chunk) commands = bgp.generate_junos() return commands
def test_generate_junos(self): """ Test the function generate_junos in the VLAN class """ # Define a static map of interfaces iface_map = {"eth 1/1": "et-1/0/1"} chunk = [ "vlan 2 name TEST", "untagged ethe 1/1", "router-interface ve 2" ] result = ["set vlans TEST", "set vlans TEST vlan-id 2"] vlan = VLAN(chunk, iface_map) commands = vlan.generate_junos() self.assertEqual(commands, result)