dom0/qvm-tools: catch exceptions while settting VM name (#656)
This commit is contained in:
parent
536eb00b9c
commit
1cd3ef3456
@ -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
|
||||
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)
|
||||
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
|
||||
|
@ -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
|
||||
|
||||
return properties[property](vms, vm, args)
|
||||
try:
|
||||
return properties[property](vms, vm, args)
|
||||
except Exception as err:
|
||||
print >> sys.stderr, "ERROR: %s" % str(err)
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user