in src/mount_efs/__init__.py [0:0]
def mount_nfs(config, dns_name, path, mountpoint, options, fallback_ip_address=None):
if legacy_stunnel_mode_enabled(options, config):
if "tls" in options:
mount_path = "127.0.0.1:%s" % path
elif fallback_ip_address:
if is_ipv6_address(fallback_ip_address):
mount_path = f"[{fallback_ip_address}]:{path}"
else:
mount_path = "%s:%s" % (fallback_ip_address, path)
else:
mount_path = "%s:%s" % (dns_name, path)
else:
mount_path = "127.0.0.1:%s" % path
nfs_options = get_nfs_mount_options(options, config)
if not check_if_platform_is_mac():
command = [
"/sbin/mount.nfs4",
mount_path,
mountpoint,
"-o",
nfs_options,
]
else:
command = [
"/sbin/mount_nfs",
"-o",
nfs_options,
mount_path,
mountpoint,
]
if "netns" in options:
command = ["nsenter", "--net=" + options["netns"]] + command
if call_nfs_mount_command_with_retry_succeed(
config, options, command, dns_name, mountpoint
):
return
logging.info('Executing: "%s"', " ".join(command))
proc = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True
)
out, err = proc.communicate()
if proc.returncode == 0:
post_mount_nfs_success(config, options, dns_name, mountpoint)
else:
message = 'Failed to mount %s at %s: returncode=%d, stderr="%s"' % (
dns_name,
mountpoint,
proc.returncode,
err.strip(),
)
fatal_error(err.strip(), message, proc.returncode)