예제 #1
0
    def runTest(self):
        sflow_cfg = {}
        sflow_cfg['device-id'] = cfg.leaf0['id']
        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.20",
            "max_payload_length": 1500,
            "max_header_length": 256,
            "polling_interval": 10000000,
            "sample_rate": 16777215,
            "port": [3],
            "duration": 10000000
        }

        sflow = SFLOW(sflow_cfg)
        sflow.delete_deviceByIdNotVerify(cfg.leaf0['id'])
        sflow.delete_deviceByIdNotVerify(cfg.leaf1['id'])
        sflow.delete_deviceByIdNotVerify(cfg.spine0['id'])

        actual_device = sflow.build()

        actual_device = sflow.get_deviceById(cfg.leaf0['id'])
        assert ("192.168.2.20" == actual_device["controllerIp"]
                ), "collector_ip setup fail"
        assert (1500 == actual_device["maxPayloadLength"]
                ), "'maxPayloadLength setup fail"
        assert (10000000 == actual_device["duration"]), "duration setup fail"
        assert (10000000 == actual_device["pollingInterval"]
                ), "pollingInterval setup fail"
        assert (16777215 == actual_device["samplingRate"]
                ), "samplingRate setup fail"
        assert (256 == actual_device["maxHeaderLength"]
                ), "maxHeaderLength setup fail"
예제 #2
0
    def runTest(self):
        sflow_cfg = {}
        sflow_cfg['device-id'] = cfg.leaf0['id']
        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.20",
            "max_payload_length": 1500,
            "max_header_length": 64,
            "polling_interval": 10000000,
            "sample_rate": 16777215,
            "port": [1],
            "duration": 10000000
        }

        sflow = SFLOW(sflow_cfg)
        sflow.delete_deviceByIdNotVerify(cfg.leaf0['id'])
        sflow.delete_deviceByIdNotVerify(cfg.leaf1['id'])
        sflow.delete_deviceByIdNotVerify(cfg.spine0['id'])

        actual_device = sflow.build()

        actual_device = sflow.get_deviceById(cfg.leaf0['id'])
        assert ("192.168.2.20" == actual_device["controllerIp"]
                ), "collector_ip setup fail"
        assert (64 == actual_device["maxHeaderLength"]
                ), "maxHeaderLength setup fail"

        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.20",
            "max_payload_length": 1500,
            "max_header_length": 256,
            "polling_interval": 10000000,
            "sample_rate": 16777215,
            "port": [1],
            "duration": 10000000
        }
        actual_device = sflow.buildNotSuccess()

        #print("Debug: Build sflow rule not success ==> pass")
        actual_device = sflow.get_deviceById(cfg.leaf0['id'])
        assert (64 == actual_device["maxHeaderLength"]
                ), "maxHeaderLength setup fail"
예제 #3
0
    def runTest(self):
        sflow_cfg = {}
        sflow_cfg['device-id'] = cfg.leaf0['id']
        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.20",
            "max_payload_length": 1500,
            "max_header_length": 256,
            "polling_interval": 10000000,
            "sample_rate": 16777215,
            "port": [1],
            "duration": 10000000
        }

        sflow = SFLOW(sflow_cfg)
        sflow.delete_deviceByIdNotVerify(cfg.leaf0['id'])
        sflow.delete_deviceByIdNotVerify(cfg.leaf1['id'])
        sflow.delete_deviceByIdNotVerify(cfg.spine0['id'])

        actual_device = sflow.build()

        actual_device = sflow.get_deviceById(cfg.leaf0['id'])
        assert (
            10000000 == actual_device["duration"]), "duration setup fail(c1)"

        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.20",
            "max_payload_length": 200,
            "max_header_length": 256,
            "polling_interval": 10000000,
            "sample_rate": 256,
            "port": [1],
            "duration": 30
        }
        actual_device = sflow.buildNotSuccess()

        actual_device = sflow.get_deviceById(cfg.leaf0['id'])
        assert (
            10000000 == actual_device["duration"]), "duration setup fail(c2)"
예제 #4
0
    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])
예제 #5
0
    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"
예제 #6
0
    def runTest(self):
        sflow_cfg = {}
        sflow = SFLOW(sflow_cfg)
        sflow.delete_deviceByIdNotVerify(cfg.leaf0['id'])
        sflow.delete_deviceByIdNotVerify(cfg.leaf1['id'])
        sflow.delete_deviceByIdNotVerify(cfg.spine0['id'])

        sflow_cfg['device-id'] = cfg.leaf0['id']
        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.10",
            "max_payload_length": 1500,
            "max_header_length": 256,
            "polling_interval": 10000000,
            "sample_rate": 16777215,
            "port": [1],
            "duration": 10000000
        }
        actual_device = sflow.build()

        sflow_cfg['device-id'] = cfg.leaf1['id']
        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.20",
            "max_payload_length": 1500,
            "max_header_length": 256,
            "polling_interval": 10000000,
            "sample_rate": 16777215,
            "port": [1],
            "duration": 10000000
        }
        actual_device = sflow.build()

        sflow_cfg['device-id'] = cfg.spine0['id']
        sflow_cfg['data'] = {
            "collector_ip": "192.168.2.30",
            "max_payload_length": 1500,
            "max_header_length": 256,
            "polling_interval": 10000000,
            "sample_rate": 16777215,
            "port": [1],
            "duration": 10000000
        }
        actual_device = sflow.build()

        actual_device = sflow.get_deviceById(cfg.leaf0['id'])
        assert ("192.168.2.10" == actual_device["controllerIp"]
                ), "1:collector_ip setup fail"

        actual_device = sflow.get_deviceById(cfg.leaf1['id'])
        assert ("192.168.2.20" == actual_device["controllerIp"]
                ), "2:collector_ip setup fail"

        actual_device = sflow.get_deviceById(cfg.spine0['id'])
        assert ("192.168.2.30" == actual_device["controllerIp"]
                ), "3:collector_ip setup fail"

        actual_device = sflow.delete_deviceById(cfg.leaf0['id'])

        actual_device = sflow.get_deviceById(cfg.leaf0['id'])
        assert ({} == actual_device), "delete leaf0 fail"

        actual_device = sflow.delete_deviceById(cfg.leaf1['id'])

        actual_device = sflow.get_deviceById(cfg.leaf1['id'])
        assert ({} == actual_device), "delete leaf1 fail"

        actual_device = sflow.delete_deviceById(cfg.spine0['id'])

        actual_device = sflow.get_deviceById(cfg.spine0['id'])
        assert ({} == actual_device), "delete spine fail"
예제 #7
0
    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)"