]> git.ipfire.org Git - nitsi.git/commitdiff
Move network class into an own file
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Fri, 27 Apr 2018 15:44:44 +0000 (17:44 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Fri, 27 Apr 2018 15:44:44 +0000 (17:44 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
network.py [new file with mode: 0644]
test.py

diff --git a/network.py b/network.py
new file mode 100644 (file)
index 0000000..223930b
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/python3
+
+# # A class which define and undefine a virtual network based on an xml file
+class network():
+    def __init__(self, network_xml_file):
+        self.log = log(4)
+        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()
\ No newline at end of file
diff --git a/test.py b/test.py
index a3d6a0dca10db9b0fa0562810a8f2c1f2ef36c7b..1ec64f842c99a80ea42d725fcf502bd945ecf30d 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -48,31 +48,6 @@ class libvirt_con():
 
 
 
 
 
 
-# A class which define and undefine a virtual network based on an xml file
-class network():
-    def __init__(self, network_xml_file):
-        self.log = log(4)
-        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()
-
-
-
 class RecipeExeption(Exception):
     pass
 
 class RecipeExeption(Exception):
     pass