From: GaoZqiang Date: Wed, 17 Feb 2016 00:47:26 +0000 (+0800) Subject: Modify the number of params of hypermetro in HuaweiDriver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4c692ba36341f705443791e7b103b340f4e715ff;p=openstack-build%2Fcinder-build.git Modify the number of params of hypermetro in HuaweiDriver 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 --- diff --git a/cinder/tests/unit/test_huawei_drivers.py b/cinder/tests/unit/test_huawei_drivers.py index 6ea717e6b..d76209606 100644 --- a/cinder/tests/unit/test_huawei_drivers.py +++ b/cinder/tests/unit/test_huawei_drivers.py @@ -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", diff --git a/cinder/volume/drivers/huawei/huawei_driver.py b/cinder/volume/drivers/huawei/huawei_driver.py index 80e02b600..50b27b73a 100644 --- a/cinder/volume/drivers/huawei/huawei_driver.py +++ b/cinder/volume/drivers/huawei/huawei_driver.py @@ -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) diff --git a/cinder/volume/drivers/huawei/hypermetro.py b/cinder/volume/drivers/huawei/hypermetro.py index 0db361334..f1ff77a81 100644 --- a/cinder/volume/drivers/huawei/hypermetro.py +++ b/cinder/volume/drivers/huawei/hypermetro.py @@ -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