diff options
author | Andrew Beresford <andrew.beresford@investbook.co.uk> | 2020-04-02 23:08:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 18:08:02 -0400 |
commit | 723e2bc1ad14687a8d6846b9ca73620e4e4090b1 (patch) | |
tree | e83718b8fa9ab06b4ff29487577ea0ef68d3ccc1 /cloudinit | |
parent | bec8f387252ac32e1fd7963cf871ceed8d313edd (diff) | |
download | vyos-cloud-init-723e2bc1ad14687a8d6846b9ca73620e4e4090b1.tar.gz vyos-cloud-init-723e2bc1ad14687a8d6846b9ca73620e4e4090b1.zip |
Add support for NFS/EFS mounts (#300)
The cc_mounts module does not support NFS mounts in the form of hostname:/ or hostname:/path.
This PR adds support for NFS-style paths in the fs_spec field.
LP: #1870370
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_mounts.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py index 4ae3f1fc..73537e71 100644 --- a/cloudinit/config/cc_mounts.py +++ b/cloudinit/config/cc_mounts.py @@ -74,6 +74,9 @@ from cloudinit import util # Shortname matches 'sda', 'sda1', 'xvda', 'hda', 'sdb', xvdb, vda, vdd1, sr0 DEVICE_NAME_FILTER = r"^([x]{0,1}[shv]d[a-z][0-9]*|sr[0-9]+)$" DEVICE_NAME_RE = re.compile(DEVICE_NAME_FILTER) +# Name matches 'server:/path' +NETWORK_NAME_FILTER = r"^.+:.*" +NETWORK_NAME_RE = re.compile(NETWORK_NAME_FILTER) WS = re.compile("[%s]+" % (whitespace)) FSTAB_PATH = "/etc/fstab" MNT_COMMENT = "comment=cloudconfig" @@ -93,6 +96,13 @@ def is_meta_device_name(name): return False +def is_network_device(name): + # return true if this is a network device + if NETWORK_NAME_RE.match(name): + return True + return False + + def _get_nth_partition_for_device(device_path, partition_number): potential_suffixes = [str(partition_number), 'p%s' % (partition_number,), '-part%s' % (partition_number,)] @@ -122,6 +132,9 @@ def sanitize_devname(startname, transformer, log): devname = "ephemeral0" log.debug("Adjusted mount option from ephemeral to ephemeral0") + if is_network_device(startname): + return startname + device_path, partition_number = util.expand_dotted_devname(devname) if is_meta_device_name(device_path): |