]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp ONTAP: Fix extending volume beyond lun geometry
authorAlex Meade <mr.alex.meade@gmail.com>
Fri, 8 Jan 2016 18:52:22 +0000 (13:52 -0500)
committerAlex Meade <mr.alex.meade@gmail.com>
Thu, 14 Jan 2016 19:24:53 +0000 (19:24 +0000)
In the case where a LUN is extended beyond it's supported geometry,
a new LUN must be created and only the used blocks should be copied
to the new LUN. Currently, we do not pass the block count, source
block, and destination block information. This causes the extend to
fail.

Closes-Bug: 1532836
Change-Id: I31d93ecfeee9884d6796c66acfbe556363130c44

cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_7mode.py
cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py
cinder/volume/drivers/netapp/dataontap/block_7mode.py
cinder/volume/drivers/netapp/dataontap/block_cmode.py

index c178a70d53ca1f0c377bc7d5ba05f8c6663704dd..1886deb2ded4a17c39b68d6c09e48c194a0e2000 100644 (file)
@@ -298,6 +298,26 @@ class NetAppBlockStorage7modeLibraryTestCase(test.TestCase):
             '/vol/fake/fakeLUN', '/vol/fake/newFakeLUN', 'fakeLUN',
             'newFakeLUN', 'false', block_count=0, dest_block=0, src_block=0)
 
+    def test_clone_lun_blocks(self):
+        """Test for when clone lun is passed block information."""
+        block_count = 10
+        src_block = 10
+        dest_block = 30
+        self.library._get_lun_attr = mock.Mock(return_value={
+            'Volume': 'fakeLUN', 'Path': '/vol/fake/fakeLUN'})
+        self.library.zapi_client = mock.Mock()
+        self.library.zapi_client.get_lun_by_args.return_value = [fake.FAKE_LUN]
+        self.library._add_lun_to_table = mock.Mock()
+
+        self.library._clone_lun('fakeLUN', 'newFakeLUN', 'false',
+                                block_count=block_count, src_block=src_block,
+                                dest_block=dest_block)
+
+        self.library.zapi_client.clone_lun.assert_called_once_with(
+            '/vol/fake/fakeLUN', '/vol/fake/newFakeLUN', 'fakeLUN',
+            'newFakeLUN', 'false', block_count=block_count,
+            dest_block=dest_block, src_block=src_block)
+
     def test_clone_lun_no_space_reservation(self):
         """Test for when space_reservation is not passed."""
         self.library._get_lun_attr = mock.Mock(return_value={
index c2bba08884429ea1e882891f9d47222cedc3007b..f8176eabef337acfac79224396351023127e4bfb 100644 (file)
@@ -192,6 +192,31 @@ class NetAppBlockStorageCmodeLibraryTestCase(test.TestCase):
             'fakeLUN', 'fakeLUN', 'newFakeLUN', 'false', block_count=0,
             dest_block=0, src_block=0, qos_policy_group_name=None)
 
+    def test_clone_lun_blocks(self):
+        """Test for when clone lun is passed block information."""
+        block_count = 10
+        src_block = 10
+        dest_block = 30
+
+        self.library._get_lun_attr = mock.Mock(return_value={'Volume':
+                                                             'fakeLUN'})
+        self.library.zapi_client = mock.Mock()
+        self.library.zapi_client.get_lun_by_args.return_value = [
+            mock.Mock(spec=netapp_api.NaElement)]
+        lun = fake.FAKE_LUN
+        self.library._get_lun_by_args = mock.Mock(return_value=[lun])
+        self.library._add_lun_to_table = mock.Mock()
+        self.library._update_stale_vols = mock.Mock()
+
+        self.library._clone_lun('fakeLUN', 'newFakeLUN', 'false',
+                                block_count=block_count, src_block=src_block,
+                                dest_block=dest_block)
+
+        self.library.zapi_client.clone_lun.assert_called_once_with(
+            'fakeLUN', 'fakeLUN', 'newFakeLUN', 'false',
+            block_count=block_count, dest_block=dest_block,
+            src_block=src_block, qos_policy_group_name=None)
+
     def test_clone_lun_no_space_reservation(self):
         """Test for when space_reservation is not passed."""
 
index cf3a749aa650ad718e21bfc8ce85b3d1d9fc33e0..e6851a7d55e1aded8ce5196c57b886a9356a5ceb 100644 (file)
@@ -205,8 +205,9 @@ class NetAppBlockStorage7modeLibrary(block_base.NetAppBlockStorageLibrary):
         clone_path = '%s/%s' % (parent, new_name)
 
         self.zapi_client.clone_lun(path, clone_path, name, new_name,
-                                   space_reserved, src_block=0,
-                                   dest_block=0, block_count=0)
+                                   space_reserved, src_block=src_block,
+                                   dest_block=dest_block,
+                                   block_count=block_count)
 
         self.vol_refresh_voluntary = True
         luns = self.zapi_client.get_lun_by_args(path=clone_path)
index 896f42bfb3339dcc27873e27c6dc575e037b7f9b..b2b067715c7aa19c6df1f2ef092b0be173d92a13 100644 (file)
@@ -133,8 +133,8 @@ class NetAppBlockStorageCmodeLibrary(block_base.NetAppBlockStorageLibrary):
         volume = metadata['Volume']
         self.zapi_client.clone_lun(volume, name, new_name, space_reserved,
                                    qos_policy_group_name=qos_policy_group_name,
-                                   src_block=0, dest_block=0,
-                                   block_count=0)
+                                   src_block=src_block, dest_block=dest_block,
+                                   block_count=block_count)
         LOG.debug("Cloned LUN with new name %s", new_name)
         lun = self.zapi_client.get_lun_by_args(vserver=self.vserver,
                                                path='/vol/%s/%s'