]> git.ipfire.org Git - nitsi.git/blame - network.py
self.con is already the connection to the libvirt daemon
[nitsi.git] / network.py
CommitLineData
3ab701aa
JS
1#!/usr/bin/python3
2
3# # A class which define and undefine a virtual network based on an xml file
4class network():
7005787e 5 def __init__(self, libvirt_con, network_xml_file):
3ab701aa 6 self.log = log(4)
7005787e 7 self.con = libvirt_con
3ab701aa
JS
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):
8b744f18 15 self.network = self.con.networkDefineXML(self.network_xml)
3ab701aa
JS
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()