diff options
Diffstat (limited to 'cloudinit/CloudConfig/cc_resizefs.py')
-rw-r--r-- | cloudinit/CloudConfig/cc_resizefs.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/cloudinit/CloudConfig/cc_resizefs.py b/cloudinit/CloudConfig/cc_resizefs.py index d960afd5..f29f886d 100644 --- a/cloudinit/CloudConfig/cc_resizefs.py +++ b/cloudinit/CloudConfig/cc_resizefs.py @@ -25,10 +25,11 @@ from cloudinit.CloudConfig import per_always frequency = per_always + def handle(_name, cfg, _cloud, log, args): if len(args) != 0: resize_root = False - if str(args[0]).lower() in [ 'true', '1', 'on', 'yes']: + if str(args[0]).lower() in ['true', '1', 'on', 'yes']: resize_root = True else: resize_root = util.get_cfg_option_bool(cfg, "resize_rootfs", True) @@ -40,7 +41,7 @@ def handle(_name, cfg, _cloud, log, args): (fd, devpth) = tempfile.mkstemp() os.unlink(devpth) os.close(fd) - + try: st_dev = os.stat("/").st_dev dev = os.makedev(os.major(st_dev), os.minor(st_dev)) @@ -52,7 +53,7 @@ def handle(_name, cfg, _cloud, log, args): log.warn("Failed to make device node to resize /") raise - cmd = [ 'blkid', '-c', '/dev/null', '-sTYPE', '-ovalue', devpth ] + cmd = ['blkid', '-c', '/dev/null', '-sTYPE', '-ovalue', devpth] try: (fstype, _err) = util.subp(cmd) except subprocess.CalledProcessError as e: @@ -62,13 +63,13 @@ def handle(_name, cfg, _cloud, log, args): os.unlink(devpth) raise - log.debug("resizing root filesystem (type=%s, maj=%i, min=%i)" % + log.debug("resizing root filesystem (type=%s, maj=%i, min=%i)" % (str(fstype).rstrip("\n"), os.major(st_dev), os.minor(st_dev))) if str(fstype).startswith("ext"): - resize_cmd = [ 'resize2fs', devpth ] + resize_cmd = ['resize2fs', devpth] elif fstype == "xfs": - resize_cmd = [ 'xfs_growfs', devpth ] + resize_cmd = ['xfs_growfs', devpth] else: os.unlink(devpth) log.debug("not resizing unknown filesystem %s" % fstype) |