Merge "[Unity] Shrink share in Unity driver."

This commit is contained in:
Zuul 2019-02-15 23:12:00 +00:00 committed by Gerrit Code Review
commit 6b3650245e
13 changed files with 221 additions and 4 deletions

View File

@ -35,7 +35,7 @@ Requirements
------------
- Unity OE 4.0.1 or higher.
- StorOps 0.5.7 or higher is installed on Manila node.
- StorOps 1.1.0 or higher is installed on Manila node.
- Following licenses are activated on Unity:
* CIFS/SMB Support
@ -54,6 +54,7 @@ Storage Systems.
* Create/delete a NFS share.
* Create/delete a CIFS share.
* Extend the size of a share.
* Shrink the size of a share.
* Modify the host access privilege of a NFS share.
* Modify the user access privilege of a CIFS share.
* Take/Delete snapshot of a share.
@ -233,6 +234,7 @@ Following driver features are implemented in the plugin.
snapshot.
* delete_share: Delete a share.
* extend_share: Extend the maximum size of a share.
* shrink_share: Shrink the minimum size of a share.
* create_snapshot: Create a snapshot for the specified share.
* delete_snapshot: Delete the snapshot of the share.
* update_access: recover, add or delete user/host access to a share.

View File

@ -45,7 +45,7 @@ Mapping of share drivers and share features support
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC VNX | J | \- | \- | \- | J | J | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC Unity | N | \- | N | \- | N | N | \- | \- | \- |
| EMC Unity | N | \- | N | S | N | N | \- | S | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC Isilon | K | \- | M | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+

View File

@ -20,7 +20,7 @@ Requirements
- Unity OE 4.1.x or higher.
- StorOps 0.4.3 or higher is installed on Manila node.
- StorOps 1.1.0 or higher is installed on Manila node.
- Following licenses are activated on Unity:
@ -54,6 +54,8 @@ The following operations are supported:
- Extend a share.
- Shrink a share.
Supported network types
~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -86,6 +86,11 @@ class EMCShareDriver(driver.ShareDriver):
else:
self.revert_to_snap_support = False
if hasattr(self.plugin, 'shrink_share_support'):
self.shrink_share_support = self.plugin.shrink_share_support
else:
self.shrink_share_support = False
def create_share(self, context, share, share_server=None):
"""Is called to create share."""
location = self.plugin.create_share(context, share, share_server)
@ -104,6 +109,13 @@ class EMCShareDriver(driver.ShareDriver):
"""Is called to extend share."""
self.plugin.extend_share(share, new_size, share_server)
def shrink_share(self, share, new_size, share_server=None):
"""Is called to shrink share."""
if self.shrink_share_support:
self.plugin.shrink_share(share, new_size, share_server)
else:
raise NotImplementedError()
def create_snapshot(self, context, snapshot, share_server=None):
"""Is called to create snapshot."""
self.plugin.create_snapshot(context, snapshot, share_server)

View File

@ -303,6 +303,20 @@ class UnityClient(object):
'bytes.', {'id': fs.get_id(), 'size': size})
return size
def shrink_filesystem(self, share_id, fs, new_size_gb):
size = utils.gib_to_byte(new_size_gb)
try:
fs.shrink(size, user_cap=True)
except storops_ex.UnityNothingToModifyError:
LOG.debug('The size of the file system %(id)s is %(size)s '
'bytes.', {'id': fs.get_id(), 'size': size})
except storops_ex.UnityShareShrinkSizeTooSmallError:
LOG.error('The used size of the file system %(id)s is '
'bigger than input shrink size,'
'it may cause date loss.', {'id': fs.get_id()})
raise exception.ShareShrinkingPossibleDataLoss(share_id=share_id)
return size
@staticmethod
def _is_external_port(port_id):
return 'eth' in port_id or '_la' in port_id

View File

