restore.py: factor out _restore_property() helper
This commit is contained in:
parent
2ace32bb73
commit
c86b731d3e
@ -1820,6 +1820,14 @@ class BackupRestore(object):
|
|||||||
self.log.info("-> Please install updates for all the restored "
|
self.log.info("-> Please install updates for all the restored "
|
||||||
"templates.")
|
"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):
|
def _restore_vms_metadata(self, restore_info):
|
||||||
'''Restore VM metadata
|
'''Restore VM metadata
|
||||||
|
|
||||||
@ -1893,11 +1901,7 @@ class BackupRestore(object):
|
|||||||
# restore options
|
# restore options
|
||||||
if prop in ['template', 'netvm', 'default_dispvm']:
|
if prop in ['template', 'netvm', 'default_dispvm']:
|
||||||
continue
|
continue
|
||||||
try:
|
self._restore_property(new_vm, prop, value)
|
||||||
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)
|
|
||||||
|
|
||||||
for feature, value in vm.features.items():
|
for feature, value in vm.features.items():
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user