]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Huawei: Manage volume fails due to lower array version
authorWilson Liu <liuxinguo@huawei.com>
Wed, 17 Feb 2016 04:48:17 +0000 (12:48 +0800)
committerWilson Liu <liuxinguo@huawei.com>
Wed, 2 Mar 2016 06:06:37 +0000 (14:06 +0800)
When we try to import an existing volume to cinder, we try
to find whether the volume already exists in a hypermetro.
But if the array version is lower than V3R3, the request
to find the hypermetro info will fail because array version
lower than V3R3 does not support hypermetro.

Closes-Bug: #1546375
Change-Id: Ia28e62f3924155e813df80f3c4932e3f0f10333e

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

index e5b173ed683d45bfdd8f7cfa75824d2b625edcb1..3c275eac86e1fc1c9bf21e1b6874ce8adf810dea 100644 (file)
@@ -2413,6 +2413,28 @@ class HuaweiISCSIDriverTestCase(test.TestCase):
                                    test_volume, external_ref)
             self.assertIsNotNone(re.search('HyperMetroPair', ex.msg))
 
+    @mock.patch.object(rest_client.RestClient, 'get_hypermetro_pairs')
+    @mock.patch.object(rest_client.RestClient, 'rename_lun')
+    @mock.patch.object(rest_client.RestClient, 'get_lun_info',
+                       return_value={'CAPACITY': 2097152,
+                                     'ID': 'ID1',
+                                     'PARENTNAME': 'StoragePool001',
+                                     'HEALTHSTATUS': constants.STATUS_HEALTH})
+    @mock.patch.object(rest_client.RestClient, 'get_lun_id_by_name',
+                       return_value='ID1')
+    def test_manage_existing_with_lower_version(self, mock_get_by_name,
+                                                mock_get_info, mock_rename,
+                                                mock_get_hyper_pairs):
+        test_volume = {'host': 'ubuntu-204@v3r3#StoragePool001',
+                       'id': '21ec7341-9256-497b-97d9-ef48edcf0635',
+                       'name': 'volume-21ec7341-9256-497b-97d9-ef48edcf'}
+        mock_get_hyper_pairs.side_effect = (
+            exception.VolumeBackendAPIException(data='err'))
+        external_ref = {'source-name': 'LUN1'}
+        model_update = self.driver.manage_existing(test_volume,
+                                                   external_ref)
+        self.assertEqual({'provider_location': 'ID1'}, model_update)
+
     @ddt.data([[{'PRILUNID': 'ID1'}], []],
               [[{'PRILUNID': 'ID2'}], ['ID1', 'ID2']])
     @mock.patch.object(rest_client.RestClient, 'get_lun_info',
index 002612bba6d14a7fd9f352d645f3ee2185ec3c62..2691cc09bf5ee4de878241361e2a05dddb34248d 100644 (file)
@@ -1081,9 +1081,8 @@ class HuaweiBaseDriver(driver.VolumeDriver):
         try:
             hypermetro_pairs = self.client.get_hypermetro_pairs()
         except exception.VolumeBackendAPIException:
-            msg = _("Failed to get HyperMetroPair.")
-            raise exception.ManageExistingInvalidReference(
-                existing_ref=external_ref, reason=msg)
+            hypermetro_pairs = []
+            LOG.debug("Can't get hypermetro info, pass the check.")
 
         for pair in hypermetro_pairs:
             if pair.get('LOCALOBJID') == lun_id: