Example #1
0
    def runTest(self):
        acl_cfg = {}
        acl_cfg['device-id'] = [cfg.leaf0['id']]

        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)
        actual_device = acl.get_device()
        #print("debug acl device status1:", actual_device)
        acl_cfg['data'] = {
            "ports": [1],
            "direction": "true",
            "action": "permit",
            "ipv4": {
                "protocol": 17,
                "srcIp": "1.1.1.1",
                "srcIpMask": "255.255.255.255"
            }
        }
        actual_device = acl.build()
        time.sleep(5)
        acl_cfg['device-id'] = [cfg.leaf0['id']]
        acl_cfg['data'] = {
            "ports": [2],
            "direction": "true",
            "action": "permit",
            "ipv4": {
                "protocol": 17,
                "dstIp": "2.2.2.2",
                "dstIpMask": "255.255.255.255"
            }
        }
        actual_device = acl.build()
        time.sleep(2)
        #print("debug:==============================")
        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("debug actual_device1:", actual_device)
        assert (2 == len(actual_device)), "Acl rule len != 2 fail on device 1"
        testResult = False
        for testData in actual_device:
            if testData["ipv4"]["srcIp"] == "1.1.1.1": testResult = True
        assert (True == testResult), "acl setup srcIp rule fail"
        testResult = False
        for testData in actual_device:
            if testData["ipv4"]["dstIp"] == "2.2.2.2": testResult = True
        assert (True == testResult), "acl setup dstIp rule fail"

        acl.delete_deviceById(cfg.leaf0['id'])
        time.sleep(2)

        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("debug actual_device3:", actual_device)
        assert (0 == len(actual_device)), "Acl rule len != 0 fail on device 1"
        acl.delete_deviceById(cfg.leaf1['id'])
Example #2
0
    def runTest(self):
        acl_cfg = {}
        acl_cfg['device-id'] = [cfg.leaf0['id']]

        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)
        actual_device = acl.get_device()
        #print("debug acl device status1:", actual_device)
        acl_cfg['data'] = {
            "ports": [1],
            "direction": "true",
            "action": "permit",
            "mac": {
                "srcMac": "11:11:11:11:11:11",
                "srcMacMask": "FF:FF:FF:FF:FF:FF"
            }
        }
        actual_device = acl.build()
        time.sleep(5)
        acl_cfg['device-id'] = [cfg.leaf0['id']]
        acl_cfg['data'] = {
            "ports": [2],
            "direction": "true",
            "action": "permit",
            "mac": {
                "dstMac": "22:22:22:22:22:22",
                "dstMacMask": "FF:FF:FF:FF:FF:FF"
            }
        }
        actual_device = acl.build()
        time.sleep(2)
        #print("debug:==============================")
        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("debug actual_device:", actual_device)
        assert (2 == len(actual_device)), "Acl rule set len fail"

        delId_1 = actual_device[0]["policyId"]
        delId_2 = actual_device[1]["policyId"]
        #print("debug policyId 1:", delId_1)
        #print("debug policyId 2:", delId_2)

        actual_device = acl.delete_deviceSpecifyRuleId(cfg.leaf0['id'],
                                                       delId_1)
        time.sleep(2)
        actual_device = acl.delete_deviceSpecifyRuleId(cfg.leaf0['id'],
                                                       delId_2)
        time.sleep(2)
        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("debug acl device status:", actual_device)
        assert (0 == len(actual_device)), "Acl rule set len fail"
Example #3
0
    def runTest(self):
        acl_cfg = {}
        acl_cfg['device-id'] = [cfg.leaf0['id']]

        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)
        actual_device = acl.get_device()
        #print("debug acl device status1:", actual_device)
        acl_cfg['data'] = {
            "ports": [1],
            "direction": "true",
            "action": "permit",
            "mac": {
                "etherType": "0800",
                "etherTypeMask": "FFFF"
            }
        }
        actual_device = acl.build()
        time.sleep(5)
        acl_cfg['device-id'] = [cfg.leaf0['id']]
        acl_cfg['data'] = {
            "ports": [2],
            "direction": "true",
            "action": "permit",
            "mac": {
                "vid": 10,
                "vidMask": 4095
            }
        }
        actual_device = acl.build()
        time.sleep(2)
        #print("debug:==============================")
        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("debug actual_device1:", actual_device)
        assert (2 == len(actual_device)), "Acl rule len != 2 fail on device 1"
        assert ("0800" == actual_device[0]["mac"]["etherType"]
                ), "acl setup ether type rule fail"
        assert (10 == actual_device[1]["mac"]["vid"]
                ), "acl setup vlan id rule fail"
        acl.delete_deviceById(cfg.leaf0['id'])
        time.sleep(2)

        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("debug actual_device3:", actual_device)
        assert (0 == len(actual_device)), "Acl rule len != 0 fail on device 1"
        acl.delete_deviceById(cfg.leaf1['id'])
Example #4
0
    def runTest(self):
        acl_cfg = {}
        acl_cfg['device-id'] = [cfg.leaf0['id']]
        acl_cfg['data'] = {
            "ports": [1],
            "direction": "true",
            "action": "permit",
            "mac": {
                "srcMac": "11:11:11:11:11:11",
                "srcMacMask": "FF:FF:FF:FF:FF:FF"
            }
        }

        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)
        actual_device = acl.get_device()
        #print("debug acl device status1:", actual_device)
        actual_device = acl.build()
        time.sleep(2)
        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("==============================")
        #print("debug acl device status2:", actual_device)
        assert ("11:11:11:11:11:11" == actual_device[0]["mac"]["srcMac"]
                ), "acl setup src mac rule fail"
Example #5
0
    def runTest(self):
        acl_cfg = {}
        acl_cfg['device-id'] = [cfg.leaf0['id']]

        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)
        actual_device = acl.get_device()
        #print("debug acl device status1:", actual_device)
        acl_cfg['data'] = {
            "ports": [1],
            "direction": "true",
            "action": "permit",
            "mac": {
                "srcMac": "11:11:11:11:11:11",
                "srcMacMask": "FF:FF:FF:FF:FF:FF"
            }
        }
        actual_device = acl.build()
        time.sleep(5)
        acl_cfg['device-id'] = [cfg.leaf1['id']]
        acl_cfg['data'] = {
            "ports": [1],
            "direction": "true",
            "action": "permit",
            "mac": {
                "dstMac": "22:22:22:22:22:22",
                "dstMacMask": "FF:FF:FF:FF:FF:FF"
            }
        }
        actual_device = acl.build()
        time.sleep(2)
        #print("debug:==============================")
        actual_device = acl.get_deviceById(cfg.leaf0['id'])
        #print("debug actual_device1:", actual_device)
        assert (
            1 == len(actual_device)), "Acl rule set len != 1 fail on device 1"

        #print("debug:==============================")
        actual_device = acl.get_deviceById(cfg.leaf1['id'])
        #print("debug actual_device2:", actual_device)
        assert (
            1 == len(actual_device)), "Acl rule set len != 1 fail on device 2"