]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add description when rename LUN in Huawei driver
authorWilson Liu <liuxinguo@huawei.com>
Sat, 23 Jan 2016 02:58:46 +0000 (10:58 +0800)
committerWilson Liu <liuxinguo@huawei.com>
Sat, 27 Feb 2016 01:44:23 +0000 (09:44 +0800)
Sometimes when we rename a LUN on the array, we should
add some description to record some information like
volume id on cinder side. This patch will enable this.

Closes-Bug: #1537304
Change-Id: Ib156e61b5b1e305c41426cf5c6001dd44770140c

cinder/tests/unit/test_huawei_drivers.py
cinder/volume/drivers/huawei/huawei_driver.py
cinder/volume/drivers/huawei/rest_client.py

index 6ea717e6b6daef3f651d5ab0bfea54669a9dae8c..0927c614a2c357735a94f41607f7ed137dd211e2 100644 (file)
@@ -3489,6 +3489,17 @@ class HuaweiFCDriverTestCase(test.TestCase):
         wwns = self.driver.client.get_online_free_wwns()
         self.assertEqual(['1'], wwns)
 
+    @mock.patch.object(rest_client.RestClient, 'call',
+                       return_value={"data": {"ID": 1}, "error": {"code": 0}})
+    def test_rename_lun(self, mock_call):
+        des = 'This LUN is renamed.'
+        new_name = 'test_name'
+        self.driver.client.rename_lun('1', new_name, des)
+        self.assertEqual(1, mock_call.call_count)
+        url = "/lun/1"
+        data = {"NAME": new_name, "DESCRIPTION": des}
+        mock_call.assert_called_once_with(url, data, "PUT")
+
 
 class HuaweiConfTestCase(test.TestCase):
     def setUp(self):
index 80e02b6008947149dd45ef2de5b9e48685eeaebd..c67b65c909de6e5f105ed253a139023994d7e381 100644 (file)
@@ -1219,8 +1219,7 @@ class HuaweiBaseDriver(driver.VolumeDriver):
         LOG.debug("Rename LUN %(old_name)s to %(new_name)s.",
                   {'old_name': lun_info.get('NAME'),
                    'new_name': new_name})
-        self.client.rename_lun(lun_id, new_name,  # pylint: disable=E1121
-                               description)
+        self.client.rename_lun(lun_id, new_name, description)
 
         model_update = {}
         model_update.update({'provider_location': lun_id})
index 90e85eae95b31164fc1fa2983588576100cb66ad..4ca4cfda82141fbd8b3f4f80b9a3bac1967ba38e 100644 (file)
@@ -1635,9 +1635,11 @@ class RestClient(object):
 
         return initiators
 
-    def rename_lun(self, lun_id, new_name):
+    def rename_lun(self, lun_id, new_name, description=None):
         url = "/lun/" + lun_id
         data = {"NAME": new_name}
+        if description:
+            data.update({"DESCRIPTION": description})
         result = self.call(url, data, "PUT")
         msg = _('Rename lun on array error.')
         self._assert_rest_result(result, msg)