Trivial fixes to snapshot revert patch
A few late-breaking comments [1] didn't make it into the revert-to-snapshot patch before it merged. This patch implements those. [1] https://review.openstack.org/#/c/340502/44 TrivialFix Change-Id: Icea22e5381b0403d623abce504f04ae3c6b77664
This commit is contained in:
parent
d4a379d083
commit
fa910aa531
|
@ -84,7 +84,6 @@ REST_API_VERSION_HISTORY = """
|
||||||
spec. Also made the 'snapshot_support' extra spec optional.
|
spec. Also made the 'snapshot_support' extra spec optional.
|
||||||
* 2.25 - Added quota-show detail API.
|
* 2.25 - Added quota-show detail API.
|
||||||
* 2.26 - Removed 'nova_net_id' parameter from share_network API.
|
* 2.26 - Removed 'nova_net_id' parameter from share_network API.
|
||||||
|
|
||||||
* 2.27 - Added share revert to snapshot API.
|
* 2.27 - Added share revert to snapshot API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ class ShareController(shares.ShareMixin,
|
||||||
msg = _LI('Reverting share %(share_id)s to snapshot %(snap_id)s.')
|
msg = _LI('Reverting share %(share_id)s to snapshot %(snap_id)s.')
|
||||||
LOG.info(msg, msg_args)
|
LOG.info(msg, msg_args)
|
||||||
|
|
||||||
self.share_api.revert_to_snapshot(context, snapshot)
|
self.share_api.revert_to_snapshot(context, share, snapshot)
|
||||||
except exception.ShareNotFound as e:
|
except exception.ShareNotFound as e:
|
||||||
raise exc.HTTPNotFound(explanation=six.text_type(e))
|
raise exc.HTTPNotFound(explanation=six.text_type(e))
|
||||||
except exception.ShareSnapshotNotFound as e:
|
except exception.ShareSnapshotNotFound as e:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"""add_revert_to_snapshot_support
|
"""add_revert_to_snapshot_support
|
||||||
|
|
||||||
Revision ID: 87ce15c59bbe
|
Revision ID: 87ce15c59bbe
|
||||||
Revises: 3e7d62517afa
|
Revises: 95e3cf760840
|
||||||
Create Date: 2016-08-18 00:12:34.587018
|
Create Date: 2016-08-18 00:12:34.587018
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -729,10 +729,9 @@ class API(base.Base):
|
||||||
|
|
||||||
self.share_rpcapi.unmanage_snapshot(context, snapshot_ref, host)
|
self.share_rpcapi.unmanage_snapshot(context, snapshot_ref, host)
|
||||||
|
|
||||||
def revert_to_snapshot(self, context, snapshot):
|
def revert_to_snapshot(self, context, share, snapshot):
|
||||||
"""Revert a share to a snapshot."""
|
"""Revert a share to a snapshot."""
|
||||||
|
|
||||||
share = self.db.share_get(context, snapshot['share_id'])
|
|
||||||
reservations = self._handle_revert_to_snapshot_quotas(
|
reservations = self._handle_revert_to_snapshot_quotas(
|
||||||
context, share, snapshot)
|
context, share, snapshot)
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ class ShareAPITest(test.TestCase):
|
||||||
mock_get_latest_snapshot_for_share.assert_called_once_with(
|
mock_get_latest_snapshot_for_share.assert_called_once_with(
|
||||||
utils.IsAMatcher(context.RequestContext), '1')
|
utils.IsAMatcher(context.RequestContext), '1')
|
||||||
mock_revert_to_snapshot.assert_called_once_with(
|
mock_revert_to_snapshot.assert_called_once_with(
|
||||||
utils.IsAMatcher(context.RequestContext), snapshot)
|
utils.IsAMatcher(context.RequestContext), share, snapshot)
|
||||||
|
|
||||||
def test__revert_not_supported(self):
|
def test__revert_not_supported(self):
|
||||||
|
|
||||||
|
|
|
@ -1163,7 +1163,7 @@ class ShareAPITestCase(test.TestCase):
|
||||||
self.api, '_revert_to_snapshot')
|
self.api, '_revert_to_snapshot')
|
||||||
snapshot = fakes.fake_snapshot(share_id=share['id'])
|
snapshot = fakes.fake_snapshot(share_id=share['id'])
|
||||||
|
|
||||||
self.api.revert_to_snapshot(self.context, snapshot)
|
self.api.revert_to_snapshot(self.context, share, snapshot)
|
||||||
|
|
||||||
mock_handle_revert_to_snapshot_quotas.assert_called_once_with(
|
mock_handle_revert_to_snapshot_quotas.assert_called_once_with(
|
||||||
self.context, share, snapshot)
|
self.context, share, snapshot)
|
||||||
|
@ -1195,6 +1195,7 @@ class ShareAPITestCase(test.TestCase):
|
||||||
self.assertRaises(exception.ReplicationException,
|
self.assertRaises(exception.ReplicationException,
|
||||||
self.api.revert_to_snapshot,
|
self.api.revert_to_snapshot,
|
||||||
self.context,
|
self.context,
|
||||||
|
share,
|
||||||
snapshot)
|
snapshot)
|
||||||
|
|
||||||
if reservations is not None:
|
if reservations is not None:
|
||||||
|
|
Loading…
Reference in New Issue