diff --git a/cinder/volume/drivers/nfs.py b/cinder/volume/drivers/nfs.py old mode 100644 new mode 100755 index 4ebf377e7..ebf157582 --- a/cinder/volume/drivers/nfs.py +++ b/cinder/volume/drivers/nfs.py @@ -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) diff --git a/etc/cinder/cinder.conf.sample b/etc/cinder/cinder.conf.sample index 5553f0a96..e7b2c9463 100644 --- a/etc/cinder/cinder.conf.sample +++ b/etc/cinder/cinder.conf.sample @@ -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