From f3c7fb812940c63f53be615f50dac2966e13a4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 15 May 2017 13:06:41 +0200 Subject: [PATCH] admin: add missing parts to admin.vm.Clone Clone all the things. --- qubes/api/admin.py | 10 ++++++---- qubes/tests/api_admin.py | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qubes/api/admin.py b/qubes/api/admin.py index 2716fbd0..3d9dc977 100644 --- a/qubes/api/admin.py +++ b/qubes/api/admin.py @@ -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] diff --git a/qubes/tests/api_admin.py b/qubes/tests/api_admin.py index afb8e9d6..d13acb1a 100644 --- a/qubes/tests/api_admin.py +++ b/qubes/tests/api_admin.py @@ -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'])])