From c86b731d3e2315f69714f1181992a1eeee5d559f Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 24 Feb 2018 12:27:37 +0000 Subject: [PATCH] restore.py: factor out _restore_property() helper --- qubesadmin/backup/restore.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qubesadmin/backup/restore.py b/qubesadmin/backup/restore.py index c39bf69..744234f 100644 --- a/qubesadmin/backup/restore.py +++ b/qubesadmin/backup/restore.py @@ -1820,6 +1820,14 @@ class BackupRestore(object): self.log.info("-> Please install updates for all the restored " "templates.") + def _restore_property(self, vm, prop, value): + '''Restore a single VM property, logging exceptions''' + try: + setattr(vm, prop, value) + except Exception as err: # pylint: disable=broad-except + self.log.error('Error setting %s.%s to %s: %s', + vm.name, prop, value, err) + def _restore_vms_metadata(self, restore_info): '''Restore VM metadata @@ -1893,11 +1901,7 @@ class BackupRestore(object): # restore options if prop in ['template', 'netvm', 'default_dispvm']: continue - try: - setattr(new_vm, prop, value) - except Exception as err: # pylint: disable=broad-except - self.log.error('Error setting %s.%s to %s: %s', - vm.name, prop, value, err) + self._restore_property(new_vm, prop, value) for feature, value in vm.features.items(): try: