From 48d5fb0a72170dec8bf6bfa84f46c5e2a83210a3 Mon Sep 17 00:00:00 2001 From: Jonatan Schlag Date: Thu, 19 Apr 2018 13:03:28 +0200 Subject: [PATCH] Add network class Signed-off-by: Jonatan Schlag --- test.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index 064633f..3f6f540 100755 --- a/test.py +++ b/test.py @@ -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 -- 2.39.2