From 8a34fb3890810330a9b8a2d659739d92134a832c Mon Sep 17 00:00:00 2001 From: Clinton Knight Date: Wed, 23 Sep 2015 10:48:34 -0400 Subject: [PATCH] Can't create shares on drivers that don't support snapshots For a driver that doesn't support snapshots, a share type with snapshot_support = ' False' will prevent share creation. Root cause is code in HostManager that improperly checks whether snapshot_support (and other boolean properties) is set on each pool. This commit fixes the check for the boolean pool capabilities. Change-Id: I6a488788926cca119498b3de992beec3b0545259 Closes-Bug: #1498646 --- manila/scheduler/host_manager.py | 14 +++++++------- manila/tests/scheduler/fakes.py | 21 +++++++++++++++------ manila/tests/scheduler/test_host_manager.py | 4 ++-- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/manila/scheduler/host_manager.py b/manila/scheduler/host_manager.py index f5f94d5e28..5c64eb3234 100644 --- a/manila/scheduler/host_manager.py +++ b/manila/scheduler/host_manager.py @@ -274,19 +274,19 @@ class HostState(object): if not pool_cap.get('storage_protocol'): pool_cap['storage_protocol'] = self.storage_protocol - if not pool_cap.get('driver_handles_share_servers'): - pool_cap['driver_handles_share_servers'] = \ - self.driver_handles_share_servers + if 'driver_handles_share_servers' not in pool_cap: + pool_cap['driver_handles_share_servers'] = ( + self.driver_handles_share_servers) - if not pool_cap.get('snapshot_support'): - pool_cap['snapshot_support'] = True + if 'snapshot_support' not in pool_cap: + pool_cap['snapshot_support'] = self.snapshot_support if not pool_cap.get('consistency_group_support'): pool_cap['consistency_group_support'] = \ self.consistency_group_support - if not pool_cap.get('dedupe'): - pool_cap['dedupe'] = False + if 'dedupe' not in pool_cap: + pool_cap['dedupe'] = self.dedupe def update_backend(self, capability): self.share_backend_name = capability.get('share_backend_name') diff --git a/manila/tests/scheduler/fakes.py b/manila/tests/scheduler/fakes.py index 8d3c8f8885..1776f38224 100644 --- a/manila/tests/scheduler/fakes.py +++ b/manila/tests/scheduler/fakes.py @@ -38,6 +38,7 @@ SERVICE_STATES_NO_POOLS = { provisioned_capacity_gb=312, max_over_subscription_ratio=1.0, thin_provisioning=False, + snapshot_support=False, driver_handles_share_servers=False), 'host2@back1': dict(share_backend_name='BBB', total_capacity_gb=256, free_capacity_gb=100, @@ -45,6 +46,7 @@ SERVICE_STATES_NO_POOLS = { provisioned_capacity_gb=400, max_over_subscription_ratio=2.0, thin_provisioning=True, + snapshot_support=True, driver_handles_share_servers=False), 'host2@back2': dict(share_backend_name='CCC', total_capacity_gb=10000, free_capacity_gb=700, @@ -52,6 +54,7 @@ SERVICE_STATES_NO_POOLS = { provisioned_capacity_gb=50000, max_over_subscription_ratio=20.0, thin_provisioning=True, + snapshot_support=True, driver_handles_share_servers=False), } @@ -180,7 +183,8 @@ class FakeHostManager(host_manager.HostManager): 'allocated_capacity_gb': 0, 'thin_provisioning': False, 'reserved_percentage': 10, - 'timestamp': None}, + 'timestamp': None, + 'snapshot_support': True}, 'host2': {'total_capacity_gb': 2048, 'free_capacity_gb': 300, 'allocated_capacity_gb': 1748, @@ -188,7 +192,8 @@ class FakeHostManager(host_manager.HostManager): 'max_over_subscription_ratio': 2.0, 'thin_provisioning': True, 'reserved_percentage': 10, - 'timestamp': None}, + 'timestamp': None, + 'snapshot_support': True}, 'host3': {'total_capacity_gb': 512, 'free_capacity_gb': 256, 'allocated_capacity_gb': 256, @@ -197,7 +202,8 @@ class FakeHostManager(host_manager.HostManager): 'thin_provisioning': False, 'consistency_group_support': 'host', 'reserved_percentage': 0, - 'timestamp': None}, + 'timestamp': None, + 'snapshot_support': True}, 'host4': {'total_capacity_gb': 2048, 'free_capacity_gb': 200, 'allocated_capacity_gb': 1848, @@ -205,7 +211,8 @@ class FakeHostManager(host_manager.HostManager): 'max_over_subscription_ratio': 1.0, 'thin_provisioning': True, 'reserved_percentage': 5, - 'timestamp': None}, + 'timestamp': None, + 'snapshot_support': True}, 'host5': {'total_capacity_gb': 2048, 'free_capacity_gb': 500, 'allocated_capacity_gb': 1548, @@ -214,13 +221,15 @@ class FakeHostManager(host_manager.HostManager): 'thin_provisioning': True, 'reserved_percentage': 5, 'timestamp': None, - 'consistency_group_support': 'pool'}, + 'consistency_group_support': 'pool', + 'snapshot_support': True}, 'host6': {'total_capacity_gb': 'unknown', 'free_capacity_gb': 'unknown', 'allocated_capacity_gb': 1548, 'thin_provisioning': False, 'reserved_percentage': 5, - 'timestamp': None}, + 'timestamp': None, + 'snapshot_support': True}, } diff --git a/manila/tests/scheduler/test_host_manager.py b/manila/tests/scheduler/test_host_manager.py index 119af06494..647d20b45e 100644 --- a/manila/tests/scheduler/test_host_manager.py +++ b/manila/tests/scheduler/test_host_manager.py @@ -194,7 +194,7 @@ class HostManagerTestCase(test.TestCase): 'vendor_name': None, 'storage_protocol': None, 'driver_handles_share_servers': False, - 'snapshot_support': True, + 'snapshot_support': False, 'consistency_group_support': False, 'dedupe': False, }, @@ -420,7 +420,7 @@ class HostManagerTestCase(test.TestCase): 'capabilities': { 'timestamp': None, 'driver_handles_share_servers': False, - 'snapshot_support': True, + 'snapshot_support': False, 'share_backend_name': 'AAA', 'free_capacity_gb': 200, 'driver_version': None,