backup/restore: improve error message about restoring tags
Before reporting a tag as not restored, verify if it really wasn't restored. Generally created-by-* tags cannot be created manually. But when restoring a backup in dom0, created-by-dom0 tag is added, which in many cases will match what want to be restored. Adjust tests to check this too.
This commit is contained in:
parent
2b6b4e7954
commit
114f6fb250
@ -2035,8 +2035,9 @@ class BackupRestore(object):
|
|||||||
try:
|
try:
|
||||||
new_vm.tags.add(tag)
|
new_vm.tags.add(tag)
|
||||||
except Exception as err: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
self.log.error('Error adding tag %s to %s: %s',
|
if tag not in new_vm.tags:
|
||||||
tag, vm.name, err)
|
self.log.error('Error adding tag %s to %s: %s',
|
||||||
|
tag, vm.name, err)
|
||||||
|
|
||||||
for bus in vm.devices:
|
for bus in vm.devices:
|
||||||
for backend_domain, ident in vm.devices[bus]:
|
for backend_domain, ident in vm.devices[bus]:
|
||||||
|
@ -1440,8 +1440,14 @@ class TC_10_BackupCompatibility(qubesadmin.tests.backup.BackupTestCase):
|
|||||||
str(value).encode())] = b'0\0'
|
str(value).encode())] = b'0\0'
|
||||||
|
|
||||||
for tag in vm['tags']:
|
for tag in vm['tags']:
|
||||||
self.app.expected_calls[
|
if tag.startswith('created-by-'):
|
||||||
(name, 'admin.vm.tag.Set', tag, None)] = b'0\0'
|
self.app.expected_calls[
|
||||||
|
(name, 'admin.vm.tag.Set', tag, None)] = b''
|
||||||
|
self.app.expected_calls[
|
||||||
|
(name, 'admin.vm.tag.Get', tag, None)] = b'0\0001'
|
||||||
|
else:
|
||||||
|
self.app.expected_calls[
|
||||||
|
(name, 'admin.vm.tag.Set', tag, None)] = b'0\0'
|
||||||
|
|
||||||
if vm['backup_path']:
|
if vm['backup_path']:
|
||||||
appmenus = (
|
appmenus = (
|
||||||
@ -1727,7 +1733,8 @@ class TC_10_BackupCompatibility(qubesadmin.tests.backup.BackupTestCase):
|
|||||||
# retrieve calls from other multiprocess.Process instances
|
# retrieve calls from other multiprocess.Process instances
|
||||||
while not qubesd_calls_queue.empty():
|
while not qubesd_calls_queue.empty():
|
||||||
call_args = qubesd_calls_queue.get()
|
call_args = qubesd_calls_queue.get()
|
||||||
self.app.qubesd_call(*call_args)
|
with contextlib.suppress(qubesadmin.exc.QubesException):
|
||||||
|
self.app.qubesd_call(*call_args)
|
||||||
qubesd_calls_queue.close()
|
qubesd_calls_queue.close()
|
||||||
|
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -1797,7 +1804,8 @@ class TC_10_BackupCompatibility(qubesadmin.tests.backup.BackupTestCase):
|
|||||||
# retrieve calls from other multiprocess.Process instances
|
# retrieve calls from other multiprocess.Process instances
|
||||||
while not qubesd_calls_queue.empty():
|
while not qubesd_calls_queue.empty():
|
||||||
call_args = qubesd_calls_queue.get()
|
call_args = qubesd_calls_queue.get()
|
||||||
self.app.qubesd_call(*call_args)
|
with contextlib.suppress(qubesadmin.exc.QubesException):
|
||||||
|
self.app.qubesd_call(*call_args)
|
||||||
qubesd_calls_queue.close()
|
qubesd_calls_queue.close()
|
||||||
|
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -1867,7 +1875,8 @@ class TC_10_BackupCompatibility(qubesadmin.tests.backup.BackupTestCase):
|
|||||||
# retrieve calls from other multiprocess.Process instances
|
# retrieve calls from other multiprocess.Process instances
|
||||||
while not qubesd_calls_queue.empty():
|
while not qubesd_calls_queue.empty():
|
||||||
call_args = qubesd_calls_queue.get()
|
call_args = qubesd_calls_queue.get()
|
||||||
self.app.qubesd_call(*call_args)
|
with contextlib.suppress(qubesadmin.exc.QubesException):
|
||||||
|
self.app.qubesd_call(*call_args)
|
||||||
qubesd_calls_queue.close()
|
qubesd_calls_queue.close()
|
||||||
|
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -1968,7 +1977,8 @@ class TC_10_BackupCompatibility(qubesadmin.tests.backup.BackupTestCase):
|
|||||||
# retrieve calls from other multiprocess.Process instances
|
# retrieve calls from other multiprocess.Process instances
|
||||||
while not qubesd_calls_queue.empty():
|
while not qubesd_calls_queue.empty():
|
||||||
call_args = qubesd_calls_queue.get()
|
call_args = qubesd_calls_queue.get()
|
||||||
self.app.qubesd_call(*call_args)
|
with contextlib.suppress(qubesadmin.exc.QubesException):
|
||||||
|
self.app.qubesd_call(*call_args)
|
||||||
qubesd_calls_queue.close()
|
qubesd_calls_queue.close()
|
||||||
|
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
Loading…
Reference in New Issue
Block a user