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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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__()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user