]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Check before add lun to QoS in Huawei driver
authorWilson Liu <liuxinguo@huawei.com>
Tue, 1 Sep 2015 11:22:41 +0000 (19:22 +0800)
committerWilson Liu <liuxinguo@huawei.com>
Tue, 1 Sep 2015 14:16:24 +0000 (22:16 +0800)
Check whether the lun_id has already been
added into the QoS before we add it.

Also some very small code clean in this patch.

Closes-Bug: #1490935
Change-Id: Ie0a2e4debe229d2f5ad8c66cfd1f0bf5522e4733

cinder/volume/drivers/huawei/rest_client.py

index d77683996539ae79851a72563b00ffad18074982..85bbae548df1fc7e3db6be5bbc22ff2140649514 100644 (file)
@@ -1491,13 +1491,16 @@ class RestClient(object):
     def add_lun_to_qos(self, qos_id, lun_id, lun_list):
         """Add lun to QoS."""
         url = self.url + "/ioclass/" + qos_id
-        lun_list = []
-        lun_string = lun_list[1:-1]
-        for lun in lun_string.split(","):
-            str = lun[1:-1]
-            lun_list.append(str)
-        lun_list.append(lun_id)
-        data = json.dumps({"LUNLIST": lun_list,
+        new_lun_list = []
+        lun_list_string = lun_list[1:-1]
+        for lun_string in lun_list_string.split(","):
+            tmp_lun_id = lun_string[1:-1]
+            if '' != tmp_lun_id and tmp_lun_id != lun_id:
+                new_lun_list.append(tmp_lun_id)
+
+        new_lun_list.append(lun_id)
+
+        data = json.dumps({"LUNLIST": new_lun_list,
                            "TYPE": 230,
                            "ID": qos_id})
         result = self.call(url, data, "PUT")