- 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.
- @classmethod
- def create_interfaces_and_subinterfaces(cls, int_nr):
- ## A class list variable to store interface indexes.
- cls.interfaces = range(int_nr)
-
- # Create interfaces
- cls.create_interfaces(cls.interfaces)
-
- # Make vpp_api_test see interfaces created using debug CLI (in function
- # create_interfaces)
- cls.api("sw_interface_dump")
-
- ## A class dictionary variable to store data about interfaces.
- # First create an empty dictionary then store interface data there.
- cls.INT_DETAILS = dict()
-
- # 1st interface is untagged - no sub-interface required
- cls.INT_DETAILS[0] = cls.HardInt()
-
- # 2nd interface is dot1q tagged
- cls.INT_DETAILS[1] = cls.Dot1QSubint(TestL2bd.dot1q_sub_id,
- TestL2bd.dot1q_tag)
- cls.create_vlan_subif(1, cls.INT_DETAILS[1].vlan)
-
- # 3rd interface is dot1ad tagged
- # FIXME: Wrong packet format/wrong layer on output of interface 2
- #self.INT_DETAILS[2] = self.Dot1ADSubint(TestL2bd.dot1ad_sub_id, TestL2bd.dot1ad_outer_tag, TestL2bd.dot1ad_inner_tag)
- #self.create_dot1ad_subif(2, self.INT_DETAILS[2].sub_id, self.INT_DETAILS[2].outer_vlan, self.INT_DETAILS[2].inner_vlan)
-
- # Use dot1q for now.
- cls.INT_DETAILS[2] = cls.Dot1QSubint(TestL2bd.dot1ad_sub_id,
- TestL2bd.dot1ad_outer_tag)
- cls.create_vlan_subif(2, cls.INT_DETAILS[2].vlan)
-
- for i in cls.interfaces:
- if isinstance(cls.INT_DETAILS[i], cls.Subint):
- cls.api("sw_interface_set_flags pg%u.%u admin-up"
- % (i, cls.INT_DETAILS[i].sub_id))
- ## @var interfaces
- # List variable to store interface indexes.
- ## @var INT_DETAILS
- # Dictionary variable to store data about interfaces.
-
- ## Class method for bridge-domain to learn defined number of MAC addresses.
- # Create required number of host MAC addresses and distribute them among
- # interfaces. Create host IPv4 address for every host MAC address. Create
- # L2 MAC packet stream with host MAC addresses per interface to let
- # the bridge domain learn these MAC addresses.
- # @param cls The class pointer.
- # @param count Integer variable to store the number of MAC addresses to be
- # created.