diff options
author | Matt Riedemann <mriedem@us.ibm.com> | 2015-07-28 14:35:39 -0700 |
---|---|---|
committer | Matt Riedemann <mriedem@us.ibm.com> | 2015-08-05 09:29:23 -0700 |
commit | 39e366e569fb9fb36df4654da127c20c65431cc7 (patch) | |
tree | 040374c121d6ab67114f28d012cdecff7a0ceaa1 /nova/virt/libvirt/volume/volume.py | |
parent | 9d1f29713a27c591ff518b5724c03cd96f71ea32 (diff) | |
download | nova-39e366e569fb9fb36df4654da127c20c65431cc7.tar.gz |
libvirt: move LibvirtNFSVolumeDriver into it's own module
Part of blueprint consolidate-libvirt-fs-volume-drivers
Change-Id: Ia2b867be06400e02c3a6668102fd79ac75a228c5
Diffstat (limited to 'nova/virt/libvirt/volume/volume.py')
-rw-r--r-- | nova/virt/libvirt/volume/volume.py | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/nova/virt/libvirt/volume/volume.py b/nova/virt/libvirt/volume/volume.py index 192f4b3be9..f95d6185e7 100644 --- a/nova/virt/libvirt/volume/volume.py +++ b/nova/virt/libvirt/volume/volume.py @@ -16,10 +16,7 @@ """Volume drivers for libvirt.""" -import os - from os_brick.initiator import connector -from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log as logging import six @@ -28,7 +25,6 @@ from nova import exception from nova.i18n import _ from nova.i18n import _LE from nova.i18n import _LW -from nova import paths from nova import utils from nova.virt.libvirt import config as vconfig from nova.virt.libvirt import utils as libvirt_utils @@ -47,13 +43,6 @@ volume_opts = [ cfg.StrOpt('rbd_secret_uuid', help='The libvirt UUID of the secret for the rbd_user' 'volumes'), - cfg.StrOpt('nfs_mount_point_base', - default=paths.state_path_def('mnt'), - help='Directory where the NFS volume is mounted on the' - ' compute node'), - cfg.StrOpt('nfs_mount_options', - help='Mount options passed to the NFS client. See section ' - 'of the nfs man page for details'), cfg.BoolOpt('iscsi_use_multipath', default=False, help='Use multipath connection of the iSCSI volume'), @@ -327,82 +316,3 @@ class LibvirtISERVolumeDriver(LibvirtISCSIVolumeDriver): def _get_transport(self): return 'iser' - - -class LibvirtNFSVolumeDriver(LibvirtBaseVolumeDriver): - """Class implements libvirt part of volume driver for NFS.""" - - def __init__(self, connection): - """Create back-end to nfs.""" - super(LibvirtNFSVolumeDriver, - self).__init__(connection, is_block_dev=False) - - def _get_device_path(self, connection_info): - path = os.path.join(CONF.libvirt.nfs_mount_point_base, - utils.get_hash_str(connection_info['data']['export'])) - path = os.path.join(path, connection_info['data']['name']) - return path - - def get_config(self, connection_info, disk_info): - """Returns xml for libvirt.""" - conf = super(LibvirtNFSVolumeDriver, - self).get_config(connection_info, disk_info) - - conf.source_type = 'file' - conf.source_path = connection_info['data']['device_path'] - conf.driver_format = connection_info['data'].get('format', 'raw') - return conf - - def connect_volume(self, connection_info, disk_info): - """Connect the volume. Returns xml for libvirt.""" - options = connection_info['data'].get('options') - self._ensure_mounted(connection_info['data']['export'], options) - - connection_info['data']['device_path'] = \ - self._get_device_path(connection_info) - - def disconnect_volume(self, connection_info, disk_dev): - """Disconnect the volume.""" - - export = connection_info['data']['export'] - mount_path = os.path.join(CONF.libvirt.nfs_mount_point_base, - utils.get_hash_str(export)) - - try: - utils.execute('umount', mount_path, run_as_root=True) - except processutils.ProcessExecutionError as exc: - if ('device is busy' in exc.message or - 'target is busy' in exc.message): - LOG.debug("The NFS share %s is still in use.", export) - else: - LOG.exception(_LE("Couldn't unmount the NFS share %s"), export) - - def _ensure_mounted(self, nfs_export, options=None): - """@type nfs_export: string - @type options: string - """ - mount_path = os.path.join(CONF.libvirt.nfs_mount_point_base, - utils.get_hash_str(nfs_export)) - if not libvirt_utils.is_mounted(mount_path, nfs_export): - self._mount_nfs(mount_path, nfs_export, options, ensure=True) - return mount_path - - def _mount_nfs(self, mount_path, nfs_share, options=None, ensure=False): - """Mount nfs export to mount path.""" - utils.execute('mkdir', '-p', mount_path) - - # Construct the NFS mount command. - nfs_cmd = ['mount', '-t', 'nfs'] - if CONF.libvirt.nfs_mount_options is not None: - nfs_cmd.extend(['-o', CONF.libvirt.nfs_mount_options]) - if options: - nfs_cmd.extend(options.split(' ')) - nfs_cmd.extend([nfs_share, mount_path]) - - try: - utils.execute(*nfs_cmd, run_as_root=True) - except processutils.ProcessExecutionError as exc: - if ensure and 'already mounted' in exc.message: - LOG.warn(_LW("%s is already mounted"), nfs_share) - else: - raise |