From dfbcef34a89853456e2ba9fb0f9ed3501ede4e41 Mon Sep 17 00:00:00 2001 From: Rafi Khardalian Date: Fri, 8 Feb 2013 00:31:46 +0000 Subject: [PATCH] Simplify libvirt snapshot code path The "cold" snapshot code path was unnecessarily complex. We were traversing 3 layers of abstraction to reach 3 lines of code. I've completely eliminated snapshot.py by moving all "cold" snapshot functions into imagebackend.py and adjusting the libvirt driver accordingly. This is the first pass of several I intend to make against imagebackend.py, as it is far too difficult to read given how basic the basic level of functionality it is intended to provide. Change-Id: Idfacffb7210ae61193ee4f2360d4b38f330a177c --- nova/tests/fake_libvirt_utils.py | 4 ++++ nova/tests/test_libvirt.py | 2 +- nova/tests/test_virt_drivers.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/tests/fake_libvirt_utils.py b/nova/tests/fake_libvirt_utils.py index b3d84246..285a4b7e 100644 --- a/nova/tests/fake_libvirt_utils.py +++ b/nova/tests/fake_libvirt_utils.py @@ -144,3 +144,7 @@ def fetch_image(context, target, image_id, user_id, project_id): def get_instance_path(instance): # TODO(mikal): we should really just call the real one here return os.path.join(CONF.instances_path, instance['name']) + + +def pick_disk_driver_name(is_block_dev=False): + return "qemu" diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 12b1c1a6..c93bb016 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -273,7 +273,7 @@ class LibvirtConnTestCase(test.TestCase): 'nova.virt.libvirt.driver.libvirt_utils', fake_libvirt_utils)) self.useFixture(fixtures.MonkeyPatch( - 'nova.virt.libvirt.snapshots.libvirt_utils', + 'nova.virt.libvirt.imagebackend.libvirt_utils', fake_libvirt_utils)) def fake_extend(image, size): diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 67452bc2..a94fdc3c 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -84,7 +84,7 @@ class _FakeDriverBackendTestCase(object): 'nova.virt.libvirt.driver.libvirt_utils', fake_libvirt_utils)) self.useFixture(fixtures.MonkeyPatch( - 'nova.virt.libvirt.snapshots.libvirt_utils', + 'nova.virt.libvirt.imagebackend.libvirt_utils', fake_libvirt_utils)) self.useFixture(fixtures.MonkeyPatch( 'nova.virt.libvirt.firewall.libvirt',