]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Modify the number of params of hypermetro in HuaweiDriver
authorGaoZqiang <gaozhiqiang2@huawei.com>
Wed, 17 Feb 2016 00:47:26 +0000 (08:47 +0800)
committerGaoZqiang <gaozhiqiang2@huawei.com>
Sat, 27 Feb 2016 01:08:19 +0000 (09:08 +0800)
When attaching or detaching hypermetro volume, the initialization
instance has three parameters, but the function definition has five
parameters.

Change-Id: I8343a7b75e02962c321a838de148acc54498f952
Closes-Bug: #1545971

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

index 6ea717e6b6daef3f651d5ab0bfea54669a9dae8c..d76209606c62df264fb3095d463ebddf25e7b1f9 100644 (file)
@@ -794,7 +794,8 @@ FAKE_GET_SPEC_MAPPING_VIEW_RESPONSE = """
         "ENABLEINBANDCOMMAND":"true",
         "ID":"1",
         "INBANDLUNWWN":"",
-        "TYPE":245
+        "TYPE":245,
+        "AVAILABLEHOSTLUNIDLIST": "[1]"
     }
 }
 """
@@ -1353,6 +1354,9 @@ MAP_COMMAND_TO_FAKE_RESPONSE['/mappingview?range=[0-8191]/GET'] = (
 MAP_COMMAND_TO_FAKE_RESPONSE['/mappingview'] = (
     FAKE_GET_MAPPING_VIEW_RESPONSE)
 
+MAP_COMMAND_TO_FAKE_RESPONSE['/mappingview/PUT'] = (
+    FAKE_GET_MAPPING_VIEW_RESPONSE)
+
 MAP_COMMAND_TO_FAKE_RESPONSE['/MAPPINGVIEW/1/GET'] = (
     FAKE_GET_SPEC_MAPPING_VIEW_RESPONSE)
 
@@ -1916,17 +1920,6 @@ class FakeClient(rest_client.RestClient):
         return json.loads(data)
 
 
-class FakeDB(object):
-
-    def volume_update(self, context, volume_id, model_update):
-        pass
-
-    def volume_get_all_by_group(self, context, group_id):
-        volumes = []
-        volumes.append(test_volume)
-        return volumes
-
-
 class FakeReplicaPairManager(replication.ReplicaPairManager):
     def _init_rmt_client(self):
         self.rmt_client = FakeClient(self.conf)
@@ -1937,7 +1930,6 @@ class FakeISCSIStorage(huawei_driver.HuaweiISCSIDriver):
 
     def __init__(self, configuration):
         self.configuration = configuration
-        self.db = FakeDB()
         self.huawei_conf = FakeHuaweiConf(self.configuration, 'iSCSI')
 
     def do_setup(self):
@@ -1947,8 +1939,7 @@ class FakeISCSIStorage(huawei_driver.HuaweiISCSIDriver):
         self.rmt_client = FakeClient(configuration=self.configuration)
         self.metro = hypermetro.HuaweiHyperMetro(self.client,
                                                  self.rmt_client,
-                                                 self.configuration,
-                                                 self.db)
+                                                 self.configuration)
         self.replica = FakeReplicaPairManager(self.client, self.configuration)
 
 
@@ -1958,7 +1949,6 @@ class FakeFCStorage(huawei_driver.HuaweiFCDriver):
     def __init__(self, configuration):
         self.configuration = configuration
         self.fcsan = None
-        self.db = FakeDB()
         self.huawei_conf = FakeHuaweiConf(self.configuration, 'iSCSI')
 
     def do_setup(self):
@@ -1968,8 +1958,7 @@ class FakeFCStorage(huawei_driver.HuaweiFCDriver):
         self.rmt_client = FakeClient(configuration=self.configuration)
         self.metro = hypermetro.HuaweiHyperMetro(self.client,
                                                  self.rmt_client,
-                                                 self.configuration,
-                                                 self.db)
+                                                 self.configuration)
         self.replica = FakeReplicaPairManager(self.client, self.configuration)
 
 
@@ -3098,11 +3087,21 @@ class HuaweiFCDriverTestCase(test.TestCase):
                                                              FakeConnector)
         self.assertEqual(1, iscsi_properties['data']['target_lun'])
 
+    def test_hypermetro_connection_success(self):
+        self.mock_object(rest_client.RestClient, 'find_array_version',
+                         mock.Mock(return_value='V300R003C00'))
+        fc_properties = self.driver.initialize_connection(hyper_volume,
+                                                          FakeConnector)
+        self.assertEqual(1, fc_properties['data']['target_lun'])
+
     def test_terminate_connection_success(self):
         self.driver.client.terminateFlag = True
         self.driver.terminate_connection(test_volume, FakeConnector)
         self.assertTrue(self.driver.client.terminateFlag)
 
+    def test_terminate_connection_hypermetro_in_metadata(self):
+        self.driver.terminate_connection(hyper_volume, FakeConnector)
+
     def test_get_volume_status(self):
         remote_device_info = {"ARRAYTYPE": "1",
                               "HEALTHSTATUS": "1",
index 80e02b6008947149dd45ef2de5b9e48685eeaebd..50b27b73aec846ce6f66caec75d6ee66d0dc91ca 100644 (file)
@@ -271,8 +271,7 @@ class HuaweiBaseDriver(driver.VolumeDriver):
         if opts.get('hypermetro') == 'true':
             metro = hypermetro.HuaweiHyperMetro(self.client,
                                                 self.rmt_client,
-                                                self.configuration,
-                                                self.db)
+                                                self.configuration)
             try:
                 metro_info = metro.create_hypermetro(lun_id, lun_params)
                 model_update['metadata'].update(metro_info)
@@ -345,8 +344,7 @@ class HuaweiBaseDriver(driver.VolumeDriver):
         if 'hypermetro_id' in metadata:
             metro = hypermetro.HuaweiHyperMetro(self.client,
                                                 self.rmt_client,
-                                                self.configuration,
-                                                self.db)
+                                                self.configuration)
             try:
                 metro.delete_hypermetro(volume)
             except exception.VolumeBackendAPIException as err:
@@ -1716,6 +1714,7 @@ class HuaweiFCDriver(HuaweiBaseDriver, driver.FibreChannelDriver):
         LOG.info(_LI("initialize_connection, metadata is: %s."), metadata)
         if 'hypermetro_id' in metadata:
             hyperm = hypermetro.HuaweiHyperMetro(self.client,
+                                                 self.rmt_client,
                                                  self.configuration)
             rmt_fc_info = hyperm.connect_volume_fc(volume, connector)
 
@@ -1877,6 +1876,7 @@ class HuaweiFCDriver(HuaweiBaseDriver, driver.FibreChannelDriver):
 
         if 'hypermetro_id' in metadata:
             hyperm = hypermetro.HuaweiHyperMetro(self.client,
+                                                 self.rmt_client,
                                                  self.configuration)
             hyperm.disconnect_volume_fc(volume, connector)
 
index 0db361334ffd56b0f68d4627a1c1612774a80298..f1ff77a81ca0b8e88de869e849506edf23232268 100644 (file)
@@ -26,8 +26,7 @@ LOG = logging.getLogger(__name__)
 
 class HuaweiHyperMetro(object):
 
-    def __init__(self, client, rmt_client, configuration, db):
-        self.db = db
+    def __init__(self, client, rmt_client, configuration):
         self.client = client
         self.rmt_client = rmt_client
         self.configuration = configuration