]> git.ipfire.org Git - nitsi.git/blobdiff - test.py
Add network class
[nitsi.git] / test.py
diff --git a/test.py b/test.py
index d2a6d97907e32e7516087d4edaf55f8185567da5..3f6f54079b3f4a59afc5af5249f8d7dbacbb37d0 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -109,7 +109,7 @@ class vm():
     def revert_snapshot(self):
         print(inspect.getmembers(self.dom, predicate=inspect.ismethod))
         self.dom.revertToSnapshot(self.snapshot)
-        #self.dom.SnapshotDelete(self.snapshot)
+        self.snapshot.delete()
 
     def is_running(self):
 
@@ -353,9 +353,28 @@ class connection():
 
 # A class which define and undefine a virtual network based on an xml file
 class network():
-    def __init__(self, path):
+    def __init__(self, network_xml_file):
         self.log = log(4)
-        self.log.debug("Path is: {}".format(path))
+        self.con = libvirt_con("qemu:///system")
+        try:
+            with open(network_xml_file) as fobj:
+                self.network_xml = fobj.read()
+        except FileNotFoundError as error:
+            self.log.error("No such file: {}".format(vm_xml_file))
+
+    def define(self):
+        self.network = self.con.con.networkDefineXML(self.network_xml)
+
+        if network == None:
+            self.log.error("Failed to define virtual network")
+
+    def start(self):
+        self.network.create()
+
+    def undefine(self):
+        self.network.destroy()
+
+
 
 # Should read the test, check if the syntax are valid
 # and return tuples with the ( host, command ) structure