summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYong Huang <yong.huang@emc.com>2019-01-13 20:16:43 -0500
committerYong Huang <yong.huang@emc.com>2019-01-16 15:20:47 -0500
commite4156ddb08a592c3f370247f51320e10ecd02da2 (patch)
tree598acd74503ed372ffc2cf71a5e5f9672ba9c82e
parent8f88779778f76df32d43d321b45a1ba37613c514 (diff)
[Unity] Revert to snapshot supportHEADmaster
Implement revert to snapshot support for Dell EMC Unity driver. Change-Id: I3a4da4a506ae4c2dbcd97207121ce19ecfb98043 Implements: unity-revert-to-snapshot
Notes
Notes (review): Code-Review+1: Ryan Liang <ryan.liang@emc.com> Code-Review+1: Yongjun Bai <baiyj666@gmail.com> Code-Review+2: Tom Barron <tpb@dyncloud.net> Code-Review+2: Amit Oren <aoren@infinidat.com> Workflow+1: Amit Oren <aoren@infinidat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 17 Jan 2019 11:15:19 +0000 Reviewed-on: https://review.openstack.org/630630 Project: openstack/manila Branch: refs/heads/master
-rw-r--r--manila/share/drivers/dell_emc/driver.py18
-rw-r--r--manila/share/drivers/dell_emc/plugins/unity/client.py4
-rw-r--r--manila/share/drivers/dell_emc/plugins/unity/connection.py8
-rw-r--r--manila/tests/share/drivers/dell_emc/plugins/unity/mocked_unity.yaml24
-rw-r--r--manila/tests/share/drivers/dell_emc/plugins/unity/test_client.py12
-rw-r--r--manila/tests/share/drivers/dell_emc/plugins/unity/test_connection.py12
-rw-r--r--releasenotes/notes/unity-revert-to-snapshot-support-1cffc3914982003d.yaml3
7 files changed, 78 insertions, 3 deletions
diff --git a/manila/share/drivers/dell_emc/driver.py b/manila/share/drivers/dell_emc/driver.py
index 46d684e..a149c08 100644
--- a/manila/share/drivers/dell_emc/driver.py
+++ b/manila/share/drivers/dell_emc/driver.py
@@ -81,6 +81,11 @@ class EMCShareDriver(driver.ShareDriver):
81 if hasattr(self.plugin, 'ipv6_implemented'): 81 if hasattr(self.plugin, 'ipv6_implemented'):
82 self.ipv6_implemented = self.plugin.ipv6_implemented 82 self.ipv6_implemented = self.plugin.ipv6_implemented
83 83
84 if hasattr(self.plugin, 'revert_to_snap_support'):
85 self.revert_to_snap_support = self.plugin.revert_to_snap_support
86 else:
87 self.revert_to_snap_support = False
88
84 def create_share(self, context, share, share_server=None): 89 def create_share(self, context, share, share_server=None):
85 """Is called to create share.""" 90 """Is called to create share."""
86 location = self.plugin.create_share(context, share, share_server) 91 location = self.plugin.create_share(context, share, share_server)
@@ -147,7 +152,8 @@ class EMCShareDriver(driver.ShareDriver):
147 vendor_name='Dell EMC', 152 vendor_name='Dell EMC',
148 storage_protocol='NFS_CIFS', 153 storage_protocol='NFS_CIFS',
149 snapshot_support=True, 154 snapshot_support=True,
150 create_share_from_snapshot_support=True) 155 create_share_from_snapshot_support=True,
156 revert_to_snapshot_support=self.revert_to_snap_support)
151 self.plugin.update_share_stats(data) 157 self.plugin.update_share_stats(data)
152 super(EMCShareDriver, self)._update_share_stats(data) 158 super(EMCShareDriver, self)._update_share_stats(data)
153 159
@@ -168,3 +174,13 @@ class EMCShareDriver(driver.ShareDriver):
168 return [4, 6] 174 return [4, 6]
169 else: 175 else:
170 return [4] 176 return [4]
177
178 def revert_to_snapshot(self, context, snapshot, share_access_rules,
179 snapshot_access_rules, share_server=None):
180 if self.revert_to_snap_support:
181 return self.plugin.revert_to_snapshot(context, snapshot,
182 share_access_rules,
183 snapshot_access_rules,
184 share_server)
185 else:
186 raise NotImplementedError()
diff --git a/manila/share/drivers/dell_emc/plugins/unity/client.py b/manila/share/drivers/dell_emc/plugins/unity/client.py
index 753d9a4..8613505 100644
--- a/manila/share/drivers/dell_emc/plugins/unity/client.py
+++ b/manila/share/drivers/dell_emc/plugins/unity/client.py
@@ -330,3 +330,7 @@ class UnityClient(object):
330 LOG.info("This system doesn't support tenant.") 330 LOG.info("This system doesn't support tenant.")
331 331
332 return tenant 332 return tenant
333
334 def restore_snapshot(self, snap_name):
335 snap = self.get_snapshot(snap_name)
336 return snap.restore(delete_backup=True)
diff --git a/manila/share/drivers/dell_emc/plugins/unity/connection.py b/manila/share/drivers/dell_emc/plugins/unity/connection.py
index 2dd93df..b7b53ec 100644
--- a/manila/share/drivers/dell_emc/plugins/unity/connection.py
+++ b/manila/share/drivers/dell_emc/plugins/unity/connection.py
@@ -36,7 +36,7 @@ from manila.share.drivers.dell_emc.plugins.unity import utils as unity_utils
36from manila.share import utils as share_utils 36from manila.share import utils as share_utils
37from manila import utils 37from manila import utils
38 38
39VERSION = "4.0.0" 39VERSION = "6.0.0"
40 40
41LOG = log.getLogger(__name__) 41LOG = log.getLogger(__name__)
42SUPPORTED_NETWORK_TYPES = (None, 'flat', 'vlan') 42SUPPORTED_NETWORK_TYPES = (None, 'flat', 'vlan')
@@ -86,6 +86,7 @@ class UnityStorageConnection(driver.StorageConnection):
86 self.max_over_subscription_ratio = None 86 self.max_over_subscription_ratio = None
87 self.port_ids_conf = None 87 self.port_ids_conf = None
88 self.ipv6_implemented = True 88 self.ipv6_implemented = True
89 self.revert_to_snap_support = True
89 90
90 # props from super class. 91 # props from super class.
91 self.driver_handles_share_servers = True 92 self.driver_handles_share_servers = True
@@ -678,3 +679,8 @@ class UnityStorageConnection(driver.StorageConnection):
678 raise exception.InvalidShare( 679 raise exception.InvalidShare(
679 reason=(_('Invalid NAS protocol supplied: %s.') % 680 reason=(_('Invalid NAS protocol supplied: %s.') %
680 share_proto)) 681 share_proto))
682
683 def revert_to_snapshot(self, context, snapshot, share_access_rules,
684 snapshot_access_rules, share_server=None):
685 """Reverts a share (in place) to the specified snapshot."""
686 return self.client.restore_snapshot(snapshot['id'])
diff --git a/manila/tests/share/drivers/dell_emc/plugins/unity/mocked_unity.yaml b/manila/tests/share/drivers/dell_emc/plugins/unity/mocked_unity.yaml
index 69ef556..d156ff5 100644
--- a/manila/tests/share/drivers/dell_emc/plugins/unity/mocked_unity.yaml
+++ b/manila/tests/share/drivers/dell_emc/plugins/unity/mocked_unity.yaml
@@ -173,6 +173,13 @@ tenant_1: &tenant_1
173 uuid: "173ca6c3-5952-427d-82a6-df88f49e3926" 173 uuid: "173ca6c3-5952-427d-82a6-df88f49e3926"
174 vlans: [2] 174 vlans: [2]
175 175
176snapshot_1: &snapshot_1
177 _properties:
178 id: "snapshot_1"
179 name: "Snapshot_1"
180 _methods:
181 restore: True
182
176unity_base: &unity_base 183unity_base: &unity_base
177 _methods: &unity_base_method 184 _methods: &unity_base_method
178 get_sp: *sp_a 185 get_sp: *sp_a
@@ -1102,3 +1109,20 @@ test_create_file_interface_ipv6:
1102 nas_server: 1109 nas_server:
1103 _methods: 1110 _methods:
1104 create_file_interface: 1111 create_file_interface:
1112
1113test_get_snapshot:
1114 unity:
1115 _methods:
1116 get_snap: *snapshot_1
1117
1118test_get_snapshot_nonexistent_expt:
1119 unity:
1120 _methods:
1121 get_snap:
1122 _raise:
1123 UnityResourceNotFoundError:
1124
1125test_restore_snapshot:
1126 unity:
1127 _methods:
1128 get_snap: *snapshot_1
diff --git a/manila/tests/share/drivers/dell_emc/plugins/unity/test_client.py b/manila/tests/share/drivers/dell_emc/plugins/unity/test_client.py
index 3603db1..251e976 100644
--- a/manila/tests/share/drivers/dell_emc/plugins/unity/test_client.py
+++ b/manila/tests/share/drivers/dell_emc/plugins/unity/test_client.py
@@ -231,3 +231,15 @@ class TestClient(test.TestCase):
231 v6_prefix_length=mock_file_interface.prefix_length, 231 v6_prefix_length=mock_file_interface.prefix_length,
232 gateway=mock_file_interface.gateway, 232 gateway=mock_file_interface.gateway,
233 vlan_id=mock_file_interface.vlan_id) 233 vlan_id=mock_file_interface.vlan_id)
234
235 @res_mock.patch_client
236 def test_get_snapshot(self, client):
237 snapshot = client.get_snapshot('Snapshot_1')
238 self.assertEqual('snapshot_1', snapshot.id)
239
240 @res_mock.patch_client
241 def test_restore_snapshot(self, client):
242 snapshot = client.get_snapshot('Snapshot_1')
243 rst = client.restore_snapshot(snapshot.name)
244 self.assertIs(True, rst)
245 snapshot.restore.assert_called_once_with(delete_backup=True)
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 a94b21b..0ac3de9 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
@@ -414,7 +414,6 @@ class TestConnection(test.TestCase):
414 414
415 @res_mock.patch_connection 415 @res_mock.patch_connection
416 def test_validate_port_configuration_exception(self, connection): 416 def test_validate_port_configuration_exception(self, connection):
417
418 self.assertRaises(exception.BadConfigurationException, 417 self.assertRaises(exception.BadConfigurationException,
419 connection.validate_port_configuration, 418 connection.validate_port_configuration,
420 ['xxxx*']) 419 ['xxxx*'])
@@ -653,3 +652,14 @@ class TestConnection(test.TestCase):
653 'vlan_id': '201'} 652 'vlan_id': '201'}
654 connection.client.create_interface.assert_called_once_with(nas_server, 653 connection.client.create_interface.assert_called_once_with(nas_server,
655 **expected) 654 **expected)
655
656 @res_mock.mock_manila_input
657 @res_mock.patch_connection
658 def test_revert_to_snapshot(self, connection, mocked_input):
659 context = mock.Mock()
660 snapshot = mocked_input['snapshot']
661 share_access_rules = [mocked_input['nfs_rw_access'], ]
662 snapshot_access_rules = [mocked_input['nfs_rw_access'], ]
663
664 connection.revert_to_snapshot(context, snapshot, share_access_rules,
665 snapshot_access_rules)
diff --git a/releasenotes/notes/unity-revert-to-snapshot-support-1cffc3914982003d.yaml b/releasenotes/notes/unity-revert-to-snapshot-support-1cffc3914982003d.yaml
new file mode 100644
index 0000000..cc2561b
--- /dev/null
+++ b/releasenotes/notes/unity-revert-to-snapshot-support-1cffc3914982003d.yaml
@@ -0,0 +1,3 @@
1---
2features:
3 - Revert to snapshot support for Dell EMC Unity Manila driver.