NetApp SolidFire: Fix CG snapshot deletion

This adds a function missing on the driver that was making impossible
to delete a consistency group snapshot.

Change-Id: I4d6a4f5cf4f4f0f751e1378d3747d2aacc050d24
Closes-bug: #1788418
Closes-bug: #1777862
(cherry picked from commit 8d9090700e)
(cherry picked from commit fb69816509)
(cherry picked from commit e201d5fcb5)
This commit is contained in:
Erlon R. Cruz
2018-08-22 10:48:59 -03:00
parent 3cbe705825
commit fcae2f086f
3 changed files with 45 additions and 2 deletions

View File

@@ -25,6 +25,8 @@ from cinder import context
from cinder import exception
from cinder.objects import fields
from cinder import test
from cinder.tests.unit import fake_group_snapshot
from cinder.tests.unit import fake_snapshot
from cinder.tests.unit.image import fake as fake_image
from cinder.tests.unit import utils as test_utils
from cinder.volume import configuration as conf
@@ -1812,8 +1814,8 @@ class SolidFireVolumeTestCase(test.TestCase):
source = {'group_snapshot_id': 'typical_cgsnap_id',
'volume_id': 'typical_vol_id',
'id': 'no_id_4_u'}
name = (self.configuration.sf_volume_prefix
+ source.get('group_snapshot_id'))
name = (self.configuration.sf_volume_prefix +
source.get('group_snapshot_id'))
with mock.patch.object(sfv,
'_get_group_snapshot_by_name',
return_value={}) as get,\
@@ -1834,6 +1836,36 @@ class SolidFireVolumeTestCase(test.TestCase):
{'status': fields.GroupStatus.AVAILABLE})
group_cg_test.assert_called_once_with(group)
@mock.patch('cinder.volume.utils.is_group_a_cg_snapshot_type')
def test_delete_group_snap_cg(self, group_cg_test):
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
group_cg_test.return_value = True
cgsnapshot = fake_group_snapshot.fake_group_snapshot_obj(
mock.MagicMock())
snapshots = fake_snapshot.fake_snapshot_obj(mock.MagicMock())
with mock.patch.object(sfv, '_delete_cgsnapshot',
return_value={}) as _del_mock:
model_update = sfv.delete_group_snapshot(self.ctxt,
cgsnapshot, snapshots)
_del_mock.assert_called_once_with(self.ctxt, cgsnapshot, snapshots)
self.assertEqual({}, model_update)
@mock.patch('cinder.volume.utils.is_group_a_cg_snapshot_type')
def test_delete_group_snap(self, group_cg_test):
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
group_cg_test.return_value = False
cgsnapshot = fake_group_snapshot.fake_group_snapshot_obj(
mock.MagicMock())
snapshots = fake_snapshot.fake_snapshot_obj(mock.MagicMock())
with mock.patch.object(sfv, '_delete_cgsnapshot',
return_value={}) as _del_mock:
self.assertRaises(NotImplementedError, sfv.delete_group_snapshot,
self.ctxt, cgsnapshot, snapshots)
_del_mock.assert_not_called()
@mock.patch('cinder.volume.utils.is_group_a_cg_snapshot_type')
def test_create_group_rainy(self, group_cg_test):
sfv = solidfire.SolidFireDriver(configuration=self.configuration)

View File

@@ -1746,6 +1746,13 @@ class SolidFireDriver(san.SanISCSIDriver):
self._delete_cgsnapshot_by_name(snap_name)
return None, None
def delete_group_snapshot(self, context, group_snapshot, snapshots):
if vol_utils.is_group_a_cg_snapshot_type(group_snapshot):
return self._delete_cgsnapshot(context, group_snapshot, snapshots)
# Default implementation handles other scenarios.
raise NotImplementedError()
def _delete_consistencygroup(self, ctxt, group, volumes):
# TODO(chris_morrell): exception handling and return correctly updated
# volume_models.

View File

@@ -0,0 +1,4 @@
---
fixes:
- Fixes a bug in NetApp SolidFire where the deletion of group snapshots
was failing.