From 4667a3b9de44ed682310b74272db4921259e8b8b Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Thu, 26 Feb 2015 22:59:13 +0000 Subject: [PATCH] Add multiattach capabilities injection This patch is a follow up to the multiattach patch that adds the ability to the scheduler to be able to filter capabilities on the volume multiattach flag. When a volume creation request comes in with the multiattach flag set on a volume, there was no way to filter out backends that don't support attaching a volume to more than one host. By defaut, no host supports it. When The Nova side lands, we can adjust drivers to add the new multiattach:True capability reporting. Change-Id: Ia426a2bf2ab8214f52fb6e70a3a1deff68d13d98 --- cinder/scheduler/filter_scheduler.py | 9 +++++++++ cinder/scheduler/host_manager.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/cinder/scheduler/filter_scheduler.py b/cinder/scheduler/filter_scheduler.py index c9dd604c9..52eb1ec33 100644 --- a/cinder/scheduler/filter_scheduler.py +++ b/cinder/scheduler/filter_scheduler.py @@ -283,6 +283,15 @@ class FilterScheduler(driver.Scheduler): self.populate_filter_properties(request_spec, filter_properties) + # If multiattach is enabled on a volume, we need to add + # multiattach to extra specs, so that the capability + # filtering is enabled. + multiattach = volume_properties.get('multiattach', False) + if multiattach and 'multiattach' not in resource_type.get( + 'extra_specs', {}): + resource_type['extra_specs'].update( + multiattach=' True') + # Find our local list of acceptable hosts by filtering and # weighing our options. we virtually consume resources on # it so subsequent selections can adjust accordingly. diff --git a/cinder/scheduler/host_manager.py b/cinder/scheduler/host_manager.py index b9c59724a..3637600b9 100644 --- a/cinder/scheduler/host_manager.py +++ b/cinder/scheduler/host_manager.py @@ -118,6 +118,9 @@ class HostState(object): self.max_over_subscription_ratio = 1.0 self.thin_provisioning_support = False self.thick_provisioning_support = False + # Does this backend support attaching a volume to more than + # once host/instance? + self.multiattach = False # PoolState for all pools self.pools = {} @@ -331,6 +334,7 @@ class PoolState(HostState): 'thin_provisioning_support', False) self.thick_provisioning_support = capability.get( 'thick_provisioning_support', False) + self.multiattach = capability.get('multiattach', False) def update_pools(self, capability): # Do nothing, since we don't have pools within pool, yet -- 2.45.2