add new topology parameter: arch
[csit.git] / resources / libraries / python / VPPUtil.py
index 32e1bb4..5881d18 100644 (file)
@@ -26,7 +26,7 @@ class VPPUtil(object):
 
         :param node: VPP node.
         :param additional_cmds: Additional commands that the vpp should print
-         settings for.
+        settings for.
         :type node: dict
         :type additional_cmds: tuple
         """
@@ -44,9 +44,37 @@ class VPPUtil(object):
                 def_setting_tb_displayed['Custom Setting: {}'.format(cmd)] = cmd
         ssh = SSH()
         ssh.connect(node)
-        print("=" * 40)
-        for key, value in def_setting_tb_displayed.iteritems():
-            (_, stdout, _) = ssh.exec_command_sudo('vppctl sh {}'.format(value))
-            print("{} : {} \n".format(key, value))
-            print(stdout)
-            print("=" * 40)
+        for _, value in def_setting_tb_displayed.items():
+            ssh.exec_command_sudo('vppctl sh {}'.format(value))
+
+    @staticmethod
+    def stop_vpp_service(node):
+        """Stop VPP service on the specified node.
+
+        :param node: VPP node.
+        :type node: dict
+        :raises RuntimeError: If VPP fails to stop.
+        """
+
+        ssh = SSH()
+        ssh.connect(node)
+        cmd = "service vpp stop"
+        ret_code, _, _ = ssh.exec_command_sudo(cmd, timeout=80)
+        if int(ret_code) != 0:
+            raise RuntimeError("VPP service did not shut down gracefully.")
+
+    @staticmethod
+    def start_vpp_service(node):
+        """start VPP service on the specified node.
+
+        :param node: VPP node.
+        :type node: dict
+        :raises RuntimeError: If VPP fails to start.
+        """
+
+        ssh = SSH()
+        ssh.connect(node)
+        cmd = "service vpp start"
+        ret_code, _, _ = ssh.exec_command_sudo(cmd)
+        if int(ret_code) != 0:
+            raise RuntimeError("VPP service did not start.")