diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-21 19:47:27 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-21 19:47:27 -0700 |
commit | 57d5e5647bf289da854dc717a9f70d28abf5a708 (patch) | |
tree | 0f03646b290a0820cbb94c421ec9ec5180b29b3d /cloudinit/util.py | |
parent | c49507a221464ce0f9747d4371f8e3d1d1b30abd (diff) | |
download | vyos-cloud-init-57d5e5647bf289da854dc717a9f70d28abf5a708.tar.gz vyos-cloud-init-57d5e5647bf289da854dc717a9f70d28abf5a708.zip |
1. Update the comment about fstab to just point to 'man fstab'
2. Update the mount point adding of '/' to just add it in one place if it does not already exist
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index f0a65fa3..3aa4e462 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1100,7 +1100,7 @@ def mounts(): # Go through mounts to see what is already mounted mount_locs = load_file("/proc/mounts").splitlines() for mpline in mount_locs: - # Format at: http://linux.die.net/man/5/fstab + # Format at: man fstab try: (dev, mp, fstype, opts, _freq, _passno) = mpline.split() except: @@ -1129,7 +1129,7 @@ def mount_cb(device, callback, data=None, rw=False, mtype=None, sync=True): with tempdir() as tmpd: umount = False if device in mounted: - mountpoint = "%s/" % mounted[device]['mountpoint'] + mountpoint = mounted[device]['mountpoint'] else: try: mountcmd = ['mount'] @@ -1140,7 +1140,7 @@ def mount_cb(device, callback, data=None, rw=False, mtype=None, sync=True): mountopts.append('ro') if sync: # This seems like the safe approach to do - # (where this is on by default) + # (ie where this is on by default) mountopts.append("sync") if mountopts: mountcmd.extend(["-o", ",".join(mountopts)]) @@ -1149,12 +1149,15 @@ def mount_cb(device, callback, data=None, rw=False, mtype=None, sync=True): mountcmd.append(device) mountcmd.append(tmpd) subp(mountcmd) - umount = tmpd + umount = tmpd # This forces it to be unmounted (when set) + mountpoint = tmpd except (IOError, OSError) as exc: raise MountFailedError(("Failed mounting %s " "to %s due to: %s") % (device, tmpd, exc)) - mountpoint = "%s/" % tmpd + # Be nice and ensure it ends with a slash + if not mountpoint.endswith("/"): + mountpoint += "/" with unmounter(umount): if data is None: ret = callback(mountpoint) |