- if isinstance(cls.INT_DETAILS[i], cls.Subint):
- interface = "pg%u.%u" % (i, cls.INT_DETAILS[i].sub_id)
- else:
- interface = "pg%u" % i
- cls.api("sw_interface_set_l2_bridge %s bd_id %u"
- % (interface, TestL2bd.bd_id))
-
- ## Make the BD learn a number of MAC entries specified by the test
- # variable <mac_entries>.
- cls.create_mac_entries(TestL2bd.mac_entries)
- cls.cli(0, "show l2fib")
-
- except Exception as e:
- super(TestL2bd, cls).tearDownClass()
- raise e
-
- ## Method to define tear down VPP actions of the test case.
- # Overrides tearDown method in VppTestCase class.
- # @param self The object pointer.
- def tearDown(self):
- self.cli(2, "show int")
- self.cli(2, "show trace")
- self.cli(2, "show hardware")
- self.cli(2, "show l2fib verbose")
- self.cli(2, "show error")
- self.cli(2, "show run")
- self.cli(2, "show bridge-domain 1 detail")
-
- ## Class method to create VLAN sub-interface.
- # Uses VPP API command to create VLAN sub-interface.
- # @param cls The class pointer.
- # @param pg_index Integer variable to store the index of the packet
- # generator interface to create VLAN sub-interface on.
- # @param vlan_id Integer variable to store required VLAN tag value.
- @classmethod
- def create_vlan_subif(cls, pg_index, vlan_id):
- cls.api("create_vlan_subif pg%u vlan %u" % (pg_index, vlan_id))
-
- ## Class method to create dot1ad sub-interface.
- # Use VPP API command to create dot1ad sub-interface.
- # @param cls The class pointer.
- # @param pg_index Integer variable to store the index of the packet
- # generator interface to create dot1ad sub-interface on.
- # @param outer_vlan_id Integer variable to store required outer VLAN tag
- # value (S-TAG).
- # @param inner_vlan_id Integer variable to store required inner VLAN tag
- # value (C-TAG).
- @classmethod
- def create_dot1ad_subif(cls, pg_index, sub_id, outer_vlan_id,
- inner_vlan_id):
- cls.api("create_subif pg%u sub_id %u outer_vlan_id %u inner_vlan_id"
- " %u dot1ad" % (pg_index, sub_id, outer_vlan_id, inner_vlan_id))
-
- ## Base class for interface.
- # To define object representation of the interface.
- class Interface(object):
- pass
-
- ## Sub-class of the interface class.
- # To define object representation of the HW interface.
- class HardInt(Interface):
- pass
-
- ## Sub-class of the interface class.
- # To define object representation of the SW interface.
- class SoftInt(Interface):
- pass
-
- ## Sub-class of the SW interface class.
- # To represent the general sub-interface.
- class Subint(SoftInt):
- ## The constructor.
- # @param sub_id Integer variable to store sub-interface ID.
- def __init__(self, sub_id):
- self.sub_id = sub_id
-
- ## Sub-class of the SW interface class.
- # To represent dot1q sub-interface.
- class Dot1QSubint(Subint):
- ## The constructor.
- # @param sub_id Integer variable to store sub-interface ID.
- # @param vlan Integer variable (optional) to store VLAN tag value. Set
- # to sub_id value when VLAN tag value not provided.
- def __init__(self, sub_id, vlan=None):
- if vlan is None:
- vlan = sub_id
- super(TestL2bd.Dot1QSubint, self).__init__(sub_id)
- self.vlan = vlan
-
- ## Sub-class of the SW interface class.
- # To represent dot1ad sub-interface.
- class Dot1ADSubint(Subint):
- ## The constructor.
- # @param sub_id Integer variable to store sub-interface ID.
- # @param outer_vlan Integer variable to store outer VLAN tag value.
- # @param inner_vlan Integer variable to store inner VLAN tag value.
- def __init__(self, sub_id, outer_vlan, inner_vlan):
- super(TestL2bd.Dot1ADSubint, self).__init__(sub_id)
- self.outer_vlan = outer_vlan
- self.inner_vlan = inner_vlan
-
- ## Class method to create interfaces and sub-interfaces.
- # Current implementation: create three interfaces, then create Dot1Q
- # sub-interfaces for the second and the third interface with VLAN tags
- # equal to their sub-interface IDs. Set sub-interfaces status to admin-up.
- # @param cls The class pointer.
- # @param int_nr Integer variable to store the number of interfaces to be
- # created.
- # TODO: Parametrize required numbers of dot1q and dot1ad to be created.