FIX: Add VatHistory for VATscript files.
[csit.git] / resources / libraries / python / VatExecutor.py
index d27e067..8b9d632 100644 (file)
@@ -106,6 +106,9 @@ class VatExecutor(object):
         if copy_on_execute:
             ssh.scp(vat_name, vat_name)
             remote_file_path = vat_name
+            with open(vat_name, 'r') as vat_file:
+                for line in vat_file:
+                    VatHistory.add_to_vat_history(node, line.replace('\n', ''))
         else:
             remote_file_path = '{0}/{1}/{2}'.format(Constants.REMOTE_FW_DIR,
                                                     Constants.RESOURCES_TPL_VAT,
@@ -201,10 +204,9 @@ class VatTerminal(object):
     """
 
     __VAT_PROMPT = ("vat# ", )
-    __LINUX_PROMPT = (":~$ ", "~]$ ", "~]# ")
+    __LINUX_PROMPT = (":~# ", ":~$ ", "~]$ ", "~]# ")
 
     def __init__(self, node, json_param=True):
-        """TODO: Should we document this constructor can raise RuntimeError?"""
         json_text = ' json' if json_param else ''
         self.json = json_param
         self._node = node
@@ -212,7 +214,7 @@ class VatTerminal(object):
         self._ssh.connect(self._node)
         try:
             self._tty = self._ssh.interactive_terminal_open()
-        except IOError:
+        except Exception:
             raise RuntimeError("Cannot open interactive terminal on node {0}".
                                format(self._node))
 
@@ -222,7 +224,7 @@ class VatTerminal(object):
                     self._tty,
                     'sudo -S {0}{1}'.format(Constants.VAT_BIN_NAME, json_text),
                     self.__VAT_PROMPT)
-            except IOError:
+            except Exception:
                 continue
             else:
                 break
@@ -254,9 +256,9 @@ class VatTerminal(object):
         """Execute command on the opened VAT terminal.
 
         :param cmd: Command to be executed.
+
         :returns: Command output in python representation of JSON format or
             None if not in JSON mode.
-        :raise RuntimeError: If VAT command execution fails.
         """
         VatHistory.add_to_vat_history(self._node, cmd)
         logger.debug("Executing command in VAT terminal: {0}".format(cmd))
@@ -264,7 +266,7 @@ class VatTerminal(object):
             out = self._ssh.interactive_terminal_exec_command(self._tty, cmd,
                                                               self.__VAT_PROMPT)
             self.vat_stdout = out
-        except IOError:
+        except Exception:
             self._exec_failure = True
             vpp_pid = get_vpp_pid(self._node)
             if vpp_pid: