def runTest(self): vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan = StaticVLAN(vlan_cfg) vlan_cfg['dynamicvlans'] = [ { "port": 1, "dynamicVlan": "disable" } ] vlanDynamic = DynamicVLAN(vlan_cfg).build() actual_port = vlan.get_port(1) assert(vlan_cfg['dynamicvlans'][0]['port'] == actual_port['port']), "Port number error" assert(vlan_cfg['dynamicvlans'][0]['dynamicVlan'] == actual_port['dynamicVlan']), "native type error" vlan_cfg['guestvlans'] = [ { "port": 1, "guestVlan": 25 } ] vlanGuest = GuestVLAN(vlan_cfg).build() actual_port = vlan.get_port(1) assert(vlan_cfg['guestvlans'][0]['port'] == actual_port['port']), "Port number error" assert(vlan_cfg['guestvlans'][0]['guestVlan'] == actual_port['guestVlan']), "guestVlan type error"
def runTest(self): vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['data'] = { "guestvlans": [ { "port": 1, "guestVlan": 20 } ] } vlan = StaticVLAN(vlan_cfg).buildById() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) chkData = vlan_cfg['data']['guestvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['guestVlan'] == portNum['guestVlan']), "guestVlan type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['data'] = { "dynamicvlans": [ { "port": 1, "dynamicVlan": "disable" }, { "port": 2, "dynamicVlan": "disable" } ] } vlan = StaticVLAN(vlan_cfg).buildById() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) chkData = vlan_cfg['data']['dynamicvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['dynamicVlan'] == portNum['dynamicVlan']), "dynamicVlan type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" vlan.delete_DevieIdNoVerify(vlan_cfg) actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) assert(None != actual_port), "get dynamicVlan fail" assert("dynamicvlans" not in actual_port), "delete dynamicVlan config fail" assert( "guestvlans" not in actual_port["ports"]), "delete guestvlans config fail"
def runTest(self): vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan = StaticVLAN(vlan_cfg) vlan_cfg['guestvlans'] = [ { "port": 1, "guestVlan": 5 }, { "port": 2, "guestVlan": 10 } ] vlanGuest = GuestVLAN(vlan_cfg).build() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) for portNum in actual_port["ports"]: if portNum["port"] == vlan_cfg['guestvlans'][0]['port']: assert(vlan_cfg['guestvlans'][0]['guestVlan'] == portNum['guestVlan']), "native type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" vlan_cfg['dynamicvlans'] = [ { "port": 1, "dynamicVlan": "disable" }, { "port": 2, "dynamicVlan": "disable" } ] vlanDynamic = DynamicVLAN(vlan_cfg).build() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) for portNum in actual_port["ports"]: if portNum["port"] == vlan_cfg['dynamicvlans'][0]['port']: assert(vlan_cfg['dynamicvlans'][0]['dynamicVlan'] == portNum['dynamicVlan']), "dynamicVlan type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error"
def runTest(self): vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan = StaticVLAN(vlan_cfg) actual_port = vlan.get_vlanConfig() assert("devices" in actual_port), "Cannot get dynamicVlan config" vlan_cfg['dynamicvlans'] = [ { "port": 6, "dynamicVlan": "enable" } ] vlanDynamic = DynamicVLAN(vlan_cfg).build() actual_port = vlan.get_vlanConfig() passMark = 0 for dutId in actual_port["devices"]: if cfg.leaf0['id'] == dutId["device-id"]: assert(dutId["ports"] != []), "Cannot get dynamicVlan config" passMark = 1 assert(passMark == 1), "Cannot get vlan config with device-id"
def runTest(self): vlan_cfg = {} vlan_cfg['device-id'] = cfg.spine0['id'] vlan_cfg['ports'] = [{ "port": 46, "native": 100, "mode": "access", "vlans": ["100/untag", "200/untag"] }] vlan = StaticVLAN(vlan_cfg).build() self.reboot_spine0_switch() actual_port = vlan.get_port(46) assert (vlan_cfg['ports'][0]['port'] == actual_port['port']) assert (vlan_cfg['ports'][0]['native'] == actual_port['native']) assert (vlan_cfg['ports'][0]['mode'] == actual_port['mode']) assert (['100/untag'] == actual_port['vlans'])
def runTest(self): vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan = StaticVLAN(vlan_cfg) vlan_cfg['guestvlans'] = [ { "port": 1, "guestVlan": 25 } ] vlanGuest = GuestVLAN(vlan_cfg).build() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) assert(actual_port["ports"] != []), "Cannot get guestVlan config" vlan_cfg['dynamicvlans'] = [ { "port": 6, "dynamicVlan": "enable" } ] vlanDynamic = DynamicVLAN(vlan_cfg).build() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) assert(actual_port["ports"] != []), "Cannot get dynamicVlan config"
def runTest(self): guestVlan_cfg = {} guestVlan_cfg['device-id'] = cfg.leaf0['id'] guestVlan_cfg['data'] = { "guestvlans": [ { "port": 1, "guestVlan": 20 }, { "port": 2, "guestVlan": 20 } ] } guestVlan = StaticVLAN(guestVlan_cfg).buildById() actual_port = guestVlan.get_vlanConfigById(cfg.leaf0['id']) chkData = guestVlan_cfg['data']['guestvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['guestVlan'] == portNum['guestVlan']), "guestVlan id error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" chkData = guestVlan_cfg['data']['guestvlans'][1] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['guestVlan'] == portNum['guestVlan']), "guestVlan id error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['data'] = { "dynamicvlans": [ { "port": 1, "dynamicVlan": "disable" }, { "port": 2, "dynamicVlan": "disable" } ] } vlan = StaticVLAN(vlan_cfg).buildById() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) chkData = vlan_cfg['data']['dynamicvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['dynamicVlan'] == portNum['dynamicVlan']), "dynamicVlan id error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" chkData = vlan_cfg['data']['dynamicvlans'][1] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['dynamicVlan'] == portNum['dynamicVlan']), "dynamicVlan id error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" del_cfg = {} del_cfg['device-id'] = cfg.leaf0['id'] del_cfg["port"] = vlan_cfg['data']["dynamicvlans"][0]["port"] vlan = StaticVLAN(del_cfg) vlan.delete(del_cfg) actual_port = vlan.get_port( vlan_cfg['data']["dynamicvlans"][0]["port"]) assert(None == actual_port), "Delete port 1 config fail" actual_port = vlan.get_port( vlan_cfg['data']["dynamicvlans"][1]["port"]) assert(None != actual_port), "Not found config of port 2" actual_port = guestVlan.get_vlanConfigById(cfg.leaf0['id']) chkData = guestVlan_cfg['data']['guestvlans'][1] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['guestVlan'] == portNum['guestVlan']), "guestVlan id error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" chkData = vlan_cfg['data']['dynamicvlans'][1] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['dynamicVlan'] == portNum['dynamicVlan']), "dynamicVlan id error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error"
def runTest(self): vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['data'] = { "guestvlans": [ { "port": 1, "guestVlan": 20 } ] } vlan = StaticVLAN(vlan_cfg).buildById() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) chkData = vlan_cfg['data']['guestvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['guestVlan'] == portNum['guestVlan']), "guestVlan type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['data'] = { "guestvlans": [ { "port": 1, "guestVlan": 25 } ] } vlan = StaticVLAN(vlan_cfg).put() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) chkData = vlan_cfg['data']['guestvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['guestVlan'] == portNum['guestVlan']), "guestVlan type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['data'] = { "dynamicvlans": [ { "port": 2, "dynamicVlan": "enable" } ] } vlan = StaticVLAN(vlan_cfg).buildById() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) chkData = vlan_cfg['data']['dynamicvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['dynamicVlan'] == portNum['dynamicVlan']), "dynamicVlan type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error" vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['data'] = { "dynamicvlans": [ { "port": 2, "dynamicVlan": "disable" } ] } vlanIp = StaticVLAN(vlan_cfg).put() actual_port = vlan.get_vlanConfigById(cfg.leaf0['id']) chkData = vlan_cfg['data']['dynamicvlans'][0] for portNum in actual_port["ports"]: if portNum["port"] == chkData['port']: assert(chkData['dynamicVlan'] == portNum['dynamicVlan']), "dynamicVlan type error" break elif portNum["port"] == actual_port["ports"][len(actual_port["ports"])-1]["port"]: assert(False), "Port number error"
def runTest(self): ports = sorted(config["port_map"].keys()) vlan_cfg = {} acl_cfg = {} acl_cfg['device-id'] = [cfg.leaf0['id']] vlan = StaticVLAN(vlan_cfg) acl = ACL(acl_cfg) actual_device = acl.delete_deviceById(cfg.leaf0['id']) time.sleep(2) actual_device = acl.delete_deviceById(cfg.leaf1['id']) time.sleep(2) actual_device = acl.delete_deviceById(cfg.spine0['id']) time.sleep(2) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf0['id']}) time.sleep(2) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf1['id']}) time.sleep(2) actual_device = acl.get_device() cfg.host0['ip'] = '192.168.100.1' cfg.host2['ip'] = '192.168.100.3' vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['ports'] = [{ "port": 1, "native": 10, "mode": "hybrid", "vlans": ["10/tag"] }] vlan = StaticVLAN(vlan_cfg).build() time.sleep(6) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan_cfg['ports'] = [{ "port": 1, "native": 10, "mode": "hybrid", "vlans": ["10/tag"] }] vlan = StaticVLAN(vlan_cfg).build() time.sleep(6) acl_cfg['device-id'] = [cfg.leaf0['id']] acl_cfg['data'] = { "ports": [1], "direction": "true", "action": "permit", "mac": { "vid": 10, "vidMask": 4095 } } actual_device = acl.build() time.sleep(5) pkt_from_p0_to_p2 = simple_tcp_packet(pktlen=68, dl_vlan_enable=True, vlan_vid=10, eth_dst=cfg.host2['mac'], eth_src=cfg.host0['mac'], ip_dst=cfg.host2['ip'], ip_src=cfg.host0['ip']) expected_pkt = pkt_from_p0_to_p2 #print("debug: =======expect pkt_from_p0_to_p2 =======") for i in range(5): self.dataplane.send(ports[0], str(pkt_from_p0_to_p2)) wait_for_seconds(1) verify_packet(self, str(expected_pkt), ports[2]) #print("debug: ", str(expected_pkt), ports[2]) acl_cfg['device-id'] = [cfg.leaf1['id']] acl_cfg['data'] = { "ports": [1], "direction": "true", "action": "deny", "mac": { "vid": 10, "vidMask": 4095 } } actual_device = acl.build() time.sleep(2) pkt_from_p2_to_p0 = simple_tcp_packet(pktlen=68, dl_vlan_enable=True, vlan_vid=10, eth_dst=cfg.host0['mac'], eth_src=cfg.host2['mac'], ip_dst=cfg.host0['ip'], ip_src=cfg.host2['ip']) expected_pkt = pkt_from_p2_to_p0 #print("debug: =======expect pkt_from_p2_to_p0 =======") for i in range(5): self.dataplane.send(ports[2], str(pkt_from_p2_to_p0)) wait_for_seconds(1) verify_no_packet(self, str(expected_pkt), ports[0]) vlan_cfg['device-id'] = cfg.leaf0['id'] vlan.delete({'port': 1, 'device-id': cfg.leaf0['id']}) actual_port = vlan.get_port(1) assert (None == actual_port) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan.delete({'port': 1, 'device-id': cfg.leaf1['id']}) actual_port = vlan.get_port(1) assert (None == actual_port)
def runTest(self): ports = sorted(config["port_map"].keys()) vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg_sw1 = {} vlan_cfg_sw1['device-id'] = cfg.leaf0['id'] sflow_cfg = {} sflow_cfg['device-id'] = [cfg.leaf0['id']] sflow = SFLOW(sflow_cfg) sflow.delete_deviceByIdNotVerify(cfg.leaf0['id']) sflow.delete_deviceByIdNotVerify(cfg.leaf1['id']) sflow.delete_deviceByIdNotVerify(cfg.spine0['id']) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan = StaticVLAN(vlan_cfg) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf0['id']}) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf1['id']}) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan_cfg['vlans'] = [{ "vlan": 1, "ip": "10.0.10.113", "mask": "255.255.255.0" }] vlan = VLAN(vlan_cfg).build() vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['vlans'] = [{ "vlan": 1, "ip": "10.0.10.111", "mask": "255.255.255.0" }] vlan = VLAN(vlan_cfg).build() vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf1['id'] vlan_cfg['ports'] = [{ "port": 1, "native": 10, "mode": "access", "vlans": ["10/untag"] }] vlan = StaticVLAN(vlan_cfg).build() vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['ports'] = [{ "port": 1, "native": 20, "mode": "access", "vlans": ["20/untag"] }] vlan = StaticVLAN(vlan_cfg).build() sflow_cfg['device-id'] = cfg.leaf1['id'] sflow_cfg['data'] = { "collector_ip": "10.0.10.14", "max_payload_length": 200, "max_header_length": 100, "polling_interval": 3, "sample_rate": 256, "port": [1], "duration": 1000 } actual_device = sflow.build() sflow_cfg['device-id'] = cfg.leaf0['id'] sflow_cfg['data'] = { "collector_ip": "10.0.10.14", "max_payload_length": 300, "max_header_length": 200, "polling_interval": 3, "sample_rate": 256, "port": [1], "duration": 1000 } actual_device = sflow.build() pkt_from_p2_to_p2 = simple_eth_packet(pktlen=64, eth_dst='ff:ff:ff:ff:ff:ff', eth_src=cfg.host2['mac']) expected_pkt = simple_eth_packet(pktlen=12, eth_type=0x0800, eth_dst=HOST3_MAC, eth_src=cfg.leaf1['mac']) #print("debug expected_pkt: ",expected_pkt) for i in range(500): self.dataplane.send(ports[2], str(pkt_from_p2_to_p2)) wait_for_seconds(0.1) verify_packet(self, str(expected_pkt), ports[3]) verify_no_packet(self, str(expected_pkt), ports[1]) pkt_from_p0_to_p0 = simple_eth_packet(pktlen=250, eth_dst='ff:ff:ff:ff:ff:ff', eth_src=cfg.host0['mac']) expected_pkt = simple_eth_packet(pktlen=12, eth_type=0x0800, eth_dst=HOST3_MAC, eth_src=cfg.leaf0['mac']) #print("debug expected_pkt: ",expected_pkt) for i in range(500): self.dataplane.send(ports[0], str(pkt_from_p0_to_p0)) wait_for_seconds(0.1) verify_packet(self, str(expected_pkt), ports[3]) verify_no_packet(self, str(expected_pkt), ports[1])
def runTest(self): ports = sorted(config["port_map"].keys()) vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg_sw1 = {} vlan_cfg_sw1['device-id'] = cfg.leaf0['id'] sflow_cfg = {} sflow_cfg['device-id'] = [cfg.leaf0['id']] sflow = SFLOW(sflow_cfg) sflow.delete_deviceByIdNotVerify(cfg.leaf0['id']) sflow.delete_deviceByIdNotVerify(cfg.leaf1['id']) sflow.delete_deviceByIdNotVerify(cfg.spine0['id']) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan_cfg['vlans'] = [{ "vlan": 1, "ip": "10.0.10.113", "mask": "255.255.255.0" }] vlan = VLAN(vlan_cfg).build() sflow_cfg['device-id'] = cfg.leaf1['id'] sflow_cfg['data'] = { "collector_ip": "10.0.10.13", "max_payload_length": 200, "max_header_length": 64, "polling_interval": 3, "sample_rate": 256, "port": [1], "duration": 30 } actual_device = sflow.build() #part 2 vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['vlans'] = [{ "vlan": 1, "ip": "10.0.10.111", "mask": "255.255.255.0" }] vlan = VLAN(vlan_cfg).build() sflow_cfg['device-id'] = cfg.leaf0['id'] sflow_cfg['data'] = { "collector_ip": "10.0.10.13", "max_payload_length": 200, "max_header_length": 64, "polling_interval": 3, "sample_rate": 256, "port": [1], "duration": 30 } actual_device = sflow.build() time.sleep(35) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan = StaticVLAN(vlan_cfg) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf0['id']}) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf1['id']}) #actual_device = sflow.delete_deviceById(cfg.leaf0['id']) #time.sleep(2) #actual_device = sflow.delete_deviceById(cfg.leaf1['id']) #time.sleep(2) actual_device = sflow.get_deviceById(cfg.leaf1['id']) assert ({} == actual_device), "delete leaf1 fail" actual_device = sflow.get_deviceById(cfg.leaf0['id']) assert ({} == actual_device), "delete leaf0 fail"
def runTest(self): ports = sorted(config["port_map"].keys()) vlan_cfg = {} vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg_sw1 = {} vlan_cfg_sw1['device-id'] = cfg.leaf0['id'] sflow_cfg = {} sflow_cfg['device-id'] = [cfg.leaf0['id']] sflow = SFLOW(sflow_cfg) sflow.delete_deviceByIdNotVerify(cfg.leaf0['id']) sflow.delete_deviceByIdNotVerify(cfg.leaf1['id']) sflow.delete_deviceByIdNotVerify(cfg.spine0['id']) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan = StaticVLAN(vlan_cfg) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf0['id']}) vlan.delete_DevieIdNoVerify({'device-id': cfg.leaf1['id']}) vlan_cfg['device-id'] = cfg.leaf1['id'] vlan_cfg['vlans'] = [{ "vlan": 1, "ip": "10.0.10.113", "mask": "255.255.255.0" }] vlan = VLAN(vlan_cfg).build() vlan_cfg['device-id'] = cfg.leaf0['id'] vlan_cfg['vlans'] = [{ "vlan": 1, "ip": "10.0.10.111", "mask": "255.255.255.0" }] vlan = VLAN(vlan_cfg).build() sflow_cfg['device-id'] = cfg.leaf1['id'] sflow_cfg['data'] = { "collector_ip": "10.0.10.14", "max_payload_length": 200, "max_header_length": 100, "polling_interval": 3, "sample_rate": 256, "port": [1], "duration": 10000 } actual_device = sflow.build() sflow_cfg['device-id'] = cfg.leaf0['id'] sflow_cfg['data'] = { "collector_ip": "10.0.10.14", "max_payload_length": 300, "max_header_length": 200, "polling_interval": 3, "sample_rate": 256, "port": [1], "duration": 10000 } actual_device = sflow.build() rebootTest = RebootSwitch(cfg.leaf0['id']) rebootTest.reboot() rebootTest = RebootSwitch(cfg.leaf1['id']) rebootTest.reboot() time.sleep(180) actual_device = sflow.get_deviceById(cfg.leaf0['id']) assert (3 == actual_device["pollingInterval"] ), "Verify pollingInterval fail by reboot(leaf0)" actual_device = sflow.get_deviceById(cfg.leaf1['id']) assert (3 == actual_device["pollingInterval"] ), "Verify pollingInterval fail by reboot(leaf1)"
def runTest(self): port_configuration() class_map_cfg = (ClassMapCfg('classA').device(cfg.leaf0['id']).match( 'vlan', 10).create()) class_map = ClassMap(class_map_cfg) class_map.create() policy_map_cfg = ( PolicyMapCfg('policyA').class_map('classA').cos(7).create()) policy_map = PolicyMap(policy_map_cfg, cfg.leaf0['id']) policy_map.create() services_cfg = (ServicesCfg().policy_map('policyA').port( cfg.leaf0['portA'].number).create()) services = Services(services_cfg, cfg.leaf0['id']) services.create() vlan_id = 10 ports = sorted(config["port_map"].keys()) vlan_cfg_sw1 = {} vlan_cfg_sw1['device-id'] = cfg.leaf0['id'] vlan_cfg_sw1['ports'] = [{ "port": 46, "native": vlan_id, "mode": "hybrid", "vlans": [str(vlan_id) + "/untag"] }, { "port": 48, "native": vlan_id, "mode": "hybrid", "vlans": [str(vlan_id) + "/tag"] }] vlan_sw1 = StaticVLAN(vlan_cfg_sw1).build() wait_for_seconds(3) pkt_from_p0_to_p1 = simple_tcp_packet(pktlen=68, dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=cfg.host1['mac'], eth_src=cfg.host0['mac'], ip_dst=cfg.host1['ip'], ip_src=cfg.host0['ip']) expected_pkt = simple_tcp_packet(pktlen=68, dl_vlan_enable=True, vlan_vid=vlan_id, vlan_pcp=7, eth_dst=cfg.host1['mac'], eth_src=cfg.host0['mac'], ip_dst=cfg.host1['ip'], ip_src=cfg.host0['ip']) self.dataplane.send(ports[0], str(pkt_from_p0_to_p1)) verify_packet(self, str(expected_pkt), ports[1]) # clear services.delete() policy_map.delete() class_map.delete()