[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
This commit is contained in:
Yong Huang 2019-10-29 14:42:38 +08:00
parent 67fe72f563
commit a5adb0bd11
7 changed files with 70 additions and 1 deletions

View File

@ -135,6 +135,7 @@ for the Unity driver.
unity_ethernet_ports = <comma separated ports list>
driver_handles_share_servers = True/False
unity_share_server = <name of NAS server in Unity system>
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

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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)

View File

@ -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)

View File

@ -0,0 +1,4 @@
---
features:
- |
Dell EMC Unity: Default filter function support for 3GB share size.