Merge "[VNX] Restore snapshot to volume"

This commit is contained in:
Zuul 2018-03-23 01:07:30 +00:00 committed by Gerrit Code Review
commit db4c31faef
10 changed files with 48 additions and 2 deletions

View File

@ -207,6 +207,10 @@ test_create_snapshot_adapter:
test_delete_snapshot_adapter:
snapshot: *snapshot_base
test_restore_snapshot_adapter:
volume: *volume_base
snapshot: *snapshot_base
test_do_create_cgsnap: &cg_snap_and_snaps
cg_snap: *cg_snapshot_base
snap1: *snapshot_base

View File

@ -696,6 +696,15 @@ test_modify_snapshot:
_methods:
get_snap: *snap_modify
test_restore_snapshot: &test_restore_snapshot
lun: &lun_restore
_methods:
restore_snap:
vnx:
_methods:
get_lun: *lun_restore
test_create_cg_snapshot: &test_create_cg_snapshot
cg_snap: &cg_snap_exist
_properties:
@ -1614,6 +1623,8 @@ test_create_snapshot_adapter: *test_create_snapshot
test_delete_snapshot_adapter: *test_delete_snapshot
test_restore_snapshot_adapter: *test_restore_snapshot
test_create_cgsnapshot: *test_create_cg_snapshot
test_do_create_cgsnap: *test_create_cg_snapshot

View File

@ -619,6 +619,13 @@ class TestCommonAdapter(test.TestCase):
mocked_input):
common_adapter.delete_snapshot(mocked_input['snapshot'])
@res_mock.mock_driver_input
@res_mock.patch_common_adapter
def test_restore_snapshot_adapter(self, common_adapter, _ignore,
mocked_input):
common_adapter.restore_snapshot(mocked_input['volume'],
mocked_input['snapshot'])
@res_mock.patch_common_adapter
def test_create_cgsnapshot(self, common_adapter, _):
common_adapter.do_create_cgsnap = mock.Mock(

View File

@ -309,6 +309,10 @@ class TestClient(test.TestCase):
def test_modify_snapshot(self, client, mocked):
client.modify_snapshot('snap_name', True, True)
@res_mock.patch_client
def test_restore_snapshot(self, client, mocked):
client.restore_snapshot('lun-id', 'snap_name')
@res_mock.patch_client
def test_create_cg_snapshot(self, client, mocked):
snap = client.create_cg_snapshot('cg_snap_name', 'cg_name')

View File

@ -811,6 +811,11 @@ class CommonAdapter(replication.ReplicationAdapter):
"""Deletes a snapshot."""
self.client.delete_snapshot(snapshot.name)
def restore_snapshot(self, volume, snapshot):
"""Restores a snapshot."""
lun_id = self.client.get_lun_id(volume)
self.client.restore_snapshot(lun_id, snapshot.name)
def _get_referenced_lun(self, existing_ref):
lun = None
if 'source-id' in existing_ref:

View File

@ -337,6 +337,10 @@ class Client(object):
snap.modify(allow_rw=allow_rw, auto_delete=auto_delete,
keep_for=None)
def restore_snapshot(self, lun_id, snap_name):
lun = self.get_lun(lun_id=lun_id)
lun.restore_snap(snap_name)
def create_consistency_group(self, cg_name, lun_id_list=None):
try:
cg = self.vnx.create_cg(name=cg_name, members=lun_id_list)

View File

@ -77,9 +77,10 @@ class VNXDriver(driver.ManageableVD,
10.1.0 - Add QoS support
10.2.0 - Add replication group support
11.0.0 - Fix failure of migration during cloning
12.0.0 - Add `volume revert to snapshot` support
"""
VERSION = '11.00.00'
VERSION = '12.00.00'
VENDOR = 'Dell EMC'
# ThirdPartySystems wiki page
CI_WIKI_NAME = "EMC_VNX_CI"
@ -141,6 +142,10 @@ class VNXDriver(driver.ManageableVD,
"""Deletes a snapshot."""
self.adapter.delete_snapshot(snapshot)
def revert_to_snapshot(self, context, volume, snapshot):
"""Reverts a volume to a snapshot"""
self.adapter.restore_snapshot(volume, snapshot)
def ensure_export(self, context, volume):
"""Driver entry point to get the export info for an existing volume."""
pass

View File

@ -39,6 +39,7 @@ Supported operations
- Create a consistency group from consistency group snapshots.
- Replication v2.1 support.
- Generic Group support.
- Revert a volume to a snapshot.
Preparation
~~~~~~~~~~~

View File

@ -32,7 +32,7 @@ rados # LGPLv2.1
rbd # LGPLv2.1
# Dell EMC VNX
storops>=0.4.8 # Apache-2.0
storops>=0.5.7 # Apache-2.0
# Violin
vmemclient>=1.1.8 # Apache-2.0

View File

@ -0,0 +1,5 @@
---
features:
- |
Added support to revert a volume to a snapshot with the Dell EMC VNX
driver.