aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorPatrik Hrnciar <phrnciar@cisco.com>2016-04-04 13:09:09 +0200
committerStefan Kobza <skobza@cisco.com>2016-04-26 09:57:13 +0000
commitd407c074289e530f62db02ca57c0af921af069cc (patch)
treedd96e450dcc220011cb36625a4c02e5553d89fa3 /resources/libraries/python
parent9cd535ec0701d5ba87a781d361b08eb0a0446789 (diff)
Add qinq through xconnect tests.
Change-Id: Ia20f5959dab41290bf60490ead830f0e37ecff0d Signed-off-by: Patrik Hrnciar <phrnciar@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/InterfaceUtil.py46
-rw-r--r--resources/libraries/python/L2Util.py23
2 files changed, 69 insertions, 0 deletions
diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py
index bf1ba1e8aa..a5f00ad03e 100644
--- a/resources/libraries/python/InterfaceUtil.py
+++ b/resources/libraries/python/InterfaceUtil.py
@@ -461,3 +461,49 @@ class InterfaceUtil(object):
else:
raise RuntimeError('Unable to create VXLAN interface on node {}'
.format(node))
+
+ @staticmethod
+ def create_subinterface(node, interface, sub_id, outer_vlan_id,
+ inner_vlan_id, type_subif):
+ """Create sub-interface on node.
+
+ :param node: Node to add sub-interface.
+ :param interface: Interface name on which create sub-interface.
+ :param sub_id: ID of the sub-interface to be created.
+ :param outer_vlan_id: Outer VLAN ID.
+ :param inner_vlan_id: Inner VLAN ID.
+ :param type_subif: Type of sub-interface.
+ :type node: dict
+ :type interface: str or int
+ :type sub_id: int
+ :type outer_vlan_id: int
+ :type inner_vlan_id: int
+ :type type_subif: str
+ :return: name and index of created sub-interface
+ :rtype: tuple
+ """
+
+ if isinstance(interface, basestring):
+ sw_if_index = Topology.get_interface_sw_index(node, interface)
+ else:
+ sw_if_index = interface
+
+ output = VatExecutor.cmd_from_template(node, "create_sub_interface.vat",
+ sw_if_index=sw_if_index,
+ sub_id=sub_id,
+ outer_vlan_id=outer_vlan_id,
+ inner_vlan_id=inner_vlan_id,
+ type_subif=type_subif)
+
+ if output[0]["retval"] == 0:
+ sw_subif_index = output[0]["sw_if_index"]
+ logger.trace('Created subinterface with index {}'
+ .format(sw_subif_index))
+ else:
+ raise RuntimeError('Unable to create subinterface on node {}'
+ .format(node['host']))
+
+ with VatTerminal(node) as vat:
+ vat.vat_terminal_exec_cmd('exec show interfaces')
+
+ return '{}.{}'.format(interface, sub_id), sw_subif_index
diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py
index e0824598b4..5903d03549 100644
--- a/resources/libraries/python/L2Util.py
+++ b/resources/libraries/python/L2Util.py
@@ -248,3 +248,26 @@ class L2Util(object):
return bridge_domain
return data
+
+ @staticmethod
+ def l2_tag_rewrite(node, interface, tag_rewrite_method):
+ """Rewrite tags in frame.
+
+ :param node: Node to rewrite tags.
+ :param interface: Interface on which rewrite tags.
+ :param tag_rewrite_method: Method of tag rewrite.
+ :type node: dict
+ :type interface: str or int
+ :type tag_rewrite_method : str
+ """
+
+ if isinstance(interface, basestring):
+ sw_if_index = Topology.get_interface_sw_index(node, interface)
+ else:
+ sw_if_index = interface
+
+ with VatTerminal(node) as vat:
+ vat.vat_terminal_exec_cmd_from_template("l2_tag_rewrite.vat",
+ sw_if_index=sw_if_index,
+ tag_rewrite_method=
+ tag_rewrite_method)