diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-03 16:54:49 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-03 16:54:49 -0500 |
commit | da39ad69e3ee240df7354eb2c2f33bdaba9194f6 (patch) | |
tree | af3bbaf35c2bfad074c5136bffc92caebed8fd31 /cloudinit/config/cc_lxd.py | |
parent | f4c25ab96c572e0a503bb211a11cd2641ac321a3 (diff) | |
parent | b1046db66bbed6a063f218992449b8abfd1ae99b (diff) | |
download | vyos-cloud-init-da39ad69e3ee240df7354eb2c2f33bdaba9194f6.tar.gz vyos-cloud-init-da39ad69e3ee240df7354eb2c2f33bdaba9194f6.zip |
merge with trunk
Diffstat (limited to 'cloudinit/config/cc_lxd.py')
-rw-r--r-- | cloudinit/config/cc_lxd.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/cloudinit/config/cc_lxd.py b/cloudinit/config/cc_lxd.py index 84eec7a5..63b8fb63 100644 --- a/cloudinit/config/cc_lxd.py +++ b/cloudinit/config/cc_lxd.py @@ -47,27 +47,29 @@ def handle(name, cfg, cloud, log, args): return init_cfg = lxd_cfg.get('init') - if not init_cfg: - init_cfg = {} - if not isinstance(init_cfg, dict): log.warn("lxd/init config must be a dictionary. found a '%s'", - type(init_cfg)) + type(init_cfg)) init_cfg = {} - packages = [] - if (init_cfg.get("storage_backend") == "zfs" and not util.which('zfs')): - packages.append('zfs') + if not init_cfg: + log.debug("no lxd/init config. disabled.") + return + packages = [] # Ensure lxd is installed if not util.which("lxd"): packages.append('lxd') - + + # if using zfs, get the utils + if init_cfg.get("storage_backend") == "zfs" and not util.which('zfs'): + packages.append('zfs') + if len(packages): try: cloud.distro.install_packages(packages) - except util.ProcessExecutionError as e: - log.warn("failed to install packages %s: %s", packages, e) + except util.ProcessExecutionError as exc: + log.warn("failed to install packages %s: %s", packages, exc) return # Set up lxd if init config is given @@ -75,11 +77,9 @@ def handle(name, cfg, cloud, log, args): 'network_address', 'network_port', 'storage_backend', 'storage_create_device', 'storage_create_loop', 'storage_pool', 'trust_password') - - if init_cfg: - cmd = ['lxd', 'init', '--auto'] - for k in init_keys: - if init_cfg.get(k): - cmd.extend(["--%s=%s" % - (k.replace('_', '-'), str(init_cfg[k]))]) - util.subp(cmd) + cmd = ['lxd', 'init', '--auto'] + for k in init_keys: + if init_cfg.get(k): + cmd.extend(["--%s=%s" % + (k.replace('_', '-'), str(init_cfg[k]))]) + util.subp(cmd) |