]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Netapp iscsi: allow snapshots with unspecified block range.
authorJeff Applewhite <jeff.applewhite@netapp.com>
Mon, 24 Mar 2014 21:37:22 +0000 (17:37 -0400)
committerJeff Applewhite <jeff.applewhite@netapp.com>
Tue, 25 Mar 2014 14:15:41 +0000 (10:15 -0400)
Snapshots were failing to create in all cases in the NetApp iscsi
driver. The clone lun function was never issuing the zapi call
because the block count was set to 0.

Closes-Bug: 1296881

Change-Id: Ic2bf67b57a566632103a3fa2ff032555f42a3961

cinder/tests/volume/drivers/netapp/test_iscsi.py
cinder/volume/drivers/netapp/iscsi.py

index fd35f0b72b809d7389b47f4e14515c388649319a..007201cfa8065134682029d94d28a531b716b2f9 100644 (file)
@@ -77,6 +77,44 @@ class NetAppiSCSICModeTestCase(test.TestCase):
 
         self.assertEqual(2, self.driver.client.invoke_successfully.call_count)
 
+    def test_clone_lun_zero_block_count(self):
+        """Test for when clone lun is not passed a block count."""
+
+        self.driver._get_lun_attr = mock.Mock(return_value={'Volume':
+                                                            'fakeLUN'})
+        self.driver.client.invoke_successfully = mock.Mock()
+        lun = ntapi.NaElement.create_node_with_children(
+            'lun-info',
+            **{'alignment': 'indeterminate',
+               'block-size': '512',
+               'comment': '',
+               'creation-timestamp': '1354536362',
+               'is-space-alloc-enabled': 'false',
+               'is-space-reservation-enabled': 'true',
+               'mapped': 'false',
+               'multiprotocol-type': 'linux',
+               'online': 'true',
+               'path': '/vol/fakeLUN/lun1',
+               'prefix-size': '0',
+               'qtree': '',
+               'read-only': 'false',
+               'serial-number': '2FfGI$APyN68',
+               'share-state': 'none',
+               'size': '20971520',
+               'size-used': '0',
+               'staging': 'false',
+               'suffix-size': '0',
+               'uuid': 'cec1f3d7-3d41-11e2-9cf4-123478563412',
+               'volume': 'fakeLUN',
+               'vserver': 'fake_vserver'})
+        self.driver._get_lun_by_args = mock.Mock(return_value=[lun])
+        self.driver._add_lun_to_table = mock.Mock()
+        self.driver._update_stale_vols = mock.Mock()
+
+        self.driver._clone_lun('fakeLUN', 'newFakeLUN')
+
+        self.assertEqual(1, self.driver.client.invoke_successfully.call_count)
+
 
 class NetAppiSCSI7ModeTestCase(test.TestCase):
     """Test case for NetApp's 7-Mode iSCSI driver."""
@@ -136,3 +174,46 @@ class NetAppiSCSI7ModeTestCase(test.TestCase):
         self.driver._clone_lun('fakeLUN', 'newFakeLUN', block_count=bc)
 
         self.assertEqual(2, self.driver.client.invoke_successfully.call_count)
+
+    def test_clone_lun_zero_block_count(self):
+        """Test for when clone lun is not passed a block count."""
+
+        self.driver._get_lun_attr = mock.Mock(return_value={'Volume':
+                                                            'fakeLUN',
+                                                            'Path':
+                                                            '/vol/fake/lun1'})
+        self.driver.client.invoke_successfully = mock.Mock(
+            return_value=mock.MagicMock())
+        lun = ntapi.NaElement.create_node_with_children(
+            'lun-info',
+            **{'alignment': 'indeterminate',
+               'block-size': '512',
+               'comment': '',
+               'creation-timestamp': '1354536362',
+               'is-space-alloc-enabled': 'false',
+               'is-space-reservation-enabled': 'true',
+               'mapped': 'false',
+               'multiprotocol-type': 'linux',
+               'online': 'true',
+               'path': '/vol/fakeLUN/lun1',
+               'prefix-size': '0',
+               'qtree': '',
+               'read-only': 'false',
+               'serial-number': '2FfGI$APyN68',
+               'share-state': 'none',
+               'size': '20971520',
+               'size-used': '0',
+               'staging': 'false',
+               'suffix-size': '0',
+               'uuid': 'cec1f3d7-3d41-11e2-9cf4-123478563412',
+               'volume': 'fakeLUN',
+               'vserver': 'fake_vserver'})
+        self.driver._get_lun_by_args = mock.Mock(return_value=[lun])
+        self.driver._add_lun_to_table = mock.Mock()
+        self.driver._update_stale_vols = mock.Mock()
+        self.driver._check_clone_status = mock.Mock()
+        self.driver._set_space_reserve = mock.Mock()
+
+        self.driver._clone_lun('fakeLUN', 'newFakeLUN')
+
+        self.assertEqual(1, self.driver.client.invoke_successfully.call_count)
index d5615207a81d0f6e500742ba2bc218b42e78ca49..1dca09de94a4bd901500943393818d44524efda8 100644 (file)
@@ -963,6 +963,8 @@ class NetAppDirectCmodeISCSIDriver(NetAppDirectISCSIDriver):
         z_limit = br_limit * bc_limit  # 256 GB
         z_calls = int(math.ceil(block_count / float(z_limit)))
         zbc = block_count
+        if z_calls == 0:
+            z_calls = 1
         for call in range(0, z_calls):
             if zbc > z_limit:
                 block_count = z_limit
@@ -1340,6 +1342,8 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver):
         z_limit = br_limit * bc_limit  # 256 GB
         z_calls = int(math.ceil(block_count / float(z_limit)))
         zbc = block_count
+        if z_calls == 0:
+            z_calls = 1
         for call in range(0, z_calls):
             if zbc > z_limit:
                 block_count = z_limit