]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Huawei: Don't fail when port group does not exist
authorWilson Liu <liuxinguo@huawei.com>
Sat, 23 Jan 2016 02:32:43 +0000 (10:32 +0800)
committerWilson Liu <liuxinguo@huawei.com>
Wed, 24 Feb 2016 03:42:03 +0000 (11:42 +0800)
Currently when we request a port group but the
port group does not exist, an error will be raised.
This is not appropriate, because port group not
exists is a normal case.

Closes-Bug: #1536040
Change-Id: I0614163574dac384167ce2bce8887f674f3a97b5

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

index c235dae5370850199c35fad217e4bc39d3ddc147..6ea717e6b6daef3f651d5ab0bfea54669a9dae8c 100644 (file)
@@ -3034,6 +3034,12 @@ class HuaweiISCSIDriverTestCase(test.TestCase):
         op.get_replica_info(replica_id)
         op._is_status(None, {'key': 'volue'}, None)
 
+    @mock.patch.object(rest_client.RestClient, 'call',
+                       return_value={"error": {"code": 0}})
+    def test_get_tgt_port_group_no_portg_exist(self, mock_call):
+        portg = self.driver.client.get_tgt_port_group('test_portg')
+        self.assertIsNone(portg)
+
 
 class FCSanLookupService(object):
 
index 7ff67495202245e3782e523b285aac1393320b6c..5fcc7f8d8e52f02bf3b374a889bed8e8405dfc23 100644 (file)
@@ -367,8 +367,6 @@ class RestClient(object):
 
         msg = _('Find portgroup error.')
         self._assert_rest_result(result, msg)
-        msg = _('Can not find the portgroup on the array.')
-        self._assert_data_in_result(result, msg)
 
         return self._get_id_from_result(result, tgt_port_group, 'NAME')