]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Huawei: Ensure the port is online
authorWilson Liu <liuxinguo@huawei.com>
Sat, 23 Jan 2016 02:35:08 +0000 (10:35 +0800)
committerWilson Liu <liuxinguo@huawei.com>
Thu, 18 Feb 2016 14:37:26 +0000 (22:37 +0800)
There is a function whose purpose is get online port,
but in fact the port we get maybe not really online.

Closes-Bug: #1536046
Change-Id: If8d6facf429fa8c90f090602d368f6d3657c8a25

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

index 6f2bef9fe450e5068c00947656e99c1a4a4a82a7..5391c6ba1ed866b0d19ea9f784beefe24854dbd9 100644 (file)
@@ -3473,6 +3473,16 @@ class HuaweiFCDriverTestCase(test.TestCase):
         lun_info = self.driver.create_volume(hyper_volume)
         self.assertEqual(metadata, lun_info['metadata'])
 
+    @mock.patch.object(rest_client.RestClient, 'call',
+                       return_value={"data": [{"RUNNINGSTATUS": "27",
+                                               "ID": '1'},
+                                              {"RUNNINGSTATUS": "26",
+                                               "ID": '2'}],
+                                     "error": {"code": 0}})
+    def test_get_online_free_wwns(self, mock_call):
+        wwns = self.driver.client.get_online_free_wwns()
+        self.assertEqual(['1'], wwns)
+
 
 class HuaweiConfTestCase(test.TestCase):
     def setUp(self):
index 64d3189e2802629d3dc27097490fd61deb766e0e..77a3884ff40f0f0b04b30fef9fd3dfbf4d23c9a6 100644 (file)
@@ -1034,7 +1034,8 @@ class RestClient(object):
         wwns = []
         if 'data' in result:
             for item in result['data']:
-                wwns.append(item['ID'])
+                if item['RUNNINGSTATUS'] == constants.FC_INIT_ONLINE:
+                    wwns.append(item['ID'])
 
         return wwns