diff options
author | Chad Smith <chad.smith@canonical.com> | 2017-10-20 13:24:22 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2017-10-20 13:24:22 -0600 |
commit | 6bc504e41666329631cdfd5b947ed5b0e2529a76 (patch) | |
tree | 732858dd24cff8b9ab7ba49b20316c8406f9fdf2 /cloudinit | |
parent | ee90a6cda4083479d5e9e2aa26887d3db91a3785 (diff) | |
download | vyos-cloud-init-6bc504e41666329631cdfd5b947ed5b0e2529a76.tar.gz vyos-cloud-init-6bc504e41666329631cdfd5b947ed5b0e2529a76.zip |
ntp: fix config module schema to allow empty ntp config
Fix three things related to the ntp module:
1. Fix invalid cloud-config schema in the integration test which
provided empty dicts instead of emptylists for pools and servers
2. Correct logic in the ntp module to allow support for the minimal
cloud-config 'ntp:' without raising a RuntimeError. Docs and schema
definitions already describe that cloud-config's ntp can be empty.
An ntp configuration with neither pools nor servers will be
configured with a default set of ntp pools. As such, the ntp module
now officially allows the following ntp cloud-configs:
- ntp:
- ntp: {}
- ntp:
servers: []
pools: []
3. Add a simple unit test which validates all cloud-config provided to
our integration tests to ensure it adheres to any defined module
schema so as more jsonschema definitions are added, we validate our
integration test configs.
LP: #1724951
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_ntp.py | 4 |
1 files changed, 3 insertions, 1 deletions
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)): |