move smbfs exceptions

This patch moves the smbfs driver exceptions to the driver.

Change-Id: Id03022b2871cbb13a9c80521dff21f52b06d5b69
This commit is contained in:
Walter A. Boring IV 2019-05-09 18:53:44 +00:00
parent 05ddc36dd7
commit 7e038bc2e9
3 changed files with 23 additions and 24 deletions

View File

@ -1038,19 +1038,6 @@ class NfsNoSuitableShareFound(RemoteFSNoSuitableShareFound):
message = _("There is no share which can host %(volume_size)sG")
# Smbfs driver
class SmbfsException(RemoteFSException):
message = _("Unknown SMBFS exception.")
class SmbfsNoSharesMounted(RemoteFSNoSharesMounted):
message = _("No mounted SMBFS shares found.")
class SmbfsNoSuitableShareFound(RemoteFSNoSuitableShareFound):
message = _("There is no share which can host %(volume_size)sG.")
# Virtuozzo Storage Driver
class VzStorageException(RemoteFSException):

View File

@ -113,7 +113,7 @@ class WindowsSmbFsTestCase(test.TestCase):
self._smbfs_driver.configuration = config
if not (config.smbfs_shares_config and share_config_exists):
self.assertRaises(exception.SmbfsException,
self.assertRaises(smbfs.SmbfsException,
self._smbfs_driver.do_setup,
mock.sentinel.context)
else:
@ -153,7 +153,7 @@ class WindowsSmbFsTestCase(test.TestCase):
'share0': 'pool0',
'share1': 'pool0'
}
self.assertRaises(exception.SmbfsException,
self.assertRaises(smbfs.SmbfsException,
self._smbfs_driver._setup_pool_mappings)
def test_initialize_connection(self):
@ -322,7 +322,7 @@ class WindowsSmbFsTestCase(test.TestCase):
supported_fmts = self._smbfs_driver._SUPPORTED_IMAGE_FORMATS
if volume_format.lower() not in supported_fmts:
self.assertRaises(exception.SmbfsException,
self.assertRaises(smbfs.SmbfsException,
self._smbfs_driver.get_volume_format,
self.volume,
qemu_format)
@ -862,7 +862,7 @@ class WindowsSmbFsTestCase(test.TestCase):
def test_get_pool_name_from_share_exception(self):
self._smbfs_driver._pool_mappings = {}
self.assertRaises(exception.SmbfsException,
self.assertRaises(smbfs.SmbfsException,
self._smbfs_driver._get_share_from_pool_name,
mock.sentinel.pool)

View File

@ -64,6 +64,18 @@ CONF = cfg.CONF
CONF.register_opts(volume_opts, group=configuration.SHARED_CONF_GROUP)
class SmbfsException(exception.RemoteFSException):
message = _("Unknown SMBFS exception.")
class SmbfsNoSharesMounted(exception.RemoteFSNoSharesMounted):
message = _("No mounted SMBFS shares found.")
class SmbfsNoSuitableShareFound(exception.RemoteFSNoSuitableShareFound):
message = _("There is no share which can host %(volume_size)sG.")
@interface.volumedriver
class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
remotefs_drv.RemoteFSPoolMixin,
@ -139,16 +151,16 @@ class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
if not config:
msg = (_("SMBFS config file not set (smbfs_shares_config)."))
LOG.error(msg)
raise exception.SmbfsException(msg)
raise SmbfsException(msg)
if not os.path.exists(config):
msg = (_("SMBFS config file at %(config)s doesn't exist.") %
{'config': config})
LOG.error(msg)
raise exception.SmbfsException(msg)
raise SmbfsException(msg)
if not os.path.isabs(self.base):
msg = _("Invalid mount point base: %s") % self.base
LOG.error(msg)
raise exception.SmbfsException(msg)
raise SmbfsException(msg)
self.shares = {} # address : options
self._ensure_shares_mounted()
@ -163,7 +175,7 @@ class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
if duplicate_pools:
msg = _("Found multiple mappings for pools %(pools)s. "
"Requested pool mappings: %(pool_mappings)s")
raise exception.SmbfsException(
raise SmbfsException(
msg % dict(pools=duplicate_pools,
pool_mappings=self._pool_mappings))
@ -221,7 +233,7 @@ class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
if sys.platform != 'win32':
_msg = _("This system platform (%s) is not supported. This "
"driver supports only Win32 platforms.") % sys.platform
raise exception.SmbfsException(_msg)
raise SmbfsException(_msg)
def _get_total_allocated(self, smbfs_share):
pool_name = self._get_pool_name_from_share(smbfs_share)
@ -276,7 +288,7 @@ class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
volume_format = ext
else:
# Hyper-V relies on file extensions so we're enforcing them.
raise exception.SmbfsException(
raise SmbfsException(
_("Invalid image file extension: %s") % ext)
else:
volume_format = (
@ -635,7 +647,7 @@ class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
if not share:
msg = _("Could not find any share for pool %(pool_name)s. "
"Pool mappings: %(pool_mappings)s.")
raise exception.SmbfsException(
raise SmbfsException(
msg % dict(pool_name=pool_name,
pool_mappings=self._pool_mappings))
return share