diff options
author | Igor Galić <igalic@brainsware.at> | 2018-11-14 22:02:18 +0000 |
---|---|---|
committer | Server Team CI Bot <josh.powers+server-team-bot@canonical.com> | 2018-11-14 22:02:18 +0000 |
commit | a3812a4ab4eeb2aa185eb4a2de186cc60ddd7c03 (patch) | |
tree | fec2e54908fb77409acc56ad57a00910c5b0cfd0 /cloudinit | |
parent | 6062595b83e08e0f12e1fe6d8e367d8db9d91ef8 (diff) | |
download | vyos-cloud-init-a3812a4ab4eeb2aa185eb4a2de186cc60ddd7c03.tar.gz vyos-cloud-init-a3812a4ab4eeb2aa185eb4a2de186cc60ddd7c03.zip |
resizefs: Prefix discovered devpath with '/dev/' when path does not exist
In some environments, like FreeBSD, gpart can return the device basename
instead of the full path. If this discovered devpath does not exist and
is missing the '/dev/' prefix, add that prefix in an attempt to find the
device.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_resizefs.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py index 2edddd0c..076b9d5a 100644 --- a/cloudinit/config/cc_resizefs.py +++ b/cloudinit/config/cc_resizefs.py @@ -197,6 +197,13 @@ def maybe_get_writable_device_path(devpath, info, log): if devpath.startswith('gpt/'): log.debug('We have a gpt label - just go ahead') return devpath + # Alternatively, our device could simply be a name as returned by gpart, + # such as da0p3 + if not devpath.startswith('/dev/') and not os.path.exists(devpath): + fulldevpath = '/dev/' + devpath.lstrip('/') + log.debug("'%s' doesn't appear to be a valid device path. Trying '%s'", + devpath, fulldevpath) + devpath = fulldevpath try: statret = os.stat(devpath) |