Move recipe class into an own file
[nitsi.git] / network.py
1 #!/usr/bin/python3
2
3 # # A class which define and undefine a virtual network based on an xml file
4 class network():
5     def __init__(self, network_xml_file):
6         self.log = log(4)
7         self.con = libvirt_con("qemu:///system")
8         try:
9             with open(network_xml_file) as fobj:
10                 self.network_xml = fobj.read()
11         except FileNotFoundError as error:
12             self.log.error("No such file: {}".format(vm_xml_file))
13
14     def define(self):
15         self.network = self.con.con.networkDefineXML(self.network_xml)
16
17         if network == None:
18             self.log.error("Failed to define virtual network")
19
20     def start(self):
21         self.network.create()
22
23     def undefine(self):
24         self.network.destroy()