diff --git a/cinder/tests/unit/volume/drivers/test_pure.py b/cinder/tests/unit/volume/drivers/test_pure.py index b5ac9190904..fb93f8eeb50 100644 --- a/cinder/tests/unit/volume/drivers/test_pure.py +++ b/cinder/tests/unit/volume/drivers/test_pure.py @@ -1679,7 +1679,7 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase): mock_cgsnapshot = mock.Mock() mock_snapshots = [mock.Mock() for i in range(5)] mock_volumes = [mock.Mock() for i in range(5)] - result = self.driver.create_consistencygroup_from_src( + self.driver.create_consistencygroup_from_src( mock_context, mock_group, mock_volumes, @@ -1688,7 +1688,6 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase): source_cg=None, source_vols=None ) - self.assertEqual((None, None), result) mock_create_cg.assert_called_with(mock_context, mock_group) expected_calls = [mock.call(vol, snap) for vol, snap in zip(mock_volumes, mock_snapshots)] @@ -1715,14 +1714,13 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase): mock_source_cg = mock.MagicMock() mock_volumes = [mock.MagicMock() for i in range(num_volumes)] mock_source_vols = [mock.MagicMock() for i in range(num_volumes)] - result = self.driver.create_consistencygroup_from_src( + self.driver.create_consistencygroup_from_src( mock_context, mock_group, mock_volumes, source_cg=mock_source_cg, source_vols=mock_source_vols ) - self.assertEqual((None, None), result) mock_create_cg.assert_called_with(mock_context, mock_group) self.assertTrue(self.array.create_pgroup_snapshot.called) self.assertTrue(self.array.destroy_pgroup.called) diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index f28e7183643..3d23d96fd18 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -550,6 +550,7 @@ class PureBaseVolumeDriver(san.SanDriver): repl_status = fields.ReplicationStatus.ENABLED model_update = { + 'id': volume.id, 'provider_id': purity_vol_name, 'replication_status': repl_status, } @@ -976,8 +977,11 @@ class PureBaseVolumeDriver(san.SanDriver): The new volumes will be consistent with the snapshot. """ + vol_models = [] for volume, snapshot in zip(volumes, snapshots): - self.create_volume_from_snapshot(volume, snapshot) + vol_models.append(self.create_volume_from_snapshot(volume, + snapshot)) + return vol_models def _create_cg_from_cg(self, group, source_group, volumes, source_vols): """Creates a new consistency group from an existing cg. @@ -985,6 +989,7 @@ class PureBaseVolumeDriver(san.SanDriver): The new volumes will be in a consistent state, but this requires taking a new temporary group snapshot and cloning from that. """ + vol_models = [] pgroup_name = self._get_pgroup_name(source_group) tmp_suffix = '%s-tmp' % uuid.uuid4() tmp_pgsnap_name = '%(pgroup_name)s.%(pgsnap_suffix)s' % { @@ -1013,19 +1018,21 @@ class PureBaseVolumeDriver(san.SanDriver): ) finally: self._delete_pgsnapshot(tmp_pgsnap_name) + return vol_models @pure_driver_debug_trace def create_consistencygroup_from_src(self, context, group, volumes, cgsnapshot=None, snapshots=None, source_cg=None, source_vols=None): - self.create_consistencygroup(context, group) + model_update = self.create_consistencygroup(context, group) if cgsnapshot and snapshots: - self._create_cg_from_cgsnap(volumes, - snapshots) + vol_models = self._create_cg_from_cgsnap(volumes, + snapshots) elif source_cg: - self._create_cg_from_cg(group, source_cg, volumes, source_vols) + vol_models = self._create_cg_from_cg(group, source_cg, + volumes, source_vols) - return None, None + return model_update, vol_models @pure_driver_debug_trace def delete_consistencygroup(self, context, group, volumes): diff --git a/releasenotes/notes/bug_1945824-7f8f238e274ddebd.yaml b/releasenotes/notes/bug_1945824-7f8f238e274ddebd.yaml new file mode 100644 index 00000000000..1d1ed0c7f3d --- /dev/null +++ b/releasenotes/notes/bug_1945824-7f8f238e274ddebd.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Pure Storage driver `Bug #1945824 `_: + Fixed missing DB values when creating new consistency group from CG snapshot.