Use one time to which all serial connection output is relativ
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 9 May 2018 07:58:51 +0000 (09:58 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 9 May 2018 07:58:51 +0000 (09:58 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
src/nitsi/machine.py
src/nitsi/serial_connection.py
src/nitsi/test.py

index d0170a0..230e855 100644 (file)
@@ -117,9 +117,13 @@ class machine():
 
         #serial_con.close()
 
-    def login(self, log_file):
+    def login(self, log_file, log_start_time=None):
         try:
-            self.serial_con = serial_connection(self.get_serial_device(), username=self.username, log_file=log_file, name=self.name)
+            self.serial_con = serial_connection(self.get_serial_device(),
+                                username=self.username,
+                                log_file=log_file,
+                                log_start_time=log_start_time,
+                                name=self.name)
             self.serial_con.login(self.password)
         except BaseException as e:
             self.log.error("Could not connect to the domain via serial console")
index 6328e4f..5e60be3 100644 (file)
@@ -13,7 +13,7 @@ from nitsi.logger import TestFormatter
 logger = logging.getLogger("nitsi.serial")
 
 class serial_connection():
-    def __init__(self, device, username=None, log_file=None, name=None):
+    def __init__(self, device, username=None, log_file=None, name=None, log_start_time=None):
         self.buffer = b""
         self.back_at_prompt_pattern =  None
         self.username = username
@@ -27,7 +27,7 @@ class serial_connection():
         log_file_handler = logging.FileHandler(self.log_file)
         log_file_handler.setLevel(logging.INFO)
         log_file_handler.terminator = ""
-        formatter = TestFormatter(name=self.name, start_time=None)
+        formatter = TestFormatter(name=self.name, start_time=log_start_time)
         log_file_handler.setFormatter(formatter)
         self.log_output.addHandler(log_file_handler)
 
index 96ce841..413518e 100755 (executable)
@@ -7,6 +7,8 @@ import os
 
 import configparser
 
+import time
+
 from nitsi.virtual_environ import virtual_environ
 from nitsi.recipe import recipe
 
@@ -73,10 +75,13 @@ class test():
             self.virtual_machines[name].copy_in(self.copy_from, self.copy_to)
             self.virtual_machines[name].start()
 
+        # Time to which all serial output log entries are relativ
+        log_start_time = time.time()
+
         self.log.debug("Try to login on all machines")
         for name in self.virtual_environ.machine_names:
             self.log.debug("Try to login on {}".format(name))
-            self.virtual_machines[name].login("{}/test.log".format(self.log_path))
+            self.virtual_machines[name].login("{}/test.log".format(self.log_path), log_start_time)
 
     def load_recipe(self):
         self.log.info("Going to load the recipe")