[Unity] Revert to snapshot support
Implement revert to snapshot support for Dell EMC Unity driver. Change-Id: I3a4da4a506ae4c2dbcd97207121ce19ecfb98043 Implements: unity-revert-to-snapshot
This commit is contained in:
@@ -81,6 +81,11 @@ class EMCShareDriver(driver.ShareDriver):
|
|||||||
if hasattr(self.plugin, 'ipv6_implemented'):
|
if hasattr(self.plugin, 'ipv6_implemented'):
|
||||||
self.ipv6_implemented = self.plugin.ipv6_implemented
|
self.ipv6_implemented = self.plugin.ipv6_implemented
|
||||||
|
|
||||||
|
if hasattr(self.plugin, 'revert_to_snap_support'):
|
||||||
|
self.revert_to_snap_support = self.plugin.revert_to_snap_support
|
||||||
|
else:
|
||||||
|
self.revert_to_snap_support = False
|
||||||
|
|
||||||
def create_share(self, context, share, share_server=None):
|
def create_share(self, context, share, share_server=None):
|
||||||
"""Is called to create share."""
|
"""Is called to create share."""
|
||||||
location = self.plugin.create_share(context, share, share_server)
|
location = self.plugin.create_share(context, share, share_server)
|
||||||
@@ -147,7 +152,8 @@ class EMCShareDriver(driver.ShareDriver):
|
|||||||
vendor_name='Dell EMC',
|
vendor_name='Dell EMC',
|
||||||
storage_protocol='NFS_CIFS',
|
storage_protocol='NFS_CIFS',
|
||||||
snapshot_support=True,
|
snapshot_support=True,
|
||||||
create_share_from_snapshot_support=True)
|
create_share_from_snapshot_support=True,
|
||||||
|
revert_to_snapshot_support=self.revert_to_snap_support)
|
||||||
self.plugin.update_share_stats(data)
|
self.plugin.update_share_stats(data)
|
||||||
super(EMCShareDriver, self)._update_share_stats(data)
|
super(EMCShareDriver, self)._update_share_stats(data)
|
||||||
|
|
||||||
@@ -168,3 +174,13 @@ class EMCShareDriver(driver.ShareDriver):
|
|||||||
return [4, 6]
|
return [4, 6]
|
||||||
else:
|
else:
|
||||||
return [4]
|
return [4]
|
||||||
|
|
||||||
|
def revert_to_snapshot(self, context, snapshot, share_access_rules,
|
||||||
|
snapshot_access_rules, share_server=None):
|
||||||
|
if self.revert_to_snap_support:
|
||||||
|
return self.plugin.revert_to_snapshot(context, snapshot,
|
||||||
|
share_access_rules,
|
||||||
|
snapshot_access_rules,
|
||||||
|
share_server)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|||||||
@@ -330,3 +330,7 @@ class UnityClient(object):
|
|||||||
LOG.info("This system doesn't support tenant.")
|
LOG.info("This system doesn't support tenant.")
|
||||||
|
|
||||||
return tenant
|
return tenant
|
||||||
|
|
||||||
|
def restore_snapshot(self, snap_name):
|
||||||
|
snap = self.get_snapshot(snap_name)
|
||||||
|
return snap.restore(delete_backup=True)
|
||||||
|
|||||||
@@ -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.share import utils as share_utils
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
VERSION = "4.0.0"
|
VERSION = "6.0.0"
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
SUPPORTED_NETWORK_TYPES = (None, 'flat', 'vlan')
|
SUPPORTED_NETWORK_TYPES = (None, 'flat', 'vlan')
|
||||||
@@ -86,6 +86,7 @@ class UnityStorageConnection(driver.StorageConnection):
|
|||||||
self.max_over_subscription_ratio = None
|
self.max_over_subscription_ratio = None
|
||||||
self.port_ids_conf = None
|
self.port_ids_conf = None
|
||||||
self.ipv6_implemented = True
|
self.ipv6_implemented = True
|
||||||
|
self.revert_to_snap_support = True
|
||||||
|
|
||||||
# props from super class.
|
# props from super class.
|
||||||
self.driver_handles_share_servers = True
|
self.driver_handles_share_servers = True
|
||||||
@@ -678,3 +679,8 @@ class UnityStorageConnection(driver.StorageConnection):
|
|||||||
raise exception.InvalidShare(
|
raise exception.InvalidShare(
|
||||||
reason=(_('Invalid NAS protocol supplied: %s.') %
|
reason=(_('Invalid NAS protocol supplied: %s.') %
|
||||||
share_proto))
|
share_proto))
|
||||||
|
|
||||||
|
def revert_to_snapshot(self, context, snapshot, share_access_rules,
|
||||||
|
snapshot_access_rules, share_server=None):
|
||||||
|
"""Reverts a share (in place) to the specified snapshot."""
|
||||||
|
return self.client.restore_snapshot(snapshot['id'])
|
||||||
|
|||||||
@@ -173,6 +173,13 @@ tenant_1: &tenant_1
|
|||||||
uuid: "173ca6c3-5952-427d-82a6-df88f49e3926"
|
uuid: "173ca6c3-5952-427d-82a6-df88f49e3926"
|
||||||
vlans: [2]
|
vlans: [2]
|
||||||
|
|
||||||
|
snapshot_1: &snapshot_1
|
||||||
|
_properties:
|
||||||
|
id: "snapshot_1"
|
||||||
|
name: "Snapshot_1"
|
||||||
|
_methods:
|
||||||
|
restore: True
|
||||||
|
|
||||||
unity_base: &unity_base
|
unity_base: &unity_base
|
||||||
_methods: &unity_base_method
|
_methods: &unity_base_method
|
||||||
get_sp: *sp_a
|
get_sp: *sp_a
|
||||||
@@ -1102,3 +1109,20 @@ test_create_file_interface_ipv6:
|
|||||||
nas_server:
|
nas_server:
|
||||||
_methods:
|
_methods:
|
||||||
create_file_interface:
|
create_file_interface:
|
||||||
|
|
||||||
|
test_get_snapshot:
|
||||||
|
unity:
|
||||||
|
_methods:
|
||||||
|
get_snap: *snapshot_1
|
||||||
|
|
||||||
|
test_get_snapshot_nonexistent_expt:
|
||||||
|
unity:
|
||||||
|
_methods:
|
||||||
|
get_snap:
|
||||||
|
_raise:
|
||||||
|
UnityResourceNotFoundError:
|
||||||
|
|
||||||
|
test_restore_snapshot:
|
||||||
|
unity:
|
||||||
|
_methods:
|
||||||
|
get_snap: *snapshot_1
|
||||||
|
|||||||
@@ -231,3 +231,15 @@ class TestClient(test.TestCase):
|
|||||||
v6_prefix_length=mock_file_interface.prefix_length,
|
v6_prefix_length=mock_file_interface.prefix_length,
|
||||||
gateway=mock_file_interface.gateway,
|
gateway=mock_file_interface.gateway,
|
||||||
vlan_id=mock_file_interface.vlan_id)
|
vlan_id=mock_file_interface.vlan_id)
|
||||||
|
|
||||||
|
@res_mock.patch_client
|
||||||
|
def test_get_snapshot(self, client):
|
||||||
|
snapshot = client.get_snapshot('Snapshot_1')
|
||||||
|
self.assertEqual('snapshot_1', snapshot.id)
|
||||||
|
|
||||||
|
@res_mock.patch_client
|
||||||
|
def test_restore_snapshot(self, client):
|
||||||
|
snapshot = client.get_snapshot('Snapshot_1')
|
||||||
|
rst = client.restore_snapshot(snapshot.name)
|
||||||
|
self.assertIs(True, rst)
|
||||||
|
snapshot.restore.assert_called_once_with(delete_backup=True)
|
||||||
|
|||||||
@@ -414,7 +414,6 @@ class TestConnection(test.TestCase):
|
|||||||
|
|
||||||
@res_mock.patch_connection
|
@res_mock.patch_connection
|
||||||
def test_validate_port_configuration_exception(self, connection):
|
def test_validate_port_configuration_exception(self, connection):
|
||||||
|
|
||||||
self.assertRaises(exception.BadConfigurationException,
|
self.assertRaises(exception.BadConfigurationException,
|
||||||
connection.validate_port_configuration,
|
connection.validate_port_configuration,
|
||||||
['xxxx*'])
|
['xxxx*'])
|
||||||
@@ -653,3 +652,14 @@ class TestConnection(test.TestCase):
|
|||||||
'vlan_id': '201'}
|
'vlan_id': '201'}
|
||||||
connection.client.create_interface.assert_called_once_with(nas_server,
|
connection.client.create_interface.assert_called_once_with(nas_server,
|
||||||
**expected)
|
**expected)
|
||||||
|
|
||||||
|
@res_mock.mock_manila_input
|
||||||
|
@res_mock.patch_connection
|
||||||
|
def test_revert_to_snapshot(self, connection, mocked_input):
|
||||||
|
context = mock.Mock()
|
||||||
|
snapshot = mocked_input['snapshot']
|
||||||
|
share_access_rules = [mocked_input['nfs_rw_access'], ]
|
||||||
|
snapshot_access_rules = [mocked_input['nfs_rw_access'], ]
|
||||||
|
|
||||||
|
connection.revert_to_snapshot(context, snapshot, share_access_rules,
|
||||||
|
snapshot_access_rules)
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Revert to snapshot support for Dell EMC Unity Manila driver.
|
||||||
Reference in New Issue
Block a user