def runTest(self):
        class_map_cfg = (ClassMapCfg('classD').device(cfg.leaf0['id']).match(
            'dscp', 20).create())

        class_map = ClassMap(class_map_cfg)
        class_map.create()

        policy_map_cfg = (
            PolicyMapCfg('policyD').class_map('classD').phb(3).flow(
                cir=1245000, bc=324288, conform="transmit",
                violate="drop").create())

        policy_map = PolicyMap(policy_map_cfg, cfg.leaf0['id'])
        policy_map.create()

        assert policy_map.retrieve() == policy_map_cfg['policyMap']

        new_policy_map_cfg = (
            PolicyMapCfg('policyD').class_map('classD').cos(5).create())

        policy_map.update(new_policy_map_cfg)
        assert policy_map.retrieve() == new_policy_map_cfg['policyMap']

        # clear
        policy_map.delete()
        class_map.delete()
    def runTest(self):
        class_map_cfg1 = (ClassMapCfg('classA').device(cfg.leaf0['id']).match(
            'dscp', 32).create())
        class_map_cfg2 = (ClassMapCfg('classB').device(cfg.leaf1['id']).match(
            'cos', 3).create())

        class_map1 = ClassMap(class_map_cfg1)
        class_map1.create()
        class_map2 = ClassMap(class_map_cfg2)
        class_map2.create()

        policy_map_cfg1 = (PolicyMapCfg('policyA').device(
            cfg.leaf0['id']).class_map('classA').cos(7).flow(
                cir=1245000, bc=324288, conform="transmit",
                violate="drop").create())
        policy_map_cfg2 = (PolicyMapCfg('policyB').device(
            cfg.leaf1['id']).class_map('classB').phb(3).flow(
                cir=1000000, bc=224288, conform="transmit",
                violate="drop").create())

        policy_map_cfg_list = [policy_map_cfg1, policy_map_cfg2]

        policy_map = PolicyMap(policy_map_cfg_list, multiple=True)
        policy_map.create()

        services_cfg1 = (ServicesCfg().device(
            cfg.leaf0['id']).policy_map('policyA').port(10).create())
        services_cfg2 = (ServicesCfg().device(
            cfg.leaf1['id']).policy_map('policyB').port(20).create())

        services_cfg_list = [services_cfg1, services_cfg2]

        services = Services(services_cfg_list, multiple=True)

        for device in services.retrieve():
            assert device['services'] == []

        services.create()

        for device in services.retrieve():
            if device['deviceId'] == cfg.leaf0['id']:
                assert device['services'] == services_cfg1['services']
            elif device['deviceId'] == cfg.leaf1['id']:
                assert device['services'] == services_cfg2['services']

        # clear
        services.delete()
        policy_map.delete()
        class_map1.delete()
        class_map2.delete()
    def runTest(self):
        class_map_cfg1 = (ClassMapCfg('classE').device(cfg.leaf0['id']).match(
            'cos', 2).create())
        class_map_cfg2 = (ClassMapCfg('classF').device(cfg.leaf1['id']).match(
            'precedence', 3).create())

        class_map1 = ClassMap(class_map_cfg1)
        class_map1.create()
        class_map2 = ClassMap(class_map_cfg2)
        class_map2.create()

        policy_map_cfg1 = (PolicyMapCfg('policyE').device(
            cfg.leaf0['id']).class_map('classE').cos(6).create())
        policy_map_cfg2 = (PolicyMapCfg('policyF').device(
            cfg.leaf1['id']).class_map('classF').phb(7).create())

        policy_map_cfg_list = [policy_map_cfg1, policy_map_cfg2]

        policy_map = PolicyMap(policy_map_cfg_list, multiple=True)
        policy_map.create()

        services_cfg1 = (ServicesCfg().device(
            cfg.leaf0['id']).policy_map('policyE').port(18).create())
        services_cfg2 = (ServicesCfg().device(
            cfg.leaf1['id']).policy_map('policyF').port(28).create())

        services_cfg_list = [services_cfg1, services_cfg2]

        services = Services(services_cfg_list, multiple=True)

        for device in services.retrieve():
            assert device['services'] == []

        services.create()

        for device in services.retrieve():
            if device['deviceId'] == cfg.leaf0['id']:
                assert device['services'] == services_cfg1['services']
            elif device['deviceId'] == cfg.leaf1['id']:
                assert device['services'] == services_cfg2['services']

        services.delete()
        for device in services.retrieve():
            assert device['services'] == []

        # clear
        policy_map.delete()
        class_map1.delete()
        class_map2.delete()
    def runTest(self):
        class_map_cfg = (ClassMapCfg('classD').device(cfg.leaf0['id']).match(
            'vlan', 15).create())

        class_map = ClassMap(class_map_cfg)
        class_map.create()

        policy_map_cfg = (
            PolicyMapCfg('policyD').class_map('classD').cos(7).flow(
                cir=1122000, bc=524288, conform="transmit",
                violate="drop").create())

        policy_map = PolicyMap(policy_map_cfg, cfg.leaf0['id'])
        policy_map.create()

        services_cfg = (ServicesCfg().policy_map('policyD').port(10).create())

        services = Services(services_cfg, cfg.leaf0['id'])

        services.create()
        assert services.retrieve() == services_cfg['services']

        new_services_cfg = (
            ServicesCfg().policy_map('policyD').port(20).create())

        services.update(new_services_cfg)
        assert services.retrieve() == new_services_cfg['services']

        # clear
        services.delete()
        policy_map.delete()
        class_map.delete()
    def runTest(self):
        class_map_cfg = (ClassMapCfg('classC').device(cfg.leaf0['id']).match(
            'cos', 3).create())

        class_map = ClassMap(class_map_cfg)
        class_map.create()

        policy_map_cfg = (
            PolicyMapCfg('policyC').class_map('classC').cos(2).flow(
                cir=1122000, bc=524288, conform="transmit",
                violate="drop").create())

        policy_map = PolicyMap(policy_map_cfg, cfg.leaf0['id'])
        policy_map.create()

        services_cfg = (ServicesCfg().policy_map('policyC').port(1).create())

        services = Services(services_cfg, cfg.leaf0['id'])

        assert services.retrieve() == []
        services.create()
        assert services.retrieve() == services_cfg['services']

        services.delete()
        assert services.retrieve() == []

        # clear
        policy_map.delete()
        class_map.delete()
    def runTest(self):
        class_map_cfg1 = (ClassMapCfg('classC').device(cfg.leaf0['id']).match(
            'vlan', 25).create())
        class_map_cfg2 = (ClassMapCfg('classD').device(cfg.leaf1['id']).match(
            'dscp', 10).create())

        class_map1 = ClassMap(class_map_cfg1)
        class_map1.create()
        class_map2 = ClassMap(class_map_cfg2)
        class_map2.create()

        policy_map_cfg1 = (PolicyMapCfg('policyC').device(
            cfg.leaf0['id']).class_map('classC').cos(3).create())
        policy_map_cfg2 = (PolicyMapCfg('policyD').device(
            cfg.leaf1['id']).class_map('classD').phb(5).create())

        policy_map_cfg_list = [policy_map_cfg1, policy_map_cfg2]

        policy_map = PolicyMap(policy_map_cfg_list, multiple=True)
        policy_map.create()

        services_cfg1 = (ServicesCfg().device(
            cfg.leaf0['id']).policy_map('policyC').port(15).create())
        services_cfg2 = (ServicesCfg().device(
            cfg.leaf1['id']).policy_map('policyD').port(25).create())

        services_cfg_list = [services_cfg1, services_cfg2]

        services = Services(services_cfg_list, multiple=True)

        for device in services.retrieve():
            assert device['services'] == []

        services.create()

        for device in services.retrieve():
            if device['deviceId'] == cfg.leaf0['id']:
                assert device['services'] == services_cfg1['services']
            elif device['deviceId'] == cfg.leaf1['id']:
                assert device['services'] == services_cfg2['services']

        # clear
        services.delete()
        policy_map.delete()
        class_map1.delete()
        class_map2.delete()
    def runTest(self):
        class_map_cfg1 = (ClassMapCfg('classE').device(cfg.leaf0['id']).match(
            'vlan', 50).create())
        class_map_cfg2 = (ClassMapCfg('classF').device(cfg.leaf1['id']).match(
            'dscp', 60).create())

        class_map1 = ClassMap(class_map_cfg1)
        class_map1.create()
        class_map2 = ClassMap(class_map_cfg2)
        class_map2.create()

        policy_map_cfg1 = (PolicyMapCfg('policyE').device(
            cfg.leaf0['id']).class_map('classE').cos(2).flow(
                cir=1111000, bc=524288, conform="transmit",
                violate="drop").create())
        policy_map_cfg2 = (PolicyMapCfg('policyF').device(
            cfg.leaf1['id']).class_map('classF').cos(5).flow(
                cir=1660000, bc=114288, conform="transmit",
                violate="drop").create())

        policy_map_cfg_list = [policy_map_cfg1, policy_map_cfg2]

        policy_map = PolicyMap(policy_map_cfg_list, multiple=True)

        for device in policy_map.retrieve():
            assert device['policyMap'] == []

        policy_map.create()

        for device in policy_map.retrieve():
            if device['deviceId'] == cfg.leaf0['id']:
                assert device['policyMap'] == policy_map_cfg1['policyMap']
            elif device['deviceId'] == cfg.leaf1['id']:
                assert device['policyMap'] == policy_map_cfg2['policyMap']

        policy_map.delete()

        for device in policy_map.retrieve():
            assert device['policyMap'] == []

        # clear
        class_map1.delete()
        class_map2.delete()
    def runTest(self):
        class_map_cfg = (ClassMapCfg('classC').device(cfg.leaf0['id']).match(
            'cos', 2).create())

        class_map = ClassMap(class_map_cfg)
        class_map.create()

        policy_map_cfg = (
            PolicyMapCfg('policyC').class_map('classC').cos(6).flow(
                cir=2245000, bc=624288, conform="transmit",
                violate="drop").create())
        policy_map = PolicyMap(policy_map_cfg, cfg.leaf0['id'])

        assert policy_map.retrieve() == []
        policy_map.create()
        assert policy_map.retrieve() == policy_map_cfg['policyMap']
        policy_map.delete()
        assert policy_map.retrieve() == []
    def runTest(self):
        class_map_cfg = (ClassMapCfg('classB').device(cfg.leaf0['id']).match(
            'vlan', 20).create())

        class_map = ClassMap(class_map_cfg)
        class_map.create()

        policy_map_cfg = (
            PolicyMapCfg('policyB').class_map('classB').phb(2).flow(
                cir=1045000, bc=524288, conform="transmit",
                violate="drop").create())
        policy_map = PolicyMap(policy_map_cfg, cfg.leaf0['id'])

        assert policy_map.retrieve() == []
        policy_map.create()
        assert policy_map.retrieve() == policy_map_cfg['policyMap']

        # clear
        policy_map.delete()
        class_map.delete()
示例#10
0
    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()