Commit 0b1ba886 authored by Antoine Millet's avatar Antoine Millet

Implemented vm_rescue and vm_unrescue VM handlers

parent 84e101ff
......@@ -111,6 +111,8 @@ class NodeConfigParser(object):
# Path to define script
default_define_script = 'hkvm-define'
self.define_script = config.get('node', 'define_script', default_define_script)
default_rescue_script = 'hkvm-rescue'
self.rescue_script = config.get('node', 'rescue_script', default_rescue_script)
# RPC handler ACLs
acl_section_name = 'node_handler'
......
......@@ -246,6 +246,30 @@ class Handler(HostHandler):
return vm.lv_dom.XMLDesc(0)
@libvirt_handler
def vm_rescue(self, name):
logger.debug('VM rescue %s', name)
if name in self.hypervisor.domains:
rcode, output = execute(self.main, [self.main.config.rescue_script, '-r', name])
if rcode != 0:
raise RuntimeError(output.strip().split('\n')[-1].strip())
else:
msg = 'Cannot rescue VM %s because it is not defined' % name
logger.error(msg)
raise UndefinedDomain(msg)
@libvirt_handler
def vm_unrescue(self, name):
logger.debug('VM unrescue %s', name)
if name in self.hypervisor.domains:
rcode, output = execute(self.main, [self.main.config.rescue_script, '-u', name])
if rcode != 0:
raise RuntimeError(output.strip().split('\n')[-1].strip())
else:
msg = 'Cannot unrescue VM %s because it is not defined' % name
logger.error(msg)
raise UndefinedDomain(msg)
@libvirt_handler
def vm_stop(self, name):
logger.debug('VM stop %s', 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 to comment