summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-03 15:17:24 -0500
committerScott Moser <smoser@ubuntu.com>2016-03-03 15:17:24 -0500
commit96f1742b36241cee152aa2cb5b4a5e1a267a4770 (patch)
treee1aa43915c5949104129e289b985d118e9a2f85b /cloudinit
parent42d3efe69caeb2bb1ebdd67f1bae3e8f2134ff85 (diff)
downloadvyos-cloud-init-96f1742b36241cee152aa2cb5b4a5e1a267a4770.tar.gz
vyos-cloud-init-96f1742b36241cee152aa2cb5b4a5e1a267a4770.zip
fix lxd module to not do anything unless config provided
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_lxd.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/cloudinit/config/cc_lxd.py b/cloudinit/config/cc_lxd.py
index 84eec7a5..80a4d219 100644
--- a/cloudinit/config/cc_lxd.py
+++ b/cloudinit/config/cc_lxd.py
@@ -47,22 +47,24 @@ 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))
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)
@@ -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)