]> git.ipfire.org Git - people/ms/nitsi.git/commitdiff
Add all stuff to the test class
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Thu, 19 Apr 2018 11:13:07 +0000 (13:13 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Thu, 19 Apr 2018 11:13:07 +0000 (13:13 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
test.py

diff --git a/test.py b/test.py
index 8140aff86933aebc90dcb84ca6df08419a98e6d8..36b391b46c161cf05e4ade0eaa6b60a7ed40c6f1 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -469,16 +469,44 @@ class test():
         self.virtual_machines = self.virtual_environ.get_machines()
 
     def virtual_environ_start(self):
-        pass
+        for name in self.virtual_environ.network_names:
+            self.virtual_networks[name].define()
+            self.virtual_networks[name].start()
 
-    def load_recipe(self):
-        pass
+        for name in self.virtual_environ.machine_names:
+            self.virtual_machines[name].define()
+            self.virtual_machines[name].create_snapshot()
+            self.virtual_machines[name].start()
 
-    def run_recipe():
-        pass
+        self.log.debug("Try to login on all machines")
+        for name in self.virtual_environ.machine_names:
+            self.virtual_machines[name].login()
 
-    def virtual_environ_stop():
-        pass
+    def load_recipe(self):
+        try:
+            self.recipe = recipe(self.recipe_file)
+        except BaseException:
+            self.log.error("Failed to load recipe")
+            exit(1)
+
+    def run_recipe(self):
+        for line in self.recipe.recipe:
+            return_value = self.virtual_machines[line[0]].cmd(line[2])
+            if not return_value and line[1] == "":
+                self.log.error("Failed to execute command '{}' on {}".format(line[2],line[0]))
+                return False
+            elif return_value == True and line[1] == "!":
+                self.log.error("Succeded to execute command '{}' on {}".format(line[2],line[0]))
+                return False
+
+    def virtual_environ_stop(self):
+        for name in self.virtual_environ.machine_names:
+            self.virtual_machines[name].shutdown()
+            self.virtual_machines[name].revert_snapshot()
+            self.virtual_machines[name].undefine()
+
+        for name in self.virtual_environ.network_names:
+            self.virtual_networks[name].undefine()
 
 
 # Should return all vms and networks in a list