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 <options> 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: I6bd27f9d0e8848a9ba98318ba7288e43ee6b4cb9
Flags: DocImpact
This commit is contained in:
Rafi Khardalian 2013-02-02 23:01:54 +00:00
parent da5bfac8c9
commit 1d25f99f40
2 changed files with 18 additions and 3 deletions
cinder/volume/drivers
etc/cinder

16
cinder/volume/drivers/nfs.py Normal file → Executable file

@ -41,7 +41,12 @@ volume_opts = [
default=True,
help=('Create volumes as sparsed files which take no space.'
'If set to False volume is created as regular file.'
'In such case volume creation takes a lot of time.'))]
'In such case volume creation takes a lot of time.')),
cfg.StrOpt('nfs_mount_options',
default=None,
help='Mount options passed to the nfs client. See section '
'of the nfs man page for details'),
]
FLAGS = flags.FLAGS
FLAGS.register_opts(volume_opts)
@ -270,9 +275,14 @@ class NfsDriver(driver.VolumeDriver):
if not self._path_exists(mount_path):
self._execute('mkdir', '-p', mount_path)
# Construct the NFS mount command.
nfs_cmd = ['mount', '-t', 'nfs']
if FLAGS.nfs_mount_options is not None:
nfs_cmd.extend(['-o', FLAGS.nfs_mount_options])
nfs_cmd.extend([nfs_share, mount_path])
try:
self._execute('mount', '-t', 'nfs', nfs_share, mount_path,
run_as_root=True)
self._execute(*nfs_cmd, run_as_root=True)
except exception.ProcessExecutionError as exc:
if ensure and 'already mounted' in exc.stderr:
LOG.warn(_("%s is already mounted"), nfs_share)

@ -882,6 +882,11 @@
# volume creation takes a lot of time. (boolean value)
#nfs_sparsed_volumes=true
# Mount options passed to the nfs client (string value)
# The value set here is passed directly to the -o flag
# of the mount command. See the nfs man page for details.
#nfs_mount_options=None
#
# Options defined in cinder.volume.drivers.rbd