Commit 51b12acb by Guba Sándor

refactoring vm to domain fixing vm_delete

parent 7f7756b3
...@@ -56,6 +56,13 @@ class VMDriver: ...@@ -56,6 +56,13 @@ class VMDriver:
logging.info("Virtual machine %s is created from xml", vm.name) logging.info("Virtual machine %s is created from xml", vm.name)
@req_connection @req_connection
def vm_delete(self, vm):
'''Destroy the running called 'name' virtual machine.
'''
domain = self.lookupByName(vm.name)
domain.destroy()
@req_connection
def list_domains(self): def list_domains(self):
return self.connection.listDefinedDomains() return self.connection.listDefinedDomains()
...@@ -73,9 +80,9 @@ class VMDriver: ...@@ -73,9 +80,9 @@ class VMDriver:
'''Undefine an already defined virtual machine. '''Undefine an already defined virtual machine.
If it's running it becomes transient (lsot on reboot) If it's running it becomes transient (lsot on reboot)
''' '''
vm = self.lookupByName(name) domain = self.lookupByName(name)
try: try:
vm.undefine() domain.undefine()
except: except:
logging.error('Can not get VM with name %s', name) logging.error('Can not get VM with name %s', name)
...@@ -83,31 +90,31 @@ class VMDriver: ...@@ -83,31 +90,31 @@ class VMDriver:
def vm_start(self, name): def vm_start(self, name):
'''Start an already defined virtual machine. '''Start an already defined virtual machine.
''' '''
vm = self.lookupByName(name) domain = self.lookupByName(name)
vm.create() domain.create()
@req_connection @req_connection
def vm_save(self, name, path): def vm_save(self, name, path):
'''Stop virtual machine and save its memory to path. '''Stop virtual machine and save its memory to path.
''' '''
vm = self.lookupByName(name) domain = self.lookupByName(name)
vm.save(path) domain.save(path)
def vm_resume(self, name): def vm_resume(self, name):
'''Resume stopped virtual machines. '''Resume stopped virtual machines.
''' '''
vm = self.lookupByName(name) domain = self.lookupByName(name)
vm.resume() domain.resume()
def vm_reset(self, name): def vm_reset(self, name):
'''Reset (power reset) virtual machine. '''Reset (power reset) virtual machine.
''' '''
vm = self.lookupByName(name) domain = self.lookupByName(name)
vm.reset() domain.reset()
def vm_reboot(self, name): def vm_reboot(self, name):
'''Reboot (with guest acpi support) virtual machine. '''Reboot (with guest acpi support) virtual machine.
''' '''
vm = self.lookupByName(name) domain = self.lookupByName(name)
vm.reboot() domain.reboot()
#virDomainResume #virDomainResume
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