]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Huawei: Check when attach hypermetro volume
authorhuananhuawei <huanan@huawei.com>
Wed, 24 Feb 2016 07:17:51 +0000 (15:17 +0800)
committerhuananhuawei <huanan@huawei.com>
Wed, 16 Mar 2016 03:31:42 +0000 (11:31 +0800)
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

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

index 68e428efe75fe18c697e3f2702eb294df08a7731..938ecd0d8a8fa4bf502153158a49bf732006453e 100644 (file)
@@ -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',
index d752fa6f75533a737e0a0c8e51affd7820f8aa99..83f9e9eab03868a9730625659cb91e298beb657f 100644 (file)
@@ -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.