From: Wilson Liu Date: Sat, 23 Jan 2016 02:35:08 +0000 (+0800) Subject: Huawei: Ensure the port is online X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=06931de997d64263de03859247764d76e4ff3207;p=openstack-build%2Fcinder-build.git Huawei: Ensure the port is online 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 --- diff --git a/cinder/tests/unit/test_huawei_drivers.py b/cinder/tests/unit/test_huawei_drivers.py index 6f2bef9fe..5391c6ba1 100644 --- a/cinder/tests/unit/test_huawei_drivers.py +++ b/cinder/tests/unit/test_huawei_drivers.py @@ -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): diff --git a/cinder/volume/drivers/huawei/rest_client.py b/cinder/volume/drivers/huawei/rest_client.py index 64d3189e2..77a3884ff 100644 --- a/cinder/volume/drivers/huawei/rest_client.py +++ b/cinder/volume/drivers/huawei/rest_client.py @@ -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