From: huananhuawei Date: Wed, 24 Feb 2016 07:17:51 +0000 (+0800) Subject: Huawei: Check when attach hypermetro volume X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=93e8529a3b463b2654dc3cf68340d2c75405d0fd;p=openstack-build%2Fcinder-build.git Huawei: Check when attach hypermetro volume Currently when we attach a hypermetro volume, if the map info is none there is not logged that is due to the array version does not support hypermetro. Change-Id: I51dc3e5b21fb0d44b00e498c4b2144e57b07e73c Closes-Bug: #1549130 --- diff --git a/cinder/tests/unit/test_huawei_drivers.py b/cinder/tests/unit/test_huawei_drivers.py index 68e428efe..938ecd0d8 100644 --- a/cinder/tests/unit/test_huawei_drivers.py +++ b/cinder/tests/unit/test_huawei_drivers.py @@ -2309,6 +2309,15 @@ class HuaweiISCSIDriverTestCase(test.TestCase): lun_PARENTID = mock_create_lun.call_args[0][0]['PARENTID'] self.assertEqual(FAKE_FIND_POOL_RESPONSE['ID'], lun_PARENTID) + @mock.patch.object(huawei_driver.huawei_utils, 'get_volume_metadata', + return_value={'hypermetro_id': '3400a30d844d0007', + 'remote_lun_id': '1'}) + def test_hypermetro_none_map_info_fail(self, mock_metadata): + self.assertRaises(exception.VolumeBackendAPIException, + self.driver.metro.connect_volume_fc, + test_volume, + FakeConnector) + @mock.patch.object(rest_client.RestClient, 'check_lun_exist', return_value=True) @mock.patch.object(rest_client.RestClient, 'check_hypermetro_exist', diff --git a/cinder/volume/drivers/huawei/hypermetro.py b/cinder/volume/drivers/huawei/hypermetro.py index d752fa6f7..83f9e9eab 100644 --- a/cinder/volume/drivers/huawei/hypermetro.py +++ b/cinder/volume/drivers/huawei/hypermetro.py @@ -166,6 +166,12 @@ class HuaweiHyperMetro(object): map_info = self.rmt_client.do_mapping(lun_id, hostgroup_id, host_id) + if not map_info: + msg = _('Map info is None due to array version ' + 'not supporting hypermetro.') + LOG.error(msg) + raise exception.VolumeBackendAPIException(data=msg) + host_lun_id = self.rmt_client.get_host_lun_id(host_id, lun_id) # Return FC properties.