]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
LeftHand: Create cloned volume didn't honor size
authorKurt Martin <kurt.f.martin@hpe.com>
Wed, 9 Mar 2016 22:33:55 +0000 (14:33 -0800)
committerKurt Martin <kurt.f.martin@hpe.com>
Wed, 9 Mar 2016 22:37:16 +0000 (14:37 -0800)
If the volume being created was larger than the cloned volume
the new volume was not being extended.

Change-Id: I65cbf76ca6c4b11b82cc992f731b868c511e653e
Closes-Bug: 1554746

cinder/tests/unit/test_hpelefthand.py
cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py

index ad4942a9d582786bf5095abf2a65caec975d909b..489957ef677055bde80576a141d275c1c4cf053d 100644 (file)
@@ -116,7 +116,10 @@ class HPELeftHandBaseDriver(object):
         'volume': volume}
 
     cloned_volume_name = "clone_volume"
-    cloned_volume = {'name': cloned_volume_name}
+    cloned_volume = {'name': cloned_volume_name,
+                     'size': 1}
+    cloned_volume_extend = {'name': cloned_volume_name,
+                            'size': 5}
 
     cloned_snapshot_name = "clonedshapshot"
     cloned_snapshot_id = 5
@@ -805,6 +808,52 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
             # validate call chain
             mock_client.assert_has_calls(expected)
 
+    def test_create_cloned_volume_extend(self):
+
+        # setup drive with default configuration
+        # and return the mock HTTP LeftHand client
+        mock_client = self.setup_driver()
+
+        mock_client.getVolumeByName.return_value = {'id': self.volume_id}
+        mock_client.cloneVolume.return_value = {
+            'iscsiIqn': self.connector['initiator']}
+        mock_client.getVolumes.return_value = {'total': 1, 'members': []}
+
+        with mock.patch.object(hpe_lefthand_iscsi.HPELeftHandISCSIDriver,
+                               '_create_client') as mock_do_setup:
+            mock_do_setup.return_value = mock_client
+
+            # execute create_cloned_volume with extend
+            model_update = self.driver.create_cloned_volume(
+                self.cloned_volume_extend, self.volume)
+
+            expected_iqn = 'iqn.1993-08.org.debian:01:222 0'
+            expected_location = "10.0.1.6:3260,1 %s" % expected_iqn
+            self.assertEqual(expected_location,
+                             model_update['provider_location'])
+
+            expected = self.driver_startup_call_stack + [
+                mock.call.getVolumeByName('fakevolume'),
+                mock.call.cloneVolume('clone_volume', 1),
+                mock.call.login('foo1', 'bar2'),
+                mock.call.getClusterByName('CloudCluster1'),
+                mock.call.setSSHOptions(
+                    HPELEFTHAND_SSH_IP,
+                    HPELEFTHAND_USERNAME,
+                    HPELEFTHAND_PASSWORD,
+                    missing_key_policy='AutoAddPolicy',
+                    privatekey=HPELEFTHAND_SAN_SSH_PRIVATE,
+                    known_hosts_file=mock.ANY,
+                    port=HPELEFTHAND_SSH_PORT,
+                    conn_timeout=HPELEFTHAND_SAN_SSH_CON_TIMEOUT),
+                mock.call.getVolumeByName('clone_volume'),
+                mock.call.modifyVolume(self.volume_id, {'size': 5 * units.Gi}),
+                mock.call.logout(),
+                mock.call.logout()]
+
+            # validate call chain
+            mock_client.assert_has_calls(expected)
+
     @mock.patch.object(volume_types, 'get_volume_type')
     def test_extra_spec_mapping(self, _mock_get_volume_type):
 
index 733948e98ea262f8fcd51f1273864ff16792d6ac..36264f2edcd6b1e9cea5fc38af890917422faac0 100644 (file)
@@ -150,9 +150,10 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
         2.0.4 - Add manage/unmanage snapshot support
         2.0.5 - Changed minimum client version to be 2.1.0
         2.0.6 - Update replication to version 2.1
+        2.0.7 - Fixed bug #1554746, Create clone volume with new size.
     """
 
-    VERSION = "2.0.6"
+    VERSION = "2.0.7"
 
     device_stats = {}
 
@@ -774,6 +775,11 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
             volume_info = client.getVolumeByName(src_vref['name'])
             clone_info = client.cloneVolume(volume['name'], volume_info['id'])
 
+            # Extend volume
+            if volume['size'] > src_vref['size']:
+                LOG.debug("Resize the new volume to %s.", volume['size'])
+                self.extend_volume(volume, volume['size'])
+
             model_update = self._update_provider(clone_info)
 
             # v2 replication check