@ -36,7 +36,7 @@ from manila.share.drivers.dell_emc.plugins.unity import utils as unity_utils
from manila.share import utils as share_utils
from manila import utils
VERSION = "6.0.0"
VERSION = "6.1.0"
LOG = log.getLogger(__name__)
SUPPORTED_NETWORK_TYPES = (None, 'flat', 'vlan')
@ -87,6 +87,7 @@ class UnityStorageConnection(driver.StorageConnection):
self.port_ids_conf = None
self.ipv6_implemented = True
self.revert_to_snap_support = True
self.shrink_share_support = True
# props from super class.
self.driver_handles_share_servers = True
@ -269,6 +270,29 @@ class UnityStorageConnection(driver.StorageConnection):
raise exception.ShareExtendingError(share_id=share_id,
reason=reason)
def shrink_share(self, share, new_size, share_server=None):
"""Shrinks a share to new size.
:param share: Share that will be shrunk.
:param new_size: New size of share.
:param share_server: Data structure with share server information.
Not used by this driver.
"""
share_id = share['id']
backend_share = self.client.get_share(share_id,
share['share_proto'])
if self._is_share_from_snapshot(backend_share):
reason = ("Driver does not support shrinking a "
"snapshot based share.")
raise exception.ShareShrinkingError(share_id=share_id,
reason=reason)
self.client.shrink_filesystem(share_id, backend_share.filesystem,
new_size)
LOG.info("Share %(shr_id)s successfully shrunk to "
"%(shr_size)sG.",
{'shr_id': share_id,
'shr_size': new_size})
def create_snapshot(self, context, snapshot, share_server=None):
"""Create snapshot from share."""
share_name = snapshot['share_id']

View File

@ -70,6 +70,10 @@ class UnityNothingToModifyError(UnityException):
pass
class UnityShareShrinkSizeTooSmallError(UnityException):
pass
class UnityTenantNameInUseError(UnityException):
pass

View File

@ -188,6 +188,42 @@ nfs_share:
export_locations: []
is_public: False
shrink_cifs_share:
_type: 'share'
_properties: &shrink_cifs_share_prop
share_id: '708e753c-aacb-411f-9c8a-8b8175da4e73'
availability_zone_id: 'de628fb6-1c99-41f6-a06a-adb61ff693b5'
share_network_id: '232d8218-2743-41d1-832b-4194626e691e'
share_server_id: '78fd845f-8e7d-487f-bfde-051d83e78103'
id: '716100cc-e0b4-416b-ac27-d38dd019330d'
size: 9
user_id: '19bbda71b578471a93363653dcb4c61d'
status: 'creating'
share_type_id: '57679eab-3e67-4052-b180-62b609670e93'
host: 'openstack@VNX#Pool_2'
display_name: 'cifs_share'
share_proto: 'CIFS'
export_locations: []
is_public: False
shrink_nfs_share:
_type: 'share'
_properties: &shrink_nfs_share_prop
share_id: '12eb3777-7008-4721-8243-422507db8f9d'
availability_zone_id: 'de628fb6-1c99-41f6-a06a-adb61ff693b5'
share_network_id: '232d8218-2743-41d1-832b-4194626e691e'
share_server_id: '78fd845f-8e7d-487f-bfde-051d83e78103'
id: 'cb532599-8dc6-4c3e-bb21-74ea54be566c'
size: 9
user_id: '19bbda71b578471a93363653dcb4c61d'
status: 'creating'
share_type_id: '57679eab-3e67-4052-b180-62b609670e93'
host: 'openstack@VNX#Pool_2'
display_name: 'nfs_share'
share_proto: 'NFS'
export_locations: []
is_public: False
invalid_share:
_type: 'share'
_properties: &invalid_share_prop

View File

