Fix verify-only

This commit is contained in:
Christopher Laprise 2017-12-06 21:31:30 -05:00
parent 6fe5f8c0e7
commit f86c640d65
No known key found for this signature in database
GPG Key ID: 448568C8B281C952
2 changed files with 19 additions and 13 deletions
qubesadmin

View File

@ -1357,9 +1357,10 @@ class BackupRestore(object):
# This all means that if the file was correctly verified
# + decrypted, we will surely access the right file
filename = self._verify_and_decrypt(filename)
if not self.options.verify_only:
to_extract.put(os.path.join(self.tmpdir, filename))
else:
os.unlink(os.path.join(self.tmpdir, filename))
if self.canceled:
raise BackupCanceledError("Restore canceled",
@ -1783,19 +1784,17 @@ class BackupRestore(object):
raise
else:
self.log.error('Error extracting data: ' + str(err))
self.log.warning(
"Continuing anyway to restore at least some VMs")
if self.options.verify_only:
finally:
if self.log.getEffectiveLevel() > logging.DEBUG:
shutil.rmtree(self.tmpdir)
return
if self.canceled:
raise BackupCanceledError("Restore canceled",
tmpdir=self.tmpdir)
shutil.rmtree(self.tmpdir)
self.log.info("-> Done. Please install updates for all the restored "
self.log.info("-> Done.")
if not self.options.verify_only:
self.log.info("-> Please install updates for all the restored "
"templates.")
def _restore_vms_metadata(self, restore_info):
@ -1817,6 +1816,9 @@ class BackupRestore(object):
for vm in self._templates_first(vms.values()):
if self.canceled:
return
if self.options.verify_only:
self.log.info("-> Verifying %s...", vm.name)
else:
self.log.info("-> Restoring %s...", vm.name)
kwargs = {}
if vm.template:

View File

@ -134,6 +134,10 @@ def handle_broken(app, args, restore_info):
"Or use --rename-conflicting to restore those VMs under "
"modified names (with numbers at the end).")
if args.verify_only:
app.log.info("The above VM archive(s) will be verified.")
app.log.info("Existing VMs will NOT be removed or altered.")
else:
app.log.info("The above VMs will be copied and added to your system.")
app.log.info("Exisiting VMs will NOT be removed.")