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")
from mox import stubout
from cinder import context
+from cinder import exception
from cinder import test
from cinder.exception import ProcessExecutionError
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):
mox.ReplayAll()
- self.assertRaises(nfs.NfsException,
+ self.assertRaises(exception.NfsException,
drv.do_setup, IsA(context.RequestContext))
mox.VerifyAll()
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):
mox.ReplayAll()
- self.assertRaises(nfs.NfsNoSuitableShareFound, drv._find_share,
+ self.assertRaises(exception.NfsNoSuitableShareFound, drv._find_share,
self.TEST_SIZE_IN_GB)
mox.VerifyAll()
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."""
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
"""
if not self._mounted_shares:
- raise NfsNoSharesMounted(
- _("There is no any mounted NFS share found"))
+ raise exception.NfsNoSharesMounted()
greatest_size = 0
greatest_share = None
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):