@ -419,6 +419,44 @@ test_extend_nfs_share:
<<: *unity_base_method
get_nfs_share: *cifs_share__test_extend_nfs_share
test_shrink_cifs_share:
filesystem: &filesystem__test_shrink_cifs_share
_properties: &filesystem_prop__test_shrink_cifs_share
<<: *filesystem_base_prop
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
_methods:
shrink:
cifs_share: &cifs_share__test_shrink_cifs_share
_properties:
<<: *cifs_share_base_prop
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
filesystem: *filesystem__test_shrink_cifs_share
unity:
_methods:
<<: *unity_base_method
get_cifs_share: *cifs_share__test_shrink_cifs_share
test_shrink_nfs_share:
filesystem: &filesystem__test_shrink_nfs_share
_properties: &filesystem_prop__test_shrink_nfs_share
<<: *filesystem_base_prop
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
_methods:
shrink:
cifs_share: &cifs_share__test_shrink_nfs_share
_properties:
<<: *cifs_share_base_prop
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
filesystem: *filesystem__test_shrink_nfs_share
unity:
_methods:
<<: *unity_base_method
get_nfs_share: *cifs_share__test_shrink_nfs_share
test_extend_share__create_from_snap:
snap: &snap__test_extend_share__create_from_snap
_properties: &snap_prop__test_extend_share__create_from_snap
@ -436,6 +474,23 @@ test_extend_share__create_from_snap:
<<: *unity_base_method
get_cifs_share: *cifs_share__test_extend_share__create_from_snap
test_shrink_share_create_from_snap:
snap: &snap__test_shrink_share_create_from_snap
_properties: &snap_prop__test_shrink_share__create_from_snap
<<: *snap_base_prop
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
cifs_share: &cifs_share__test_shrink_share__create_from_snap
_properties:
<<: *cifs_share_base_prop
name: '716100cc-e0b4-416b-ac27-d38dd019330d'
snap: *snap__test_shrink_share_create_from_snap
unity:
_methods:
<<: *unity_base_method
get_cifs_share: *cifs_share__test_shrink_share__create_from_snap
test_create_snapshot_from_filesystem:
filesystem: &filesystem__test_create_snapshot_from_filesystem
_properties: &filesystem_prop__test_create_snapshot_from_filesystem
@ -1063,6 +1118,22 @@ test_extend_filesystem:
_raise:
UnityNothingToModifyError:
test_shrink_filesystem:
fs:
_methods:
get_id: 'svc_11'
shrink:
_raise:
UnityNothingToModifyError:
test_shrink_filesystem_size_too_small:
fs:
_methods:
get_id: 'svc_10'
shrink:
_raise:
UnityShareShrinkSizeTooSmallError:
test_get_tenant:
unity:
_methods:

View File

@ -179,6 +179,23 @@ class TestClient(test.TestCase):
self.assertEqual(5 * units.Gi, size)
@res_mock.mock_client_input
@res_mock.patch_client
def test_shrink_filesystem(self, client, mocked_input):
fs = mocked_input['fs']
size = client.shrink_filesystem('fake_share_id_1', fs, 4)
self.assertEqual(4 * units.Gi, size)
@res_mock.mock_client_input
@res_mock.patch_client
def test_shrink_filesystem_size_too_small(self, client, mocked_input):
fs = mocked_input['fs']
self.assertRaises(exception.ShareShrinkingPossibleDataLoss,
client.shrink_filesystem, 'fake_share_id_2', fs, 4)
@res_mock.patch_client
def test_get_file_ports(self, client):
ports = client.get_file_ports()

View File

@ -175,6 +175,22 @@ class TestConnection(test.TestCase):
connection.delete_share(None, share, share_server)
@res_mock.mock_manila_input
@res_mock.patch_connection
def test_shrink_cifs_share(self, connection, mocked_input):
share = mocked_input['shrink_cifs_share']
new_size = 4 * units.Gi
connection.shrink_share(share, new_size)
@res_mock.mock_manila_input
@res_mock.patch_connection
def test_shrink_nfs_share(self, connection, mocked_input):
share = mocked_input['shrink_nfs_share']
new_size = 4 * units.Gi
connection.shrink_share(share, new_size)
@res_mock.mock_manila_input
@res_mock.patch_connection
def test_extend_cifs_share(self, connection, mocked_input):
@ -206,6 +222,19 @@ class TestConnection(test.TestCase):
new_size,
share_server)
@res_mock.mock_manila_input
@res_mock.patch_connection
def test_shrink_share_create_from_snap(self, connection, mocked_input):
share = mocked_input['shrink_cifs_share']
share_server = mocked_input['share_server']
new_size = 4 * units.Gi
self.assertRaises(exception.ShareShrinkingError,
connection.shrink_share,
share,
new_size,
share_server)
@res_mock.mock_manila_input
@res_mock.patch_connection
def test_create_snapshot_from_filesystem(self, connection, mocked_input):

View File

@ -43,6 +43,9 @@ class FakeConnection(base.StorageConnection):
def extend_share(self, share, new_size, share_server):
"""Is called to extend share."""
def shrink_share(self, share, new_size, share_server):
"""Is called to shrink share."""
def delete_snapshot(self, context, snapshot, share_server):
"""Is called to remove snapshot."""

View File

@ -0,0 +1,3 @@
---
features:
- Shrink share support has been added for Dell EMC Unity Manila driver.