+ path = ("interfaces",
+ ("interface", "name", super_interface),
+ "vpp-vlan:sub-interfaces",
+ ("sub-interface", "identifier", int(identifier)),
+ "l2")
+
+ return InterfaceKeywords._set_interface_properties(
+ node, super_interface, path, config)
+
+ @staticmethod
+ def get_bd_data_from_sub_interface(node, super_interface, identifier):
+ """Get the operational data about the bridge domain from sub-interface.
+
+ :param node: Honeycomb node.
+ :param super_interface: Super interface.
+ :param identifier: The ID of sub-interface.
+ :type node: dict
+ :type super_interface: str
+ :type identifier: int
+ :return: Operational data about the bridge domain.
+ :rtype: dict
+ :raises HoneycombError: If there is no sub-interface with the given ID.
+ """
+
+ try:
+ bd_data = InterfaceKeywords.get_sub_interface_oper_data(
+ node, super_interface, identifier)["l2"]
+ return bd_data
+ except KeyError:
+ raise HoneycombError("The operational data does not contain "
+ "information about a bridge domain.")
+
+ @staticmethod
+ def configure_tag_rewrite(node, super_interface, identifier, config):
+ """Add / change / disable vlan tag rewrite on a sub-interface.
+
+ :param node: Honeycomb node.
+ :param super_interface: Super interface.
+ :param identifier: The ID of sub-interface.
+ :param config: Rewrite tag configuration.
+ :type node: dict
+ :type super_interface: str
+ :type identifier: int
+ :type config: dict
+ :return: Content of response.
+ :rtype: bytearray
+ """
+
+ path = ("interfaces",
+ ("interface", "name", super_interface),
+ "vpp-vlan:sub-interfaces",
+ ("sub-interface", "identifier", int(identifier)),
+ "l2",
+ "rewrite")
+
+ return InterfaceKeywords._set_interface_properties(
+ node, super_interface, path, config)
+
+ @staticmethod
+ def get_tag_rewrite_oper_data(node, super_interface, identifier):
+ """Get the operational data about tag rewrite.
+
+ :param node: Honeycomb node.
+ :param super_interface: Super interface.
+ :param identifier: The ID of sub-interface.
+ :type node: dict
+ :type super_interface: str
+ :type identifier: int
+ :return: Operational data about tag rewrite.
+ :rtype: dict
+ :raises HoneycombError: If there is no sub-interface with the given ID.
+ """
+
+ try:
+ tag_rewrite = InterfaceKeywords.get_sub_interface_oper_data(
+ node, super_interface, identifier)["l2"]["rewrite"]
+ return tag_rewrite
+ except KeyError:
+ raise HoneycombError("The operational data does not contain "
+ "information about the tag-rewrite.")
+
+ @staticmethod
+ def compare_data_structures(data, ref):
+ """Checks if data obtained from UUT is as expected.
+
+ :param data: Data to be checked.
+ :param ref: Referential data used for comparison.
+ :type data: dict
+ :type ref: dict
+ :raises HoneycombError: If a parameter from referential data is not
+ present in operational data or if it has different value.
+ """
+
+ for key, item in ref.items():
+ try:
+ if data[key] != item:
+ raise HoneycombError("The value of parameter '{0}' is "
+ "incorrect. It should be "
+ "'{1}' but it is '{2}'".
+ format(key, item, data[key]))
+ except KeyError:
+ raise HoneycombError("The parameter '{0}' is not present in "
+ "operational data".format(key))
+
+ @staticmethod
+ def compare_interface_lists(list1, list2):
+ """Compare provided lists of interfaces by name.
+
+ :param list1: List of interfaces.
+ :param list2: List of interfaces.
+ :type list1: list
+ :type list2: list
+ :raises HoneycombError: If an interface exists in only one of the lists.
+ """
+
+ ignore = ["vx_tunnel0", "vxlan_gpe_tunnel0"]
+ # these have no equivalent in config data and no effect on VPP
+
+ names1 = [x['name'] for x in list1]
+ names2 = [x['name'] for x in list2]
+
+ for name in names1:
+ if name not in names2 and name not in ignore:
+ raise HoneycombError("Interface {0} not present in list {1}"
+ .format(name, list2))
+ for name in names2:
+ if name not in names1 and name not in ignore:
+ raise HoneycombError("Interface {0} not present in list {1}"
+ .format(name, list1))
+
+ @staticmethod
+ def create_vxlan_gpe_interface(node, interface, **kwargs):
+ """Create a new VxLAN GPE interface.
+
+ :param node: Honeycomb node.
+ :param interface: The name of interface to be created.
+ :param kwargs: Parameters and their values. The accepted parameters are
+ defined in InterfaceKeywords.VXLAN_GPE_PARAMS.
+ :type node: dict
+ :type interface: str
+ :type kwargs: dict
+ :return: Content of response.
+ :rtype: bytearray
+ :raises HoneycombError: If a parameter in kwargs is not valid.
+ """
+
+ new_vxlan_gpe = {
+ "name": interface,
+ "type": "v3po:vxlan-gpe-tunnel",
+ "v3po:vxlan-gpe": {}
+ }
+ for param, value in kwargs.items():
+ if param in InterfaceKeywords.INTF_PARAMS:
+ new_vxlan_gpe[param] = value
+ elif param in InterfaceKeywords.VXLAN_GPE_PARAMS:
+ new_vxlan_gpe["v3po:vxlan-gpe"][param] = value
+ else:
+ raise HoneycombError("The parameter {0} is invalid.".
+ format(param))
+ path = ("interfaces", "interface")
+ vxlan_gpe_structure = [new_vxlan_gpe, ]