From a5adb0bd11da734a14bfc9b51f128be90be3bab3 Mon Sep 17 00:00:00 2001 From: Yong Huang Date: Tue, 29 Oct 2019 14:42:38 +0800 Subject: [PATCH] [Unity] Implements default filter function Implements the default filter function for Unity driver, if the share size is smaller than 3GB, will not schedule the share creation to Unity backend. Change-Id: Iebb5063d4e1c4c2f5ddce0d5000b7d51dcb0605b Closes-bug: #1652379 --- .../drivers/dell-emc-unity-driver.rst | 25 +++++++++++++++++++ manila/share/drivers/dell_emc/driver.py | 5 ++++ .../dell_emc/plugins/unity/connection.py | 13 +++++++++- .../dell_emc/plugins/unity/res_mock.py | 1 + .../dell_emc/plugins/unity/test_connection.py | 17 +++++++++++++ .../share/drivers/dell_emc/test_driver.py | 6 +++++ ...ter-function-support-2eefc8044a5add5d.yaml | 4 +++ 7 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/unity-default-filter-function-support-2eefc8044a5add5d.yaml diff --git a/doc/source/configuration/shared-file-systems/drivers/dell-emc-unity-driver.rst b/doc/source/configuration/shared-file-systems/drivers/dell-emc-unity-driver.rst index f2950cfa73..70b13a9d15 100644 --- a/doc/source/configuration/shared-file-systems/drivers/dell-emc-unity-driver.rst +++ b/doc/source/configuration/shared-file-systems/drivers/dell-emc-unity-driver.rst @@ -135,6 +135,7 @@ for the Unity driver. unity_ethernet_ports = driver_handles_share_servers = True/False unity_share_server = + report_default_filter_function = True/False - `emc_share_backend` The plugin name. Set it to `unity` for the Unity driver. @@ -192,6 +193,13 @@ for the Unity driver. One of NAS server names in Unity, it is used for share creation when the driver is in `DHSS=False` mode. +- `report_default_filter_function` + Whether or not report default filter function. Default value is False. + However, this value will be changed to True in a future release to ensure + compliance with design expectations in Manila. So we recommend always + setting this option in your deployment to True or False per your desired + behavior. + Restart of :term:`manila-share` service is needed for the configuration changes to take effect. @@ -444,6 +452,22 @@ balanced ports per storage processor. For example: # Use eth2 from both SPs unity_ethernet_ports = spa_eth2, spb_eth2 + +Default filter function +----------------------- + +Unity does not support the file system creation with size smaller than 3GB, if +the size of share user create is smaller than 3GB, Unity driver will supplement +the size to 3GB in Unity. + +Unity driver implemented the get_default_filter_function API to report the +default filter function, if the share size is smaller than 3GB, Manila will +not schedule the share creation to Unity backend. + +Unity driver provides an option ``report_default_filter_function`` to disable +or enable the filter function reporting, the default value is disabled. + + Restrictions ------------ @@ -483,6 +507,7 @@ Following driver features are implemented in the plugin. parameters. * teardown_server: Tear down the share server. * revert_to_snapshot: Revert a share to a snapshot. +* get_default_filter_function: Report a default filter function. Driver options diff --git a/manila/share/drivers/dell_emc/driver.py b/manila/share/drivers/dell_emc/driver.py index 2af803bb25..365874b1c0 100644 --- a/manila/share/drivers/dell_emc/driver.py +++ b/manila/share/drivers/dell_emc/driver.py @@ -308,3 +308,8 @@ class EMCShareDriver(driver.ShareDriver): share_server) else: raise NotImplementedError() + + def get_default_filter_function(self): + if hasattr(self.plugin, 'get_default_filter_function'): + return self.plugin.get_default_filter_function() + return None diff --git a/manila/share/drivers/dell_emc/plugins/unity/connection.py b/manila/share/drivers/dell_emc/plugins/unity/connection.py index 5a54d81b01..62f8b1f746 100644 --- a/manila/share/drivers/dell_emc/plugins/unity/connection.py +++ b/manila/share/drivers/dell_emc/plugins/unity/connection.py @@ -42,9 +42,10 @@ from manila import utils 7.0.1 - Fix parsing management IPv6 address 7.0.2 - Bugfix: failed to delete CIFS share if wrong access was set 8.0.0 - Supports manage/unmanage share server/share/snapshot + 9.0.0 - Implements default filter function """ -VERSION = "8.0.0" +VERSION = "9.0.0" LOG = log.getLogger(__name__) SUPPORTED_NETWORK_TYPES = (None, 'flat', 'vlan') @@ -72,6 +73,9 @@ UNITY_OPTS = [ help='NAS server used for creating share when driver ' 'is in DHSS=False mode. It is required when ' 'driver_handles_share_servers=False in manila.conf.'), + cfg.StrOpt('report_default_filter_function', + default=False, + help='Whether or not report default filter function.'), ] CONF = cfg.CONF @@ -143,6 +147,8 @@ class UnityStorageConnection(driver.StorageConnection): self.validate_port_configuration(self.port_ids_conf) pool_name = config.unity_server_meta_pool self._config_pool(pool_name) + self.report_default_filter_function = config.safe_get( + 'report_default_filter_function') def get_server_name(self, share_server=None): if not self.driver_handles_share_servers: @@ -894,3 +900,8 @@ class UnityStorageConnection(driver.StorageConnection): """Reverts a share (in place) to the specified snapshot.""" snapshot_id = unity_utils.get_snapshot_id(snapshot) return self.client.restore_snapshot(snapshot_id) + + def get_default_filter_function(self): + if self.report_default_filter_function: + return "share.size >= 3" + return None diff --git a/manila/tests/share/drivers/dell_emc/plugins/unity/res_mock.py b/manila/tests/share/drivers/dell_emc/plugins/unity/res_mock.py index da45d6a9a3..caead56989 100644 --- a/manila/tests/share/drivers/dell_emc/plugins/unity/res_mock.py +++ b/manila/tests/share/drivers/dell_emc/plugins/unity/res_mock.py @@ -354,6 +354,7 @@ def do_connection_connect(conn, res): conn.port_set = set(['spa_eth1', 'spa_eth2']) conn.nas_server_pool = StorageObjectMock(res['nas_server_pool']) conn.storage_processor = StorageObjectMock(res['sp_a']) + conn.report_default_filter_function = False def patch_connection(func): diff --git a/manila/tests/share/drivers/dell_emc/plugins/unity/test_connection.py b/manila/tests/share/drivers/dell_emc/plugins/unity/test_connection.py index 1eb2855cde..a016f63a47 100644 --- a/manila/tests/share/drivers/dell_emc/plugins/unity/test_connection.py +++ b/manila/tests/share/drivers/dell_emc/plugins/unity/test_connection.py @@ -882,3 +882,20 @@ class TestConnection(test.TestCase): self.assertRaises(exception.ManageInvalidShare, connection.manage_existing_with_server, share, driver_options, share_server) + + @res_mock.mock_manila_input + @res_mock.patch_connection + def test_get_default_filter_function_disable_report(self, connection, + mocked_input): + expected = None + actual = connection.get_default_filter_function() + self.assertEqual(expected, actual) + + @res_mock.mock_manila_input + @res_mock.patch_connection + def test_get_default_filter_function_enable_report(self, connection, + mocked_input): + expected = "share.size >= 3" + connection.report_default_filter_function = True + actual = connection.get_default_filter_function() + self.assertEqual(expected, actual) diff --git a/manila/tests/share/drivers/dell_emc/test_driver.py b/manila/tests/share/drivers/dell_emc/test_driver.py index 88b2ce8dab..93a68dfbbe 100644 --- a/manila/tests/share/drivers/dell_emc/test_driver.py +++ b/manila/tests/share/drivers/dell_emc/test_driver.py @@ -116,6 +116,7 @@ class EMCShareFrameworkTestCase(test.TestCase): def test_update_share_stats(self): data = {} self.driver.plugin = mock.Mock() + self.driver.plugin.get_default_filter_function.return_value = None self.driver._update_share_stats() data["share_backend_name"] = FAKE_BACKEND data["driver_handles_share_servers"] = True @@ -203,3 +204,8 @@ class EMCShareFrameworkTestCase(test.TestCase): self.driver.unmanage_snapshot(snapshot) self.driver.unmanage_snapshot_with_server(snapshot, share_server) self.driver.unmanage_server(server_details) + + def test_get_default_filter_function(self): + expected = None + actual = self.driver.get_default_filter_function() + self.assertEqual(expected, actual) diff --git a/releasenotes/notes/unity-default-filter-function-support-2eefc8044a5add5d.yaml b/releasenotes/notes/unity-default-filter-function-support-2eefc8044a5add5d.yaml new file mode 100644 index 0000000000..664235b7e2 --- /dev/null +++ b/releasenotes/notes/unity-default-filter-function-support-2eefc8044a5add5d.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Dell EMC Unity: Default filter function support for 3GB share size.