Merge remote-tracking branch 'qubesos/pr/187'
* qubesos/pr/187: Don't fail create/clone if /var/lib/qubes/TYPE/NAME/ exists Make 'qvm-volume revert' really use the latest revision Fix wrong mocks of Volume.revisions
This commit is contained in:
commit
eb846f6647
@ -347,7 +347,8 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
|
|||||||
assert self.arg in self.dest.volumes.keys()
|
assert self.arg in self.dest.volumes.keys()
|
||||||
|
|
||||||
volume = self.dest.volumes[self.arg]
|
volume = self.dest.volumes[self.arg]
|
||||||
revisions = [revision for revision in volume.revisions]
|
id_to_timestamp = volume.revisions
|
||||||
|
revisions = sorted(id_to_timestamp, key=id_to_timestamp.__getitem__)
|
||||||
revisions = self.fire_event_for_filter(revisions)
|
revisions = self.fire_event_for_filter(revisions)
|
||||||
|
|
||||||
return ''.join('{}\n'.format(revision) for revision in revisions)
|
return ''.join('{}\n'.format(revision) for revision in revisions)
|
||||||
|
@ -381,7 +381,8 @@ class TC_00_VMs(AdminAPITestCase):
|
|||||||
self.vm.volumes = unittest.mock.MagicMock()
|
self.vm.volumes = unittest.mock.MagicMock()
|
||||||
volumes_conf = {
|
volumes_conf = {
|
||||||
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
||||||
'__getitem__.return_value.revisions': ['rev1', 'rev2'],
|
'__getitem__.return_value.revisions':
|
||||||
|
{'rev2': '2018-02-22T22:22:22', 'rev1': '2018-01-11T11:11:11'},
|
||||||
}
|
}
|
||||||
self.vm.volumes.configure_mock(**volumes_conf)
|
self.vm.volumes.configure_mock(**volumes_conf)
|
||||||
value = self.call_mgmt_func(b'admin.vm.volume.ListSnapshots',
|
value = self.call_mgmt_func(b'admin.vm.volume.ListSnapshots',
|
||||||
@ -413,7 +414,8 @@ class TC_00_VMs(AdminAPITestCase):
|
|||||||
self.vm.volumes = unittest.mock.MagicMock()
|
self.vm.volumes = unittest.mock.MagicMock()
|
||||||
volumes_conf = {
|
volumes_conf = {
|
||||||
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
||||||
'__getitem__.return_value.revisions': ['rev1', 'rev2'],
|
'__getitem__.return_value.revisions':
|
||||||
|
{'rev2': '2018-02-22T22:22:22', 'rev1': '2018-01-11T11:11:11'},
|
||||||
}
|
}
|
||||||
self.vm.volumes.configure_mock(**volumes_conf)
|
self.vm.volumes.configure_mock(**volumes_conf)
|
||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
@ -440,7 +442,8 @@ class TC_00_VMs(AdminAPITestCase):
|
|||||||
self.vm.volumes = unittest.mock.MagicMock()
|
self.vm.volumes = unittest.mock.MagicMock()
|
||||||
volumes_conf = {
|
volumes_conf = {
|
||||||
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
||||||
'__getitem__.return_value.revisions': ['rev1', 'rev2'],
|
'__getitem__.return_value.revisions':
|
||||||
|
{'rev2': '2018-02-22T22:22:22', 'rev1': '2018-01-11T11:11:11'},
|
||||||
}
|
}
|
||||||
self.vm.volumes.configure_mock(**volumes_conf)
|
self.vm.volumes.configure_mock(**volumes_conf)
|
||||||
del self.vm.volumes['private'].revert('rev1')._is_coroutine
|
del self.vm.volumes['private'].revert('rev1')._is_coroutine
|
||||||
@ -462,7 +465,8 @@ class TC_00_VMs(AdminAPITestCase):
|
|||||||
self.vm.volumes = unittest.mock.MagicMock()
|
self.vm.volumes = unittest.mock.MagicMock()
|
||||||
volumes_conf = {
|
volumes_conf = {
|
||||||
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
'keys.return_value': ['root', 'private', 'volatile', 'kernel'],
|
||||||
'__getitem__.return_value.revisions': ['rev1', 'rev2'],
|
'__getitem__.return_value.revisions':
|
||||||
|
{'rev2': '2018-02-22T22:22:22', 'rev1': '2018-01-11T11:11:11'},
|
||||||
}
|
}
|
||||||
self.vm.volumes.configure_mock(**volumes_conf)
|
self.vm.volumes.configure_mock(**volumes_conf)
|
||||||
self.vm.storage = unittest.mock.Mock()
|
self.vm.storage = unittest.mock.Mock()
|
||||||
|
@ -93,7 +93,7 @@ class TC_00_DispVM(qubes.tests.QubesTestCase):
|
|||||||
self.assertEqual(dispvm.label, self.appvm.label)
|
self.assertEqual(dispvm.label, self.appvm.label)
|
||||||
self.assertEqual(dispvm.auto_cleanup, True)
|
self.assertEqual(dispvm.auto_cleanup, True)
|
||||||
mock_makedirs.assert_called_once_with(
|
mock_makedirs.assert_called_once_with(
|
||||||
'/var/lib/qubes/appvms/' + dispvm.name, mode=0o775)
|
'/var/lib/qubes/appvms/' + dispvm.name, mode=0o775, exist_ok=True)
|
||||||
mock_symlink.assert_called_once_with(
|
mock_symlink.assert_called_once_with(
|
||||||
'/usr/share/icons/hicolor/128x128/devices/appvm-red.png',
|
'/usr/share/icons/hicolor/128x128/devices/appvm-red.png',
|
||||||
'/var/lib/qubes/appvms/{}/icon.png'.format(dispvm.name))
|
'/var/lib/qubes/appvms/{}/icon.png'.format(dispvm.name))
|
||||||
|
@ -1344,7 +1344,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
self.log.info('Creating directory: {0}'.format(self.dir_path))
|
self.log.info('Creating directory: {0}'.format(self.dir_path))
|
||||||
os.makedirs(self.dir_path, mode=0o775)
|
os.makedirs(self.dir_path, mode=0o775, exist_ok=True)
|
||||||
|
|
||||||
if pool or pools:
|
if pool or pools:
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
@ -1411,7 +1411,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
assert not os.path.exists(self.dir_path), msg
|
assert not os.path.exists(self.dir_path), msg
|
||||||
|
|
||||||
self.log.info('Creating directory: {0}'.format(self.dir_path))
|
self.log.info('Creating directory: {0}'.format(self.dir_path))
|
||||||
os.makedirs(self.dir_path, mode=0o775)
|
os.makedirs(self.dir_path, mode=0o775, exist_ok=True)
|
||||||
|
|
||||||
if pool or pools:
|
if pool or pools:
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
Loading…
Reference in New Issue
Block a user