diff options
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_lxd.py | 2 | ||||
-rw-r--r-- | cloudinit/config/cc_ntp.py | 4 | ||||
-rw-r--r-- | cloudinit/config/cc_resizefs.py | 43 | ||||
-rw-r--r-- | cloudinit/config/cc_users_groups.py | 3 | ||||
-rw-r--r-- | cloudinit/config/schema.py | 2 |
5 files changed, 20 insertions, 34 deletions
diff --git a/cloudinit/config/cc_lxd.py b/cloudinit/config/cc_lxd.py index e6262f8c..09374d2e 100644 --- a/cloudinit/config/cc_lxd.py +++ b/cloudinit/config/cc_lxd.py @@ -72,7 +72,7 @@ def handle(name, cfg, cloud, log, args): type(init_cfg)) init_cfg = {} - bridge_cfg = lxd_cfg.get('bridge') + bridge_cfg = lxd_cfg.get('bridge', {}) if not isinstance(bridge_cfg, dict): log.warn("lxd/bridge config must be a dictionary. found a '%s'", type(bridge_cfg)) diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py index 15ae1ecd..d43d060c 100644 --- a/cloudinit/config/cc_ntp.py +++ b/cloudinit/config/cc_ntp.py @@ -100,7 +100,9 @@ def handle(name, cfg, cloud, log, _args): LOG.debug( "Skipping module named %s, not present or disabled by cfg", name) return - ntp_cfg = cfg.get('ntp', {}) + ntp_cfg = cfg['ntp'] + if ntp_cfg is None: + ntp_cfg = {} # Allow empty config which will install the package # TODO drop this when validate_cloudconfig_schema is strict=True if not isinstance(ntp_cfg, (dict)): diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py index f774baa3..0d282e63 100644 --- a/cloudinit/config/cc_resizefs.py +++ b/cloudinit/config/cc_resizefs.py @@ -145,25 +145,6 @@ RESIZE_FS_PRECHECK_CMDS = { } -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 can_skip_resize(fs_type, resize_what, devpth): fstype_lc = fs_type.lower() for i, func in RESIZE_FS_PRECHECK_CMDS.items(): @@ -172,14 +153,15 @@ def can_skip_resize(fs_type, resize_what, devpth): return False -def is_device_path_writable_block(devpath, info, log): - """Return True if devpath is a writable block device. +def maybe_get_writable_device_path(devpath, info, log): + """Return updated devpath if the devpath is a writable block device. - @param devpath: Path to the root device we want to resize. + @param devpath: Requested path to the root device we want to resize. @param info: String representing information about the requested device. @param log: Logger to which logs will be added upon error. - @returns Boolean True if block device is writable + @returns devpath or updated devpath per kernel commandline if the device + path is a writable block device, returns None otherwise. """ container = util.is_container() @@ -189,12 +171,12 @@ def is_device_path_writable_block(devpath, info, log): devpath = util.rootdev_from_cmdline(util.get_cmdline()) if devpath is None: log.warn("Unable to find device '/dev/root'") - return False + return None log.debug("Converted /dev/root to '%s' per kernel cmdline", devpath) if devpath == 'overlayroot': log.debug("Not attempting to resize devpath '%s': %s", devpath, info) - return False + return None try: statret = os.stat(devpath) @@ -207,7 +189,7 @@ def is_device_path_writable_block(devpath, info, log): devpath, info) else: raise exc - return False + return None if not stat.S_ISBLK(statret.st_mode) and not stat.S_ISCHR(statret.st_mode): if container: @@ -216,8 +198,8 @@ def is_device_path_writable_block(devpath, info, log): else: log.warn("device '%s' not a block device. cannot resize: %s" % (devpath, info)) - return False - return True + return None + return devpath # The writable block devpath def handle(name, cfg, _cloud, log, args): @@ -242,8 +224,9 @@ def handle(name, cfg, _cloud, log, args): info = "dev=%s mnt_point=%s path=%s" % (devpth, mount_point, resize_what) log.debug("resize_info: %s" % info) - if not is_device_path_writable_block(devpth, info, log): - return + devpth = maybe_get_writable_device_path(devpth, info, log) + if not devpth: + return # devpath was not a writable block device resizer = None if can_skip_resize(fs_type, resize_what, devpth): diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py index b80d1d36..f363000d 100644 --- a/cloudinit/config/cc_users_groups.py +++ b/cloudinit/config/cc_users_groups.py @@ -15,7 +15,8 @@ options, see the ``Including users and groups`` config example. Groups to add to the system can be specified as a list under the ``groups`` key. Each entry in the list should either contain a the group name as a string, or a dictionary with the group name as the key and a list of users who should -be members of the group as the value. +be members of the group as the value. **Note**: Groups are added before users, +so any users in a group list must already exist on the system. The ``users`` config key takes a list of users to configure. The first entry in this list is used as the default user for the system. To preserve the standard diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py index bb291ff8..ca7d0d5b 100644 --- a/cloudinit/config/schema.py +++ b/cloudinit/config/schema.py @@ -74,7 +74,7 @@ def validate_cloudconfig_schema(config, schema, strict=False): try: from jsonschema import Draft4Validator, FormatChecker except ImportError: - logging.warning( + logging.debug( 'Ignoring schema validation. python-jsonschema is not present') return validator = Draft4Validator(schema, format_checker=FormatChecker()) |