admin: add missing parts to admin.vm.Clone

Clone all the things.
This commit is contained in:
Marek Marczykowski-Górecki 2017-05-15 13:06:41 +02:00
parent 8533ec9773
commit f3c7fb8129
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 9 additions and 4 deletions

View File

@ -727,10 +727,12 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
dst_vm = self.app.add_new_vm(src_vm.__class__, name=new_name)
try:
dst_vm.clone_properties(src_vm)
# TODO: tags
# TODO: features
# TODO: firewall
# TODO: persistent devices
dst_vm.tags.update(src_vm.tags)
dst_vm.features.update(src_vm.features)
dst_vm.firewall.clone(src_vm.firewall)
for devclass in src_vm.devices:
for device_assignment in src_vm.devices[devclass].assignments():
dst_vm.devices[devclass].attach(device_assignment.clone())
yield from dst_vm.clone_disk_files(src_vm)
except:
del self.app.domains[dst_vm]

View File

@ -1233,6 +1233,9 @@ class TC_00_VMs(AdminAPITestCase):
vm = self.app.domains['test-vm2']
self.assertEqual(vm.label, self.app.get_label('red'))
self.assertEqual(vm.template, self.app.domains['test-template'])
self.assertEqual(vm.tags, self.vm.tags)
self.assertEqual(vm.features, self.vm.features)
self.assertEqual(vm.firewall, self.vm.firewall)
self.assertEqual(mock_clone.mock_calls,
[unittest.mock.call(self.app.domains['test-vm2']).clone(
self.app.domains['test-vm1'])])