]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp E-Series: Volumes not added to consisgroup
authorMichael Price <michael.price@netapp.com>
Thu, 10 Mar 2016 17:17:18 +0000 (11:17 -0600)
committerMichael Price <michael.price@netapp.com>
Mon, 14 Mar 2016 21:40:18 +0000 (21:40 +0000)
Volumes were not being added to a consistency group upon creation when the
consistencygroup_id is provided during the volume creation.

This patch adds functionality to relevant methods in library.py to add the newly
created volume to a consistency group when applicable.

Closes-Bug: #1555933
Change-Id: I6d09b81571ce7b5c07d155cb4a70079fe35ed945

cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py
cinder/volume/drivers/netapp/eseries/library.py

index b8ff667533ba882e32d6a422de60195c9339aee6..ff4017c0041946405660e190bcf2d91965fc186c 100644 (file)
@@ -1244,6 +1244,22 @@ class NetAppEseriesLibraryTestCase(test.TestCase):
 
         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):
@@ -1340,10 +1356,14 @@ class NetAppEseriesLibraryMultiAttachTestCase(test.TestCase):
     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),
index 90cd85dc60f2a20dcb2407fa7997e834a157439d..1ad5504c7cfbba8fff4e44ef7d78d5d7d3e6fccc 100644 (file)
@@ -499,6 +499,11 @@ class NetAppESeriesLibrary(object):
         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."""
 
@@ -521,6 +526,8 @@ class NetAppESeriesLibrary(object):
         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."""
@@ -665,6 +672,8 @@ class NetAppESeriesLibrary(object):
         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."),
@@ -711,6 +720,7 @@ class NetAppESeriesLibrary(object):
 
         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'])