Commit 5335f5f4 authored by Antoine Millet's avatar Antoine Millet

Implemented vm_set_vlans VM handler

parent a66e7c1b
......@@ -113,6 +113,8 @@ class NodeConfigParser(object):
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)
default_vlan_script = 'hkvm-vlan'
self.vlan_script = config.get('node', 'vlan_script', default_vlan_script)
# RPC handler ACLs
acl_section_name = 'node_handler'
......
......@@ -256,6 +256,24 @@ class Handler(HostHandler):
logger.error(msg)
raise UndefinedDomain(msg)
@libvirt_handler
def vm_set_vlans(self, name, vlan_update_format, mac_address=None):
logger.debug('VM set vlan %s', name)
if name in self.hypervisor.domains:
if mac_address is None:
rcode, output = execute(self.main, [self.main.config.vlan_script,
name, vlan_update_format])
else:
rcode, output = execute(self.main, [self.main.config.vlan_script,
'--iface-macaddr', mac_address,
name, vlan_update_format])
if rcode != 0:
raise RuntimeError(output.strip().split('\n')[-1].strip())
else:
msg = 'Cannot set vlans on 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