dom0: qvm-backup-restore change restore loop logic (#212)
This commit is contained in:
parent
f69caefa61
commit
c1f4fcc172
@ -298,25 +298,16 @@ def main():
|
|||||||
if not (prompt == "y" or prompt == "Y"):
|
if not (prompt == "y" or prompt == "Y"):
|
||||||
exit (0)
|
exit (0)
|
||||||
|
|
||||||
for vm in vms_to_restore:
|
# Add templates...
|
||||||
print "-> Restoring: {0} ...".format(vm.name)
|
for vm in [ vm for vm in vms_to_restore if vm.is_template()]:
|
||||||
|
print "-> Restoring Template VM {0}...".format(vm.name)
|
||||||
retcode = subprocess.call (["mkdir", "-p", vm.dir_path])
|
retcode = subprocess.call (["mkdir", "-p", vm.dir_path])
|
||||||
if retcode != 0:
|
if retcode != 0:
|
||||||
print ("*** Cannot create directory: {0}?!".format(dest_dir))
|
print ("*** Cannot create directory: {0}?!".format(dest_dir))
|
||||||
print ("Skiping...")
|
print ("Skiping...")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if vm.is_appvm():
|
restore_vm_dir (backup_dir, vm.dir_path, qubes_templates_dir);
|
||||||
restore_vm_dir (backup_dir, vm.dir_path, qubes_appvms_dir);
|
|
||||||
elif vm.is_template():
|
|
||||||
restore_vm_dir (backup_dir, vm.dir_path, qubes_templates_dir);
|
|
||||||
else:
|
|
||||||
print "ERROR: VM '{0}', type='{1}': unsupported VM type!".format(vm.name, vm.type)
|
|
||||||
|
|
||||||
# Add templates...
|
|
||||||
for vm in [ vm for vm in vms_to_restore if vm.is_template()]:
|
|
||||||
print "-> Adding Template VM {0}...".format(vm.name)
|
|
||||||
updateable = vm.updateable
|
updateable = vm.updateable
|
||||||
try:
|
try:
|
||||||
vm = host_collection.add_new_templatevm(vm.name,
|
vm = host_collection.add_new_templatevm(vm.name,
|
||||||
@ -336,14 +327,19 @@ def main():
|
|||||||
# ... then appvms...
|
# ... then appvms...
|
||||||
for vm in [ vm for vm in vms_to_restore if vm.is_appvm()]:
|
for vm in [ vm for vm in vms_to_restore if vm.is_appvm()]:
|
||||||
|
|
||||||
print "-> Adding AppVM {0}...".format(vm.name)
|
print "-> Restoring AppVM {0}...".format(vm.name)
|
||||||
|
retcode = subprocess.call (["mkdir", "-p", vm.dir_path])
|
||||||
|
if retcode != 0:
|
||||||
|
print ("*** Cannot create directory: {0}?!".format(dest_dir))
|
||||||
|
print ("Skiping...")
|
||||||
|
continue
|
||||||
|
|
||||||
|
restore_vm_dir (backup_dir, vm.dir_path, qubes_appvms_dir);
|
||||||
|
|
||||||
template_vm = None
|
template_vm = None
|
||||||
recreate_conf = options.recreate_conf
|
|
||||||
if vm.template_vm is not None:
|
if vm.template_vm is not None:
|
||||||
template_name = find_template_name(vm.template_vm.name, options.replace_template)
|
template_name = find_template_name(vm.template_vm.name, options.replace_template)
|
||||||
template_vm = host_collection.get_vm_by_name(template_name)
|
template_vm = host_collection.get_vm_by_name(template_name)
|
||||||
if template_name != vm.template_vm.name:
|
|
||||||
recreate_conf = True
|
|
||||||
|
|
||||||
if not vm.uses_default_netvm:
|
if not vm.uses_default_netvm:
|
||||||
uses_default_netvm = False
|
uses_default_netvm = False
|
||||||
@ -370,23 +366,15 @@ def main():
|
|||||||
vm.uses_default_netvm = False
|
vm.uses_default_netvm = False
|
||||||
vm.netvm_vm = netvm_vm
|
vm.netvm_vm = netvm_vm
|
||||||
|
|
||||||
try:
|
|
||||||
if template_vm is not None and recreate_conf:
|
|
||||||
print "--> Recreating config file..."
|
|
||||||
vm.create_config_file()
|
|
||||||
except QubesException as err:
|
|
||||||
print "ERROR xen config restore: {0}".format(err)
|
|
||||||
print "*** VM '{0}' will not boot until you manually fix it (or correctly restore this VM)!".format(vm.name)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vm.create_appmenus(verbose=True)
|
vm.create_appmenus(verbose=True)
|
||||||
except QubesException as err:
|
except Exception as err:
|
||||||
print "ERROR during appmenu restore: {0}".format(err)
|
print "ERROR during appmenu restore: {0}".format(err)
|
||||||
print "*** VM '{0}' will not have appmenus".format(vm.name)
|
print "*** VM '{0}' will not have appmenus".format(vm.name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vm.verify_files()
|
vm.verify_files()
|
||||||
except QubesException as err:
|
except Exception as err:
|
||||||
print "ERROR: {0}".format(err)
|
print "ERROR: {0}".format(err)
|
||||||
print "*** Skiping VM: {0}".format(vm.name)
|
print "*** Skiping VM: {0}".format(vm.name)
|
||||||
host_collection.pop(vm.qid)
|
host_collection.pop(vm.qid)
|
||||||
|
Loading…
Reference in New Issue
Block a user