From bffa08e758e52c6bad4faae128daa0214637631f Mon Sep 17 00:00:00 2001 From: Rafi Khardalian Date: Sat, 2 Feb 2013 01:34:53 +0000 Subject: Allow for specifying nfs mount options Fixes bug 1113042 Adds a new config option: nfs_mount_options=None (Default) When not None, anything set here will be passed as -o to the mount command. The default behavior is to do exactly as we are doing today and relying on the OS/kernel defaults. Change-Id: I935ae6f4d96c20904b7132fe8c6dfd3cbe089e51 Flags: DocImpact --- nova/virt/libvirt/volume_nfs.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nova/virt/libvirt/volume_nfs.py b/nova/virt/libvirt/volume_nfs.py index 7f721a534..fc10863b5 100755 --- a/nova/virt/libvirt/volume_nfs.py +++ b/nova/virt/libvirt/volume_nfs.py @@ -33,6 +33,10 @@ volume_opts = [ cfg.StrOpt('nfs_mount_point_base', default=paths.state_path_def('mnt'), help='Base dir where nfs expected to be mounted on compute'), + cfg.StrOpt('nfs_mount_options', + default=None, + help='Mount options passed to the nfs client. See section ' + 'of the nfs man page for details'), ] CONF = cfg.CONF CONF.register_opts(volume_opts) @@ -70,9 +74,14 @@ class NfsVolumeDriver(volume.LibvirtBaseVolumeDriver): if not self._path_exists(mount_path): utils.execute('mkdir', '-p', mount_path) + # Construct the NFS mount command. + nfs_cmd = ['mount', '-t', 'nfs'] + if CONF.nfs_mount_options is not None: + nfs_cmd.extend(['-o', CONF.nfs_mount_options]) + nfs_cmd.extend([nfs_share, mount_path]) + try: - utils.execute('mount', '-t', 'nfs', nfs_share, mount_path, - run_as_root=True) + utils.execute(*nfs_cmd, run_as_root=True) except exception.ProcessExecutionError as exc: if ensure and 'already mounted' in exc.message: LOG.warn(_("%s is already mounted"), nfs_share) -- cgit