dom0/qvm-tools: catch exceptions while settting VM name (#656)

This commit is contained in:
Marek Marczykowski 2012-08-23 03:48:03 +02:00
parent 536eb00b9c
commit 1cd3ef3456
2 changed files with 16 additions and 7 deletions

View File

@ -22,6 +22,7 @@
from qubes.qubes import QubesVmCollection
from qubes.qubes import QubesVmLabels
from qubes.qubes import QubesException
from optparse import OptionParser;
import subprocess
import re
@ -116,12 +117,16 @@ def main():
new_vm_template = template
vm = None
try:
if options.netvm:
vm = qvm_collection.add_new_netvm(vmname, new_vm_template, label = label)
elif options.proxyvm:
vm = qvm_collection.add_new_proxyvm(vmname, new_vm_template, label = label)
else:
vm = qvm_collection.add_new_appvm(vmname, new_vm_template, label = label)
except QubesException as err:
print >> sys.stderr, "ERROR: {0}".format(err)
exit (1)
if options.internal:
vm.internal = True

View File

@ -331,7 +331,11 @@ def do_set(vms, vm, property, args):
print >> sys.stderr, "ERROR: Property '{0}' not available for this VM".format(property)
return False
try:
return properties[property](vms, vm, args)
except Exception as err:
print >> sys.stderr, "ERROR: %s" % str(err)
return False
def main():