From: Kurt Martin <kurt.f.martin@hp.com>
Date: Thu, 5 Feb 2015 00:09:44 +0000 (-0800)
Subject: Lefthand driver fails to attach a cloned volume
X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f71a2c535eaed8aec77354e1737618897fc2cbd0;p=openstack-build%2Fcinder-build.git

Lefthand driver fails to attach a cloned volume

The provider location was not being populated for cloned volumes.
This patch is updating the provider location for cloned volumes
resulting in successful volume attachments.

Change-Id: I86ef7935ed7233377aa4745dc4b45fcab5703f0a
Closes-Bug: 1418201
---

diff --git a/cinder/tests/test_hplefthand.py b/cinder/tests/test_hplefthand.py
index 8bcfdc201..409a5ddda 100644
--- a/cinder/tests/test_hplefthand.py
+++ b/cinder/tests/test_hplefthand.py
@@ -1173,15 +1173,22 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
         mock_client = self.setup_driver()
 
         mock_client.getVolumeByName.return_value = {'id': self.volume_id}
+        mock_client.cloneVolume.return_value = {
+            'iscsiIqn': self.connector['initiator']}
 
         with mock.patch.object(hp_lefthand_rest_proxy.HPLeftHandRESTProxy,
                                '_create_client') as mock_do_setup:
             mock_do_setup.return_value = mock_client
 
             # execute create_cloned_volume
-            self.driver.create_cloned_volume(
+            model_update = self.driver.create_cloned_volume(
                 self.cloned_volume, 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),
diff --git a/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py b/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py
index 0eb594324..59e03b341 100644
--- a/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py
+++ b/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py
@@ -96,9 +96,10 @@ class HPLeftHandRESTProxy(ISCSIDriver):
         1.0.6 - Removing locks bug #1395953
         1.0.7 - Fixed bug #1353137, Server was not removed from the HP
                 Lefthand backend after the last volume was detached.
+        1.0.8 - Fixed bug #1418201, A cloned volume fails to attach.
     """
 
-    VERSION = "1.0.7"
+    VERSION = "1.0.8"
 
     device_stats = {}
 
@@ -377,7 +378,8 @@ class HPLeftHandRESTProxy(ISCSIDriver):
         client = self._login()
         try:
             volume_info = client.getVolumeByName(src_vref['name'])
-            client.cloneVolume(volume['name'], volume_info['id'])
+            clone_info = client.cloneVolume(volume['name'], volume_info['id'])
+            return self._update_provider(clone_info)
         except Exception as ex:
             raise exception.VolumeBackendAPIException(ex)
         finally: