From 5e95380db95fe72eeb0deaf8b72a089648a61cf3 Mon Sep 17 00:00:00 2001 From: Joanna Rutkowska Date: Sun, 24 Jul 2011 23:24:45 +0200 Subject: [PATCH] dom0: qvm-prefs: allow to change template for a VM --- dom0/qvm-tools/qvm-prefs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dom0/qvm-tools/qvm-prefs b/dom0/qvm-tools/qvm-prefs index 51ebe251..67874cc6 100755 --- a/dom0/qvm-tools/qvm-prefs +++ b/dom0/qvm-tools/qvm-prefs @@ -204,6 +204,24 @@ def set_kernel(vms, vm, args): vm.kernel = kernel +def set_template(vms, vm, args): + if len (args) != 1: + print "Missing template name argument!" + return False + + template_name = args[0]; + template_vm = vms.get_vm_by_name(template_name) + if template_vm is None or template_vm.qid not in vms: + print "A VM with the name '{0}' does not exist in the system.".format(template_name) + return False + + if not template_vm.is_template(): + print "VM '{0}' is not a TemplateVM".format(template_name) + return False + + print "Setting template for VM '{0}' to '{1}'...".format (vm.name, template_name) + vm.template_vm = template_vm + return True properties = { "updateable": set_updateable, @@ -214,6 +232,7 @@ properties = { "maxmem" : set_maxmem, "memory" : set_memory, "kernel" : set_kernel, + "template" : set_template, }