Bug fix for revert to snapshot feature
Snapshot information should be retrieved from the snapshot API instead of retrieving volume's last_snap Closes-bug: #1918099 Change-Id: Iee7d2e8d935a806f92f3991a943a458f5b74ef48
This commit is contained in:
parent
a1f567e3b3
commit
77127e7d46
@ -167,6 +167,9 @@ FAKE_GET_VOL_INFO_REVERT = {'name': 'testvolume',
|
||||
'agent_type': 'openstack',
|
||||
'last_snap': {'snap_id': fake.SNAPSHOT_ID}}
|
||||
|
||||
FAKE_SNAP_INFO_REVERT = {'name': 'testsnap',
|
||||
'id': fake.SNAPSHOT2_ID}
|
||||
|
||||
FAKE_CREATE_VOLUME_NEGATIVE_RESPONSE = exception.VolumeBackendAPIException(
|
||||
"Volume testvolume not found")
|
||||
|
||||
@ -1274,17 +1277,20 @@ class NimbleDriverSnapshotTestCase(NimbleDriverBaseTestCase):
|
||||
FAKE_GET_VOL_INFO_REVERT)
|
||||
self.mock_client_service.get_netconfig.return_value = (
|
||||
FAKE_POSITIVE_NETCONFIG_RESPONSE)
|
||||
self.mock_client_service.get_snap_info.return_value = (
|
||||
FAKE_SNAP_INFO_REVERT)
|
||||
ctx = context.get_admin_context()
|
||||
self.driver.revert_to_snapshot(ctx,
|
||||
{'id': fake.VOLUME_ID,
|
||||
'size': 1,
|
||||
'name': 'testvolume'},
|
||||
{'id': fake.SNAPSHOT_ID,
|
||||
{'id': fake.SNAPSHOT2_ID,
|
||||
'name': 'testsnap',
|
||||
'volume_id': fake.VOLUME_ID})
|
||||
expected_calls = [mock.call.online_vol('testvolume', False),
|
||||
mock.call.volume_restore('testvolume',
|
||||
{'data': {'id': fake.VOLUME_ID,
|
||||
'base_snap_id': fake.SNAPSHOT_ID}}),
|
||||
'base_snap_id': fake.SNAPSHOT2_ID}}),
|
||||
mock.call.online_vol('testvolume', True)]
|
||||
self.mock_client_service.assert_has_calls(expected_calls)
|
||||
|
||||
@ -1301,6 +1307,8 @@ class NimbleDriverSnapshotTestCase(NimbleDriverBaseTestCase):
|
||||
FAKE_GET_VOL_INFO_REVERT)
|
||||
self.mock_client_service.get_netconfig.return_value = (
|
||||
FAKE_POSITIVE_NETCONFIG_RESPONSE)
|
||||
self.mock_client_service.get_snap_info.return_value = (
|
||||
FAKE_SNAP_INFO_REVERT)
|
||||
ctx = context.get_admin_context()
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.revert_to_snapshot, ctx,
|
||||
@ -1308,6 +1316,7 @@ class NimbleDriverSnapshotTestCase(NimbleDriverBaseTestCase):
|
||||
'size': 1,
|
||||
'name': 'testvolume'},
|
||||
{'id': fake.SNAPSHOT_ID,
|
||||
'name': 'testsnap',
|
||||
'volume_id': fake.VOLUME_ID})
|
||||
|
||||
|
||||
|
@ -755,7 +755,9 @@ class NimbleBaseVolumeDriver(san.SanDriver):
|
||||
|
||||
def revert_to_snapshot(self, context, volume, snapshot):
|
||||
vol_info = self.APIExecutor.get_vol_info(volume['name'])
|
||||
snap_id = vol_info['last_snap']['snap_id']
|
||||
snap_info = self.APIExecutor.get_snap_info(snapshot['name'],
|
||||
volume['name'])
|
||||
snap_id = snap_info['id']
|
||||
volume_id = vol_info['id']
|
||||
LOG.debug("Reverting volume %(vol)s with snapshot id %(snap_id)s",
|
||||
{'vol': volume['name'], 'snap_id': snap_id})
|
||||
|
6
releasenotes/notes/1918099-18b26dd9107f19c0.yaml
Normal file
6
releasenotes/notes/1918099-18b26dd9107f19c0.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Nimble driver `bug #1918099
|
||||
<https://bugs.launchpad.net/cinder/+bug/1918099>`_: Fix
|
||||
revert to snapshot not working as expected.
|
Loading…
Reference in New Issue
Block a user