40184939 |
diff -rup cloud-init-0.7.9/cloudinit/config/cc_growpart.py cloud-init-0.7.9-new/cloudinit/config/cc_growpart.py
--- cloud-init-0.7.9/cloudinit/config/cc_growpart.py 2016-12-23 08:37:45.000000000 -0800
+++ cloud-init-0.7.9-new/cloudinit/config/cc_growpart.py 2017-04-28 17:55:53.083355910 -0700
@@ -247,7 +247,20 @@ def devent2dev(devent):
result = util.get_mount_info(devent)
if not result:
raise ValueError("Could not determine device of '%s' % dev_ent")
- return result[0]
+ dev = result[0]
+
+ container = util.is_container()
+
+ # Ensure the path is a block device.
+ if (dev == "/dev/root" and not container):
+ dev = util.rootdev_from_cmdline(util.get_cmdline())
+ if dev is None:
+ if os.path.exists(dev):
+ # if /dev/root exists, but we failed to convert
+ # that to a "real" /dev/ path device, then return it.
+ return dev
+ raise ValueError("Unable to find device '/dev/root'")
+ return dev |
40184939 |
def resize_devices(resizer, devices):
diff -rup cloud-init-0.7.9/cloudinit/config/cc_resizefs.py cloud-init-0.7.9-new/cloudinit/config/cc_resizefs.py
--- cloud-init-0.7.9/cloudinit/config/cc_resizefs.py 2016-12-23 08:37:45.000000000 -0800
+++ cloud-init-0.7.9-new/cloudinit/config/cc_resizefs.py 2017-04-28 17:55:33.095356361 -0700
@@ -71,25 +71,6 @@ RESIZE_FS_PREFIXES_CMDS = [
NOBLOCK = "noblock"
|
40184939 |
-def rootdev_from_cmdline(cmdline):
- found = None
- for tok in cmdline.split():
- if tok.startswith("root="):
- found = tok[5:]
- break
- if found is None:
- return None
-
- if found.startswith("/dev/"):
- return found
- if found.startswith("LABEL="):
- return "/dev/disk/by-label/" + found[len("LABEL="):]
- if found.startswith("UUID="):
- return "/dev/disk/by-uuid/" + found[len("UUID="):]
-
- return "/dev/" + found
-
-
def handle(name, cfg, _cloud, log, args):
if len(args) != 0:
resize_root = args[0]
@@ -121,7 +102,7 @@ def handle(name, cfg, _cloud, log, args)
# Ensure the path is a block device.
if (devpth == "/dev/root" and not os.path.exists(devpth) and
not container):
- devpth = rootdev_from_cmdline(util.get_cmdline())
+ devpth = util.rootdev_from_cmdline(util.get_cmdline())
if devpth is None:
log.warn("Unable to find device '/dev/root'")
return
diff -rup cloud-init-0.7.9/cloudinit/util.py cloud-init-0.7.9-new/cloudinit/util.py
--- cloud-init-0.7.9/cloudinit/util.py 2016-12-23 08:37:45.000000000 -0800
+++ cloud-init-0.7.9-new/cloudinit/util.py 2017-04-28 17:55:57.435355811 -0700
@@ -2402,4 +2402,34 @@ def system_is_snappy():
return True
return False
+def rootdev_from_cmdline(cmdline):
+ found = None
+ for tok in cmdline.split():
+ if tok.startswith("root="):
+ found = tok[5:]
+ break
+ if found is None:
+ return None
+
+ if found.startswith("/dev/"):
+ return found
+ if found.startswith("LABEL="):
+ return "/dev/disk/by-label/" + found[len("LABEL="):]
+ if found.startswith("UUID="):
+ return "/dev/disk/by-uuid/" + found[len("UUID="):].lower()
+ if found.startswith("PARTUUID="):
+ disks_path = ("/dev/disk/by-partuuid/" +
+ found[len("PARTUUID="):].lower())
+ if os.path.exists(disks_path):
+ return disks_path
+ results = find_devs_with(found)
+ if results:
+ return results[0]
+ # we know this doesn't exist, but for consistency return the path as
+ # it /would/ exist
+ return disks_path
+
+ return "/dev/" + found
+
+
# vi: ts=4 expandtab
|