diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-10-01 14:58:14 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-10-01 14:58:14 -0400 |
commit | f3c8ec58cb2a2d1bce73bec08bae08e16f1b1f99 (patch) | |
tree | 6b2a125845a61722c32023668daf08af99017d72 | |
parent | 4fb4b31a889f9f6c32290b4fde99edbcd30a3660 (diff) | |
download | vyos-cloud-init-f3c8ec58cb2a2d1bce73bec08bae08e16f1b1f99.tar.gz vyos-cloud-init-f3c8ec58cb2a2d1bce73bec08bae08e16f1b1f99.zip |
nice log message
-rw-r--r-- | cloudinit/config/cc_mounts.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py index db09d2fb..2503ed98 100644 --- a/cloudinit/config/cc_mounts.py +++ b/cloudinit/config/cc_mounts.py @@ -82,6 +82,9 @@ def suggested_swapsize(memsize=None, maxsize=None, fsys=None): GB = 2 ** 30 sugg_max = 8 * GB + max_in = maxsize + + info = {'avail': 'na', 'max_in': maxsize, 'mem': memsize} if fsys is None and maxsize is None: # set max to 8GB default if no filesystem given @@ -89,6 +92,7 @@ def suggested_swapsize(memsize=None, maxsize=None, fsys=None): elif fsys: statvfs = os.statvfs(fsys) avail = statvfs.f_frsize * statvfs.f_bfree + info['avail'] = avail if maxsize is None: # set to 25% of filesystem space @@ -96,6 +100,10 @@ def suggested_swapsize(memsize=None, maxsize=None, fsys=None): elif maxsize > ((avail * .9)): # set to 90% of available disk space maxsize = int(avail * .9) + elif maxsize is None: + maxsize = sugg_max + + info['max'] = maxsize formulas = [ # < 1G: swap = double memory @@ -122,8 +130,19 @@ def suggested_swapsize(memsize=None, maxsize=None, fsys=None): if size is not None: size = maxsize - LOG.debug("suggest %s for %s memory with %s available disk and max=%s", - size, memsize, avail, maxsize) + + info['size'] = size + + MB = 2 ** 20 + pinfo = {} + for k, v in info.items(): + if isinstance(v, int): + pinfo[k] = "%s MB" % (v / MB) + else: + pinfo[k] = v + + LOG.debug("suggest %(size)s swap for %(mem)s memory with '%(avail)s'" + " disk given max=%(max_in)s [max=%(max)s]'" % pinfo) return size @@ -192,7 +211,6 @@ def handle_swapcfg(swapcfg): return None - def handle(_name, cfg, cloud, log, _args): # fs_spec, fs_file, fs_vfstype, fs_mntops, fs-freq, fs_passno defvals = [None, None, "auto", "defaults,nobootwait", "0", "2"] |