self.assertEqual(result, actual)
+ def test_add_volume_to_consistencygroup(self):
+ fake_volume = cinder_utils.create_volume(self.ctxt)
+ fake_volume['consistencygroup'] = (
+ cinder_utils.create_consistencygroup(self.ctxt))
+ fake_volume['consistencygroup_id'] = fake_volume[
+ 'consistencygroup']['id']
+ cg = copy.deepcopy(eseries_fake.FAKE_CONSISTENCY_GROUP)
+ self.mock_object(self.library, '_get_consistencygroup',
+ mock.Mock(return_value=cg))
+ update_members = self.mock_object(self.library,
+ '_update_consistency_group_members')
+
+ self.library._add_volume_to_consistencygroup(fake_volume)
+
+ update_members.assert_called_once_with(cg, [fake_volume], [])
+
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall', new=
cinder_utils.ZeroIntervalLoopingCall)
def test_copy_volume_high_priority_readonly(self):
def test_create_volume(self):
self.library._client.create_volume = mock.Mock(
return_value=eseries_fake.VOLUME)
+ update_members = self.mock_object(self.library,
+ '_update_consistency_group_members')
self.library.create_volume(get_fake_volume())
self.assertTrue(self.library._client.create_volume.call_count)
+ update_members.assert_not_called()
+
@ddt.data(('netapp_eseries_flash_read_cache', 'flash_cache', 'true'),
('netapp_eseries_flash_read_cache', 'flash_cache', 'false'),
('netapp_eseries_flash_read_cache', 'flash_cache', None),
if storage_pool:
return storage_pool.get('label')
+ def _add_volume_to_consistencygroup(self, volume):
+ if volume.get('consistencygroup_id'):
+ es_cg = self._get_consistencygroup(volume['consistencygroup'])
+ self._update_consistency_group_members(es_cg, [volume], [])
+
def create_volume(self, volume):
"""Creates a volume."""
self._create_volume(eseries_pool_label, eseries_volume_label, size_gb,
extra_specs)
+ self._add_volume_to_consistencygroup(volume)
+
def _create_volume(self, eseries_pool_label, eseries_volume_label,
size_gb, extra_specs=None):
"""Creates volume with given label and size."""
cinder_utils.synchronized(snapshot['id'])(
self._create_volume_from_snapshot)(volume, es_snapshot)
+ self._add_volume_to_consistencygroup(volume)
+
def _copy_volume_high_priority_readonly(self, src_vol, dst_vol):
"""Copies src volume to dest volume."""
LOG.info(_LI("Copying src vol %(src)s to dest vol %(dst)s."),
try:
self._create_volume_from_snapshot(volume, es_snapshot)
+ self._add_volume_to_consistencygroup(volume)
finally:
try:
self._client.delete_snapshot_group(es_snapshot['pitGroupRef'])