]> git.ipfire.org Git - nitsi.git/commitdiff
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 d0170a0cc3e7f2107da1c0921f5d951610b22aad..230e8558bc3cdd8e78d2af1719ed15fc795bbed1 100644 (file)
@@ -117,9 +117,13 @@ class machine():
 
         #serial_con.close()
 
 
         #serial_con.close()
 
-    def login(self, log_file):
+    def login(self, log_file, log_start_time=None):
         try:
         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")
             self.serial_con.login(self.password)
         except BaseException as e:
             self.log.error("Could not connect to the domain via serial console")
index 6328e4f143b2c22353bbc3717d56adb499a0728d..5e60be3bfc0ffef75a8e66ad4f37a61cd4f78789 100644 (file)
@@ -13,7 +13,7 @@ from nitsi.logger import TestFormatter
 logger = logging.getLogger("nitsi.serial")
 
 class serial_connection():
 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
         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 = ""
         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)
 
         log_file_handler.setFormatter(formatter)
         self.log_output.addHandler(log_file_handler)
 
index 96ce841083b01a965d8ecc2b3b9f79be4414b7df..413518e72c68e1d8444ac5a568f3d26af7e62f17 100755 (executable)
@@ -7,6 +7,8 @@ import os
 
 import configparser
 
 
 import configparser
 
+import time
+
 from nitsi.virtual_environ import virtual_environ
 from nitsi.recipe import recipe
 
 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()
 
             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.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")
 
     def load_recipe(self):
         self.log.info("Going to load the recipe")