dom0/qvm-tools: catch exceptions while settting VM name (#656)
This commit is contained in:
parent
85565af560
commit
b7f5c6ac0b
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
from qubes.qubes import QubesVmCollection
|
from qubes.qubes import QubesVmCollection
|
||||||
from qubes.qubes import QubesVmLabels
|
from qubes.qubes import QubesVmLabels
|
||||||
|
from qubes.qubes import QubesException
|
||||||
from optparse import OptionParser;
|
from optparse import OptionParser;
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
@ -133,14 +134,18 @@ def main():
|
|||||||
new_vm_template = template
|
new_vm_template = template
|
||||||
|
|
||||||
vm = None
|
vm = None
|
||||||
if options.netvm:
|
try:
|
||||||
vm = qvm_collection.add_new_netvm(vmname, new_vm_template, label = label)
|
if options.netvm:
|
||||||
elif options.proxyvm:
|
vm = qvm_collection.add_new_netvm(vmname, new_vm_template, label = label)
|
||||||
vm = qvm_collection.add_new_proxyvm(vmname, new_vm_template, label = label)
|
elif options.proxyvm:
|
||||||
elif options.hvm:
|
vm = qvm_collection.add_new_proxyvm(vmname, new_vm_template, label = label)
|
||||||
vm = qvm_collection.add_new_hvm(vmname, label = label)
|
elif options.hvm:
|
||||||
else:
|
vm = qvm_collection.add_new_hvm(vmname, label = label)
|
||||||
vm = qvm_collection.add_new_appvm(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:
|
if options.internal:
|
||||||
vm.internal = True
|
vm.internal = True
|
||||||
|
@ -375,7 +375,11 @@ def do_set(vms, vm, property, args):
|
|||||||
print >> sys.stderr, "ERROR: Property '{0}' not available for this VM".format(property)
|
print >> sys.stderr, "ERROR: Property '{0}' not available for this VM".format(property)
|
||||||
return False
|
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():
|
def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user