Move newly created NFS exceptions to standard location in exception.py
Addresses bug 1037619 bug 1037619 Change-Id: I20b1c612c03ef90eeb074814b979a9bc7492109c
This commit is contained in:
@@ -478,3 +478,15 @@ class InstanceNotFound(NotFound):
|
||||
class VolumeBackendAPIException(CinderException):
|
||||
message = _("Bad or unexpected response from the storage volume "
|
||||
"backend API: %(data)s")
|
||||
|
||||
|
||||
class NfsException(CinderException):
|
||||
message = _("Unknown NFS exception")
|
||||
|
||||
|
||||
class NfsNoSharesMounted(NotFound):
|
||||
message = _("No mounted NFS shares found")
|
||||
|
||||
|
||||
class NfsNoSuitableShareFound(NotFound):
|
||||
message = _("There is no share which can host %(volume_size)sG")
|
||||
|
||||
@@ -26,6 +26,7 @@ from mox import IgnoreArg
|
||||
from mox import stubout
|
||||
|
||||
from cinder import context
|
||||
from cinder import exception
|
||||
from cinder import test
|
||||
from cinder.exception import ProcessExecutionError
|
||||
|
||||
@@ -374,7 +375,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
nfs.FLAGS.nfs_shares_config = self.TEST_SHARES_CONFIG_FILE
|
||||
|
||||
self.assertRaises(nfs.NfsException,
|
||||
self.assertRaises(exception.NfsException,
|
||||
drv.do_setup, IsA(context.RequestContext))
|
||||
|
||||
def test_setup_should_throw_exception_if_nfs_client_is_not_installed(self):
|
||||
@@ -392,7 +393,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
mox.ReplayAll()
|
||||
|
||||
self.assertRaises(nfs.NfsException,
|
||||
self.assertRaises(exception.NfsException,
|
||||
drv.do_setup, IsA(context.RequestContext))
|
||||
|
||||
mox.VerifyAll()
|
||||
@@ -403,7 +404,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
drv._mounted_shares = []
|
||||
|
||||
self.assertRaises(nfs.NfsException, drv._find_share,
|
||||
self.assertRaises(exception.NotFound, drv._find_share,
|
||||
self.TEST_SIZE_IN_GB)
|
||||
|
||||
def test_find_share(self):
|
||||
@@ -441,7 +442,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
mox.ReplayAll()
|
||||
|
||||
self.assertRaises(nfs.NfsNoSuitableShareFound, drv._find_share,
|
||||
self.assertRaises(exception.NfsNoSuitableShareFound, drv._find_share,
|
||||
self.TEST_SIZE_IN_GB)
|
||||
|
||||
mox.VerifyAll()
|
||||
|
||||
@@ -48,18 +48,6 @@ FLAGS = flags.FLAGS
|
||||
FLAGS.register_opts(volume_opts)
|
||||
|
||||
|
||||
class NfsException(exception.CinderException):
|
||||
pass
|
||||
|
||||
|
||||
class NfsNoSharesMounted(NfsException):
|
||||
pass
|
||||
|
||||
|
||||
class NfsNoSuitableShareFound(NfsException):
|
||||
pass
|
||||
|
||||
|
||||
class NfsDriver(driver.VolumeDriver):
|
||||
"""NFS based cinder driver. Creates file on NFS share for using it
|
||||
as block device on hypervisor."""
|
||||
@@ -74,13 +62,13 @@ class NfsDriver(driver.VolumeDriver):
|
||||
if not config or not os.path.exists(config):
|
||||
msg = _("NFS config file doesn't exist")
|
||||
LOG.warn(msg)
|
||||
raise NfsException(msg)
|
||||
raise exception.NfsException(msg)
|
||||
|
||||
try:
|
||||
self._execute('mount.nfs', check_exit_code=False)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.ENOENT:
|
||||
raise NfsException('mount.nfs is not installed')
|
||||
raise exception.NfsException('mount.nfs is not installed')
|
||||
else:
|
||||
raise
|
||||
|
||||
@@ -229,8 +217,7 @@ class NfsDriver(driver.VolumeDriver):
|
||||
"""
|
||||
|
||||
if not self._mounted_shares:
|
||||
raise NfsNoSharesMounted(
|
||||
_("There is no any mounted NFS share found"))
|
||||
raise exception.NfsNoSharesMounted()
|
||||
|
||||
greatest_size = 0
|
||||
greatest_share = None
|
||||
@@ -242,8 +229,8 @@ class NfsDriver(driver.VolumeDriver):
|
||||
greatest_size = capacity
|
||||
|
||||
if volume_size_for * 1024 * 1024 * 1024 > greatest_size:
|
||||
raise NfsNoSuitableShareFound(
|
||||
_('There is no share which can host %sG') % volume_size_for)
|
||||
raise exception.NfsNoSuitableShareFound(
|
||||
volume_size=volume_size_for)
|
||||
return greatest_share
|
||||
|
||||
def _get_mount_point_for_share(self, nfs_share):
|
||||
|
||||
Reference in New Issue
Block a user