Commit faaf1293 by tarokkk

adding docstring comments

parent 8b6b18e3
...@@ -21,6 +21,9 @@ class VMDriver: ...@@ -21,6 +21,9 @@ class VMDriver:
return new_function return new_function
def connect(self, connection_string='qemu:///system'): def connect(self, connection_string='qemu:///system'):
'''Connect to the libvirt daemon specified in the
connection_string or the local root.
'''
if self.connection is None: if self.connection is None:
self.connection = libvirt.open(connection_string) self.connection = libvirt.open(connection_string)
else: else:
...@@ -28,15 +31,22 @@ class VMDriver: ...@@ -28,15 +31,22 @@ class VMDriver:
@req_connection @req_connection
def disconnect(self, connection_string='qemu:///system'): def disconnect(self, connection_string='qemu:///system'):
'''Disconnect from the active libvirt daemon connection.
'''
self.connection.close() self.connection.close()
self.connection = None self.connection = None
@req_connection @req_connection
def vm_define(self, vm): def vm_define(self, vm):
'''Define permanent virtual machine from xml
'''
self.connection.defineXML(vm.dump_xml()) self.connection.defineXML(vm.dump_xml())
logging.info("Virtual machine %s is defined from xml", vm.name) logging.info("Virtual machine %s is defined from xml", vm.name)
@req_connection
def vm_create(self, vm): def vm_create(self, vm):
'''Create and start non-permanent virtual machine from xml
'''
self.connection.createXML(vm.dump_xml()) self.connection.createXML(vm.dump_xml())
logging.info("Virtual machine %s is created from xml", vm.name) logging.info("Virtual machine %s is created from xml", vm.name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment