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: I935ae6f4d96c20904b7132fe8c6dfd3cbe089e51 Flags: DocImpact
This commit is contained in:
parent
ee955d272a
commit
bffa08e758
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user