Add vpp_create_loopback 10/910/3
authorMatus Fabian <matfabia@cisco.com>
Thu, 28 Apr 2016 12:41:32 +0000 (14:41 +0200)
committerStefan Kobza <skobza@cisco.com>
Mon, 2 May 2016 07:44:15 +0000 (07:44 +0000)
Change-Id: If934d7ec28f86b070a0cafa0ee56d0bcf4e2ac6d
Signed-off-by: Matus Fabian <matfabia@cisco.com>
resources/libraries/python/InterfaceUtil.py
resources/templates/vat/create_loopback.vat [new file with mode: 0644]

index a5f00ad..021e8ed 100644 (file)
@@ -507,3 +507,19 @@ class InterfaceUtil(object):
             vat.vat_terminal_exec_cmd('exec show interfaces')
 
         return '{}.{}'.format(interface, sub_id), sw_subif_index
+
+    @staticmethod
+    def vpp_create_loopback(node):
+        """Create loopback interface on VPP node.
+
+        :param node: Node to create loopback interface on.
+        :type node: dict
+        :return: SW interface index.
+        :rtype: int
+        """
+        out = VatExecutor.cmd_from_template(node, "create_loopback.vat")
+        if out[0].get('retval') == 0:
+            return out[0].get('sw_if_index')
+        else:
+            raise RuntimeError('Create loopback failed on node "{}"'
+                               .format(node['host']))
diff --git a/resources/templates/vat/create_loopback.vat b/resources/templates/vat/create_loopback.vat
new file mode 100644 (file)
index 0000000..94cfc0d
--- /dev/null
@@ -0,0 +1 @@
+create_loopback