From 1538251464826034613ce6b711761689308442c2 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Fri, 3 May 2019 16:04:23 +0000 Subject: [PATCH] move NVMEOF exception to target file This patch moves the NVMEof specific exception from cinder/exception to the target driver file itself. Change-Id: I18925ae7c8d10588b810a7ac5371b81c98227306 --- cinder/exception.py | 5 ----- cinder/tests/unit/targets/test_nvmeof_driver.py | 2 +- cinder/volume/targets/nvmeof.py | 8 +++++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cinder/exception.py b/cinder/exception.py index 6a418a2e97c..73e95c10433 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -1304,8 +1304,3 @@ class ServiceUserTokenNoAuth(CinderException): message = _("The [service_user] send_service_user_token option was " "requested, but no service auth could be loaded. Please check " "the [service_user] configuration section.") - - -class UnsupportedNVMETProtocol(Invalid): - message = _("An invalid 'target_protocol' " - "value was provided: %(protocol)s") diff --git a/cinder/tests/unit/targets/test_nvmeof_driver.py b/cinder/tests/unit/targets/test_nvmeof_driver.py index 31f80ef3051..102a41a6eed 100644 --- a/cinder/tests/unit/targets/test_nvmeof_driver.py +++ b/cinder/tests/unit/targets/test_nvmeof_driver.py @@ -133,7 +133,7 @@ class TestNVMeOFDriver(tf.TargetDriverFixture): def test_invalid_target_protocol(self): self.configuration.target_protocol = 'iser' - self.assertRaises(exception.UnsupportedNVMETProtocol, + self.assertRaises(nvmeof.UnsupportedNVMETProtocol, FakeNVMeOFDriver, root_helper=utils.get_root_helper(), configuration=self.configuration) diff --git a/cinder/volume/targets/nvmeof.py b/cinder/volume/targets/nvmeof.py index 8a97e9e3d31..c4d30062c4d 100644 --- a/cinder/volume/targets/nvmeof.py +++ b/cinder/volume/targets/nvmeof.py @@ -15,12 +15,18 @@ import abc from oslo_log import log as logging from cinder import exception +from cinder.i18n import _ from cinder.volume.targets import driver LOG = logging.getLogger(__name__) +class UnsupportedNVMETProtocol(exception.Invalid): + message = _("An invalid 'target_protocol' " + "value was provided: %(protocol)s") + + class NVMeOF(driver.Target): """Target object for block storage devices with RDMA transport.""" @@ -44,7 +50,7 @@ class NVMeOF(driver.Target): self.nvme_transport_type = self.target_protocol_map[ target_protocol] else: - raise exception.UnsupportedNVMETProtocol( + raise UnsupportedNVMETProtocol( protocol=target_protocol )