]> git.ipfire.org Git - nitsi.git/blobdiff - src/nitsi/virtual_environ.py
Raise exception instead of dropping them
[nitsi.git] / src / nitsi / virtual_environ.py
index 3dc86fdae9329f368d45cccdad1ca987ec022bd5..3f7493300728f2a59489ddff92d8b17ffcb8ff82 100644 (file)
@@ -1,13 +1,12 @@
 #!/usr/bin/python3
 
-from nitsi.machine import machine
-
-from nitsi.network import network
-
-import os
 import configparser
 import libvirt
 import logging
+import os
+
+from . import machine
+from . import network
 
 logger = logging.getLogger("nitsi.virtual_environ")
 
@@ -20,6 +19,7 @@ class virtual_environ():
             self.path = os.path.abspath(path)
         except BaseException as e:
             self.log.error("Could not get absolute path")
+            raise e
 
         self.log.debug(self.path)
 
@@ -54,6 +54,7 @@ class virtual_environ():
             self.con = libvirt.open(self.uri)
         except BaseException as error:
             self.log.error("Could not connect to: {}".format(self.uri))
+            raise error
 
         self.log.debug("Connected to: {}".format(self.uri))
 
@@ -61,14 +62,14 @@ class virtual_environ():
         networks = {}
         for _network in self.networks:
             self.log.debug(_network)
-            networks.setdefault(_network, network(self.con, os.path.normpath(self.path + "/" + self.config[_network]["xml_file"])))
+            networks.setdefault(_network, network.network(self.con, os.path.normpath(self.path + "/" + self.config[_network]["xml_file"])))
         return networks
 
     def get_machines(self):
         machines = {}
         for _machine in self.machines:
             self.log.debug(_machine)
-            machines.setdefault(_machine, machine(
+            machines.setdefault(_machine, machine.machine(
                 self.con,
                 os.path.normpath(self.path + "/" + self.config[_machine]["xml_file"]),
                 os.path.normpath(self.path + "/" + self.config[_machine]["snapshot_xml_file"]),
@@ -96,4 +97,4 @@ class virtual_environ():
                 if len(_machine) > self._longest_machine_name:
                     self._longest_machine_name = len(_machine)
 
-            return self._longest_machine_name
\ No newline at end of file
+            return self._longest_machine_name