From 0254d0f0f690a8950085f61a81bac410eb4cc333 Mon Sep 17 00:00:00 2001 From: Yusuke Hayashi Date: Fri, 26 Dec 2014 21:21:04 +0900 Subject: [PATCH] Move 3 Fujitsu ETERNUS DX related file Since there are three volume driver files relating to Fujitsu ETERNUS DX in cinder.volume.drivers, I make 'fujitsu' directory at cinder.volume.drivers and I move these files to the directory. Closes-Bug: #1402349 Change-Id: I449346fa86940113f5b9e7a7108338b45e981053 --- cinder/tests/test_fujitsu.py | 21 +++--- cinder/tests/test_fujitsu_compatibility.py | 69 +++++++++++++++++++ cinder/volume/drivers/fujitsu/__init__.py | 0 .../eternus_dx_common.py} | 0 .../eternus_dx_fc.py} | 4 +- .../eternus_dx_iscsi.py} | 4 +- cinder/volume/manager.py | 6 +- 7 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 cinder/tests/test_fujitsu_compatibility.py create mode 100644 cinder/volume/drivers/fujitsu/__init__.py rename cinder/volume/drivers/{fujitsu_eternus_dx_common.py => fujitsu/eternus_dx_common.py} (100%) rename cinder/volume/drivers/{fujitsu_eternus_dx_fc.py => fujitsu/eternus_dx_fc.py} (98%) rename cinder/volume/drivers/{fujitsu_eternus_dx_iscsi.py => fujitsu/eternus_dx_iscsi.py} (98%) diff --git a/cinder/tests/test_fujitsu.py b/cinder/tests/test_fujitsu.py index 9b22fb966..08fa8e2e8 100644 --- a/cinder/tests/test_fujitsu.py +++ b/cinder/tests/test_fujitsu.py @@ -23,9 +23,9 @@ from cinder import exception from cinder.i18n import _LW from cinder.openstack.common import log as logging from cinder import test -from cinder.volume.drivers.fujitsu_eternus_dx_common import FJDXCommon -from cinder.volume.drivers.fujitsu_eternus_dx_fc import FJDXFCDriver -from cinder.volume.drivers.fujitsu_eternus_dx_iscsi import FJDXISCSIDriver +import cinder.volume.drivers.fujitsu.eternus_dx_common as eternus_dx_common +import cinder.volume.drivers.fujitsu.eternus_dx_fc as eternus_dx_fc +import cinder.volume.drivers.fujitsu.eternus_dx_iscsi as eternus_dx_iscsi CONFIG_FILE_NAME = 'cinder_fujitsu_eternus_dx.xml' STORAGE_SYSTEM = '172.16.0.2' @@ -653,15 +653,15 @@ class FJFCDriverTestCase(test.TestCase): # replace some configuration function with fake # self.stubs.Set(self.driver.configuration, 'safe_get', # self.fake_configuration_safe_get) - self.stubs.Set(FJDXCommon, '_get_ecom_connection', + self.stubs.Set(eternus_dx_common.FJDXCommon, '_get_ecom_connection', self.fake_ecom_connection) instancename = FakeCIMInstanceName() - self.stubs.Set(FJDXCommon, '_getinstancename', + self.stubs.Set(eternus_dx_common.FJDXCommon, '_getinstancename', instancename.fake_getinstancename) # set fc driver to self.driver - driver = FJDXFCDriver(configuration=self.configuration) + driver = eternus_dx_fc.FJDXFCDriver(configuration=self.configuration) driver.db = FakeDB() self.driver = driver @@ -735,18 +735,19 @@ class FJISCSIDriverTestCase(test.TestCase): # self.stubs.Set(self.driver.configuration, 'safe_get', # self.fake_configuration_safe_get) - self.stubs.Set(FJDXISCSIDriver, '_do_iscsi_discovery', + self.stubs.Set(eternus_dx_iscsi.FJDXISCSIDriver, '_do_iscsi_discovery', self.fake_do_iscsi_discovery) - self.stubs.Set(FJDXCommon, '_get_ecom_connection', + self.stubs.Set(eternus_dx_common.FJDXCommon, '_get_ecom_connection', self.fake_ecom_connection) instancename = FakeCIMInstanceName() - self.stubs.Set(FJDXCommon, '_getinstancename', + self.stubs.Set(eternus_dx_common.FJDXCommon, '_getinstancename', instancename.fake_getinstancename) # set iscsi driver to self.driver - driver = FJDXISCSIDriver(configuration=self.configuration) + driver = ( + eternus_dx_iscsi.FJDXISCSIDriver(configuration=self.configuration)) driver.db = FakeDB() self.driver = driver diff --git a/cinder/tests/test_fujitsu_compatibility.py b/cinder/tests/test_fujitsu_compatibility.py new file mode 100644 index 000000000..c5992886e --- /dev/null +++ b/cinder/tests/test_fujitsu_compatibility.py @@ -0,0 +1,69 @@ +# Copyright (c) 2015 FUJITSU LIMITED +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from oslo_config import cfg +from oslo_utils import importutils + +from cinder import test +import cinder.volume.drivers.fujitsu.eternus_dx_common as eternus_dx_common + + +CONF = cfg.CONF + +FUJITSU_FC_MODULE = ('cinder.volume.drivers.fujitsu.' + 'eternus_dx_fc.FJDXFCDriver') + +FUJITSU_ISCSI_MODULE = ('cinder.volume.drivers.fujitsu.' + 'eternus_dx_iscsi.FJDXISCSIDriver') + + +class FJDriverCompatibility(test.TestCase): + + def setUp(self): + super(FJDriverCompatibility, self).setUp() + self.manager = importutils.import_object(CONF.volume_manager) + + # Stub definition + self.stubs.Set( + eternus_dx_common.FJDXCommon, '__init__', self.fake_init) + + def _load_driver(self, driver): + self.manager.__init__(volume_driver=driver) + + def _driver_module_name(self): + return "%s.%s" % (self.manager.driver.__class__.__module__, + self.manager.driver.__class__.__name__) + + def fake_init(self, prtcl, configuration=None): + msg = "selected protocol is %s" % prtcl + self.assertTrue((prtcl == 'FC') or (prtcl == 'iSCSI'), msg=msg) + + def test_fujitsu_driver_fc_old(self): + self._load_driver( + 'cinder.volume.drivers.fujitsu_eternus_dx_fc.FJDXFCDriver') + self.assertEqual(FUJITSU_FC_MODULE, self._driver_module_name()) + + def test_fujitsu_driver_fc_new(self): + self._load_driver(FUJITSU_FC_MODULE) + self.assertEqual(FUJITSU_FC_MODULE, self._driver_module_name()) + + def test_fujitsu_driver_iscsi_old(self): + self._load_driver( + 'cinder.volume.drivers.fujitsu_eternus_dx_iscsi.FJDXISCSIDriver') + self.assertEqual(FUJITSU_ISCSI_MODULE, self._driver_module_name()) + + def test_fujitsu_driver_iscsi_new(self): + self._load_driver(FUJITSU_ISCSI_MODULE) + self.assertEqual(FUJITSU_ISCSI_MODULE, self._driver_module_name()) diff --git a/cinder/volume/drivers/fujitsu/__init__.py b/cinder/volume/drivers/fujitsu/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cinder/volume/drivers/fujitsu_eternus_dx_common.py b/cinder/volume/drivers/fujitsu/eternus_dx_common.py similarity index 100% rename from cinder/volume/drivers/fujitsu_eternus_dx_common.py rename to cinder/volume/drivers/fujitsu/eternus_dx_common.py diff --git a/cinder/volume/drivers/fujitsu_eternus_dx_fc.py b/cinder/volume/drivers/fujitsu/eternus_dx_fc.py similarity index 98% rename from cinder/volume/drivers/fujitsu_eternus_dx_fc.py rename to cinder/volume/drivers/fujitsu/eternus_dx_fc.py index 0d71d4fdc..695538a0a 100644 --- a/cinder/volume/drivers/fujitsu_eternus_dx_fc.py +++ b/cinder/volume/drivers/fujitsu/eternus_dx_fc.py @@ -23,7 +23,7 @@ import six from cinder import context from cinder.openstack.common import log as logging from cinder.volume import driver -from cinder.volume.drivers import fujitsu_eternus_dx_common +from cinder.volume.drivers.fujitsu import eternus_dx_common from cinder.zonemanager import utils as fczm_utils LOG = logging.getLogger(__name__) @@ -37,7 +37,7 @@ class FJDXFCDriver(driver.FibreChannelDriver): def __init__(self, *args, **kwargs): super(FJDXFCDriver, self).__init__(*args, **kwargs) - self.common = fujitsu_eternus_dx_common.FJDXCommon( + self.common = eternus_dx_common.FJDXCommon( 'FC', configuration=self.configuration) diff --git a/cinder/volume/drivers/fujitsu_eternus_dx_iscsi.py b/cinder/volume/drivers/fujitsu/eternus_dx_iscsi.py similarity index 98% rename from cinder/volume/drivers/fujitsu_eternus_dx_iscsi.py rename to cinder/volume/drivers/fujitsu/eternus_dx_iscsi.py index 8ca64152c..36bb0697f 100644 --- a/cinder/volume/drivers/fujitsu_eternus_dx_iscsi.py +++ b/cinder/volume/drivers/fujitsu/eternus_dx_iscsi.py @@ -25,7 +25,7 @@ from cinder import exception from cinder.i18n import _, _LW from cinder.openstack.common import log as logging from cinder.volume import driver -from cinder.volume.drivers import fujitsu_eternus_dx_common +from cinder.volume.drivers.fujitsu import eternus_dx_common LOG = logging.getLogger(__name__) @@ -39,7 +39,7 @@ class FJDXISCSIDriver(driver.ISCSIDriver): super(FJDXISCSIDriver, self).__init__(*args, **kwargs) self.common = \ - fujitsu_eternus_dx_common.\ + eternus_dx_common.\ FJDXCommon('iSCSI', configuration=self.configuration) def check_for_setup_error(self): diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 4c3c31b93..755b90971 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -107,7 +107,11 @@ MAPPING = { 'cinder.volume.drivers.huawei.huawei_hvs.HuaweiHVSISCSIDriver': 'cinder.volume.drivers.huawei.huawei_18000.Huawei18000ISCSIDriver', 'cinder.volume.drivers.huawei.huawei_hvs.HuaweiHVSFCDriver': - 'cinder.volume.drivers.huawei.huawei_18000.Huawei18000FCDriver', } + 'cinder.volume.drivers.huawei.huawei_18000.Huawei18000FCDriver', + 'cinder.volume.drivers.fujitsu_eternus_dx_fc.FJDXFCDriver': + 'cinder.volume.drivers.fujitsu.eternus_dx_fc.FJDXFCDriver', + 'cinder.volume.drivers.fujitsu_eternus_dx_iscsi.FJDXISCSIDriver': + 'cinder.volume.drivers.fujitsu.eternus_dx_iscsi.FJDXISCSIDriver', } def locked_volume_operation(f): -- 2.45.2