def setUp()

in ptf/saimpls.py [0:0]


    def setUp(self):
        super(MplsIpv6TtlModeTest, self).setUp()

        ttl_value = 63
        exp_value = 5
        ipv6_1 = '100::1'
        ipv6_2 = '100::2'
        ipv6_3 = '100::3'
        ipv6_4 = '220::1'
        ipv6_5 = '330::1'
        ipv6_10 = '800::1'

        ipv6_subnet_1 = '110::1/128'
        ipv6_subnet_2 = '120::1/128'
        ipv6_subnet_3 = '130::1/128'
        ipv6_subnet_4 = '200::1/128'
        dmac = '00:11:22:33:44:55'

        # Ingress LER config
        self.ingress_rif = self.port10_rif
        self.egress_rif_1 = self.port11_rif

        label_list = [1000]
        label_list_t = sai_thrift_u32_list_t(
            count=len(label_list),
            uint32list=label_list)

        self.nhop_label_1 = sai_thrift_create_next_hop(
            self.client,
            ip=sai_ipaddress(ipv6_1),
            router_interface_id=self.egress_rif_1,
            type=SAI_NEXT_HOP_TYPE_MPLS,
            labelstack=label_list_t,
            outseg_ttl_mode=SAI_OUTSEG_TTL_MODE_UNIFORM,
            outseg_ttl_value=ttl_value,
            outseg_exp_value=exp_value,
            outseg_type=SAI_OUTSEG_TYPE_PUSH)

        label_list.append(2000)
        label_list_t = sai_thrift_u32_list_t(
            count=len(label_list),
            uint32list=label_list)

        self.nhop_label_2 = sai_thrift_create_next_hop(
            self.client,
            ip=sai_ipaddress(ipv6_2),
            router_interface_id=self.egress_rif_1,
            type=SAI_NEXT_HOP_TYPE_MPLS,
            labelstack=label_list_t,
            outseg_ttl_mode=SAI_OUTSEG_TTL_MODE_UNIFORM,
            outseg_ttl_value=ttl_value,
            outseg_exp_value=exp_value,
            outseg_type=SAI_OUTSEG_TYPE_PUSH)

        label_list.append(3000)
        label_list_t = sai_thrift_u32_list_t(
            count=len(label_list),
            uint32list=label_list)

        self.nhop_label_3 = sai_thrift_create_next_hop(
            self.client,
            ip=sai_ipaddress(ipv6_3),
            router_interface_id=self.egress_rif_1,
            type=SAI_NEXT_HOP_TYPE_MPLS,
            labelstack=label_list_t,
            outseg_ttl_mode=SAI_OUTSEG_TTL_MODE_UNIFORM,
            outseg_ttl_value=ttl_value,
            outseg_exp_value=exp_value,
            outseg_type=SAI_OUTSEG_TYPE_PUSH)

        # note: neighbor with the same dst_ip as MPLS nexthop has to be created
        # after MPLS nexthop is created,
        # if not it will create second nexthop of type IP with this dst_ip
        # and neither of them will be functioning correctly - packets
        # will be gleaned to CPU
        self.mpls_neighbor_entry_1 = sai_thrift_neighbor_entry_t(
            rif_id=self.egress_rif_1, ip_address=sai_ipaddress(ipv6_1))
        status = sai_thrift_create_neighbor_entry(
            self.client, self.mpls_neighbor_entry_1, dst_mac_address=dmac,
            no_host_route=True)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.mpls_neighbor_entry_2 = sai_thrift_neighbor_entry_t(
            rif_id=self.egress_rif_1, ip_address=sai_ipaddress(ipv6_2))
        status = sai_thrift_create_neighbor_entry(
            self.client, self.mpls_neighbor_entry_2, dst_mac_address=dmac,
            no_host_route=True)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.mpls_neighbor_entry_3 = sai_thrift_neighbor_entry_t(
            rif_id=self.egress_rif_1, ip_address=sai_ipaddress(ipv6_3))
        status = sai_thrift_create_neighbor_entry(
            self.client, self.mpls_neighbor_entry_3, dst_mac_address=dmac,
            no_host_route=True)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.mpls_encap_route_1 = sai_thrift_route_entry_t(
            vr_id=self.default_vrf, destination=sai_ipprefix(ipv6_subnet_1))
        sai_thrift_create_route_entry(
            self.client, self.mpls_encap_route_1,
            next_hop_id=self.nhop_label_1)

        self.mpls_encap_route_2 = sai_thrift_route_entry_t(
            vr_id=self.default_vrf, destination=sai_ipprefix(ipv6_subnet_2))
        sai_thrift_create_route_entry(
            self.client, self.mpls_encap_route_2,
            next_hop_id=self.nhop_label_2)

        self.mpls_encap_route_3 = sai_thrift_route_entry_t(
            vr_id=self.default_vrf, destination=sai_ipprefix(ipv6_subnet_3))
        sai_thrift_create_route_entry(
            self.client, self.mpls_encap_route_3,
            next_hop_id=self.nhop_label_3)

        # MPLS egress LER term config
        self.egress_rif_2 = self.port12_rif

        self.mpls_rif = sai_thrift_create_router_interface(
            self.client,
            type=SAI_ROUTER_INTERFACE_TYPE_MPLS_ROUTER,
            virtual_router_id=self.default_vrf)

        self.nhop_1 = sai_thrift_create_next_hop(
            self.client,
            ip=sai_ipaddress(ipv6_4),
            router_interface_id=self.egress_rif_2,
            type=SAI_NEXT_HOP_TYPE_IP)
        self.neighbor_entry_1 = sai_thrift_neighbor_entry_t(
            rif_id=self.egress_rif_2, ip_address=sai_ipaddress(ipv6_4))
        sai_thrift_create_neighbor_entry(
            self.client, self.neighbor_entry_1, dst_mac_address=dmac,
            no_host_route=True)
        self.route_entry_1 = sai_thrift_route_entry_t(
            vr_id=self.default_vrf, destination=sai_ipprefix(ipv6_subnet_4))
        sai_thrift_create_route_entry(
            self.client, self.route_entry_1, next_hop_id=self.nhop_1)

        self.inseg_entry_1000 = sai_thrift_inseg_entry_t(label=1000)
        status = sai_thrift_create_inseg_entry(
            self.client, self.inseg_entry_1000,
            num_of_pop=1,
            pop_ttl_mode=SAI_INSEG_ENTRY_POP_TTL_MODE_UNIFORM,
            next_hop_id=self.mpls_rif)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        # MPLS Egress LER Null Term configs
        self.inseg_entry_0 = sai_thrift_inseg_entry_t(label=0)
        status = sai_thrift_create_inseg_entry(
            self.client, self.inseg_entry_0,
            num_of_pop=1,
            pop_ttl_mode=SAI_INSEG_ENTRY_POP_TTL_MODE_UNIFORM,
            next_hop_id=self.mpls_rif)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        # MPLS Egress PHP configs
        self.egress_rif_3 = self.port13_rif

        self.nhop_2 = sai_thrift_create_next_hop(
            self.client,
            ip=sai_ipaddress(ipv6_4),
            router_interface_id=self.egress_rif_3,
            type=SAI_NEXT_HOP_TYPE_IP)

        self.neighbor_entry_2 = sai_thrift_neighbor_entry_t(
            rif_id=self.egress_rif_3, ip_address=sai_ipaddress(ipv6_4))
        status = sai_thrift_create_neighbor_entry(
            self.client, self.neighbor_entry_2, dst_mac_address=dmac,
            no_host_route=True)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.inseg_entry_2000 = sai_thrift_inseg_entry_t(label=2000)
        status = sai_thrift_create_inseg_entry(
            self.client, self.inseg_entry_2000,
            num_of_pop=1,
            pop_ttl_mode=SAI_INSEG_ENTRY_POP_TTL_MODE_UNIFORM,
            next_hop_id=self.nhop_2)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.inseg_entry_2111 = sai_thrift_inseg_entry_t(label=2111)
        status = sai_thrift_create_inseg_entry(
            self.client, self.inseg_entry_2111,
            num_of_pop=2,
            pop_ttl_mode=SAI_INSEG_ENTRY_POP_TTL_MODE_UNIFORM,
            next_hop_id=self.nhop_2)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.inseg_entry_2222 = sai_thrift_inseg_entry_t(label=2222)
        status = sai_thrift_create_inseg_entry(
            self.client, self.inseg_entry_2222,
            num_of_pop=3,
            pop_ttl_mode=SAI_INSEG_ENTRY_POP_TTL_MODE_UNIFORM,
            next_hop_id=self.nhop_2)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        # MPLS Egress PHP Swap Null configs
        self.egress_rif_4 = sai_thrift_create_router_interface(
            self.client,
            type=SAI_ROUTER_INTERFACE_TYPE_PORT,
            port_id=self.port25,
            virtual_router_id=self.default_vrf)

        label_list = [0]
        label_list_t = sai_thrift_u32_list_t(
            count=len(label_list),
            uint32list=label_list)

        self.nhop_label_4 = sai_thrift_create_next_hop(
            self.client,
            ip=sai_ipaddress(ipv6_5),
            router_interface_id=self.egress_rif_4,
            type=SAI_NEXT_HOP_TYPE_MPLS,
            labelstack=label_list_t,
            outseg_ttl_mode=SAI_OUTSEG_TTL_MODE_UNIFORM,
            outseg_ttl_value=ttl_value,
            outseg_type=SAI_OUTSEG_TYPE_SWAP)

        self.mpls_neighbor_entry_4 = sai_thrift_neighbor_entry_t(
            rif_id=self.egress_rif_4, ip_address=sai_ipaddress(ipv6_5))
        status = sai_thrift_create_neighbor_entry(
            self.client, self.mpls_neighbor_entry_4, dst_mac_address=dmac,
            no_host_route=True)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.inseg_entry_3000 = sai_thrift_inseg_entry_t(label=3000)
        status = sai_thrift_create_inseg_entry(
            self.client, self.inseg_entry_3000,
            next_hop_id=self.nhop_label_4)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        # MPLS Transit Push configs
        self.egress_rif_9 = sai_thrift_create_router_interface(
            self.client,
            type=SAI_ROUTER_INTERFACE_TYPE_PORT,
            port_id=self.port30,
            virtual_router_id=self.default_vrf)

        label_list = [9000]
        label_list_t = sai_thrift_u32_list_t(
            count=len(label_list),
            uint32list=label_list)

        self.nhop_label_9 = sai_thrift_create_next_hop(
            self.client,
            ip=sai_ipaddress(ipv6_10),
            router_interface_id=self.egress_rif_9,
            type=SAI_NEXT_HOP_TYPE_MPLS,
            labelstack=label_list_t,
            outseg_ttl_mode=SAI_OUTSEG_TTL_MODE_UNIFORM,
            outseg_ttl_value=ttl_value,
            outseg_exp_value=exp_value,
            outseg_type=SAI_OUTSEG_TYPE_PUSH)

        self.mpls_neighbor_entry_9 = sai_thrift_neighbor_entry_t(
            rif_id=self.egress_rif_9, ip_address=sai_ipaddress(ipv6_10))
        status = sai_thrift_create_neighbor_entry(
            self.client, self.mpls_neighbor_entry_9, dst_mac_address=dmac,
            no_host_route=True)
        self.assertEqual(status, SAI_STATUS_SUCCESS)

        self.inseg_entry_8000 = sai_thrift_inseg_entry_t(label=8000)
        status = sai_thrift_create_inseg_entry(
            self.client, self.inseg_entry_8000,
            next_hop_id=self.nhop_label_9)
        self.assertEqual(status, SAI_STATUS_SUCCESS)