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
This commit is contained in:
Walter A. Boring IV 2019-05-03 16:04:23 +00:00
parent 22e09a4bf3
commit 1538251464
3 changed files with 8 additions and 7 deletions

View File

@ -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")

View File

@ -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)

View File

@ -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
)