core: fix un-setting global VMs (default netvm, clockvm etc)

This commit is contained in:
Marek Marczykowski-Górecki 2014-05-05 05:24:04 +02:00
parent 3914835ceb
commit b8b2733114
2 changed files with 39 additions and 17 deletions

View File

@ -354,6 +354,9 @@ class QubesVmCollection(dict):
netvm = self.get_default_fw_netvm())
def set_default_template(self, vm):
if vm is None:
self.default_template_qid = None
else:
assert vm.is_template(), "VM {0} is not a TemplateVM!".format(vm.name)
self.default_template_qid = vm.qid
@ -364,6 +367,9 @@ class QubesVmCollection(dict):
return self[self.default_template_qid]
def set_default_netvm(self, vm):
if vm is None:
self.default_netvm_qid = None
else:
assert vm.is_netvm(), "VM {0} does not provide network!".format(vm.name)
self.default_netvm_qid = vm.qid
@ -383,6 +389,9 @@ class QubesVmCollection(dict):
return self.default_kernel
def set_default_fw_netvm(self, vm):
if vm is None:
self.default_fw_netvm_qid = None
else:
assert vm.is_netvm(), "VM {0} does not provide network!".format(vm.name)
self.default_fw_netvm_qid = vm.qid
@ -393,6 +402,9 @@ class QubesVmCollection(dict):
return self[self.default_fw_netvm_qid]
def set_updatevm_vm(self, vm):
if vm is None:
self.updatevm_qid = None
else:
self.updatevm_qid = vm.qid
def get_updatevm_vm(self):
@ -402,6 +414,9 @@ class QubesVmCollection(dict):
return self[self.updatevm_qid]
def set_clockvm_vm(self, vm):
if vm is None:
self.clockvm_qid = None
else:
self.clockvm_qid = vm.qid
def get_clockvm_vm(self):

View File

@ -39,6 +39,13 @@ def handle_vm(vms, label, new_value = None):
assert label in functions.keys()
if new_value:
if new_value == "none":
try:
vms.__getattribute__(functions[label][1])(None)
except Exception as e:
print >> sys.stderr, "ERROR: {0}".format(str(e))
exit(1)
else:
vm = vms.get_vm_by_name (new_value)
if vm is None:
print >> sys.stderr, "A VM with the name '{0}' does not exist in the system.".format(new_value)