From 0daebe727246eef501c54adaa678995467e3060b Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 23 Oct 2012 12:44:54 -0700 Subject: Add virt driver capabilities definition Going forward with the early stages of no-db-compute, we will consistently hit cases where we need to eject some database usage from one virt driver up a few layers. Since those are not commonly used by all, some way of determining (and the higher layer) the properties of the virt driver being used will be useful. We have discussed using something like a mixin interface class and multiple inheritance. We have discussed tricks like detecting if the manage_image_cache() method has been overridden. We have discussed trying it once and catching NotImplementedError and then never trying again. Aside from the first, none of these are unsneaky enough to bite us later. This approach will provide us a way to declare such properties succinctly in the compute driver to help the higher layers know what we want them to do on our behalf. Change-Id: I74dea9322a5b4688319ebf5d9afe416e93401c58 --- nova/compute/manager.py | 2 ++ nova/virt/driver.py | 4 ++++ nova/virt/libvirt/driver.py | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index f598ccb39..515737992 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2970,6 +2970,8 @@ class ComputeManager(manager.SchedulerDependentManager): def _run_image_cache_manager_pass(self, context): """Run a single pass of the image cache manager.""" + if not self.driver.capabilities["has_imagecache"]: + return if FLAGS.image_cache_manager_interval == 0: return diff --git a/nova/virt/driver.py b/nova/virt/driver.py index 59fac115f..8a7c39fa8 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -88,6 +88,10 @@ class ComputeDriver(object): """ + capabilities = { + "has_imagecache": False, + } + def init_host(self, host): """Initialize anything that is necessary for the driver to function, including catching up with currently running VM's on the given host.""" diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 8ef469b76..fcbc8f688 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -258,6 +258,10 @@ def _get_eph_disk(ephemeral): class LibvirtDriver(driver.ComputeDriver): + capabilities = { + "has_imagecache": True, + } + def __init__(self, read_only=False): super(LibvirtDriver, self).__init__() -- cgit