summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-04-11 15:08:08 -0400
committerScott Moser <smoser@ubuntu.com>2016-04-11 15:08:08 -0400
commit860d98bce4b607a513dc94d96335e8f105a36294 (patch)
tree816b5703292f5820c4b1f3921c91ee66e532c4c1 /cloudinit
parent32340db1f8b232855b635686e89608e23f2530cc (diff)
downloadvyos-cloud-init-860d98bce4b607a513dc94d96335e8f105a36294.tar.gz
vyos-cloud-init-860d98bce4b607a513dc94d96335e8f105a36294.zip
minor cleanups
- use util.del_file rather than os.remove - raise exception if debconf-communicate is not present - add a trailing newline into debconf-communicate input
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_lxd.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/cloudinit/config/cc_lxd.py b/cloudinit/config/cc_lxd.py
index 0b10077a..bf735648 100644
--- a/cloudinit/config/cc_lxd.py
+++ b/cloudinit/config/cc_lxd.py
@@ -46,7 +46,6 @@ Example config:
"""
from cloudinit import util
-import os
def handle(name, cfg, cloud, log, args):
@@ -102,26 +101,29 @@ def handle(name, cfg, cloud, log, args):
util.subp(cmd)
# Set up lxd-bridge if bridge config is given
- if bridge_cfg:
+ dconf_comm = "debconf-communicate"
+ if bridge_cfg and util.which(dconf_comm):
debconf = bridge_to_debconf(bridge_cfg)
# Update debconf database
try:
- log.debug("Setting lxd debconf-set-selections")
+ log.debug("Setting lxd debconf via " + dconf_comm)
data = "\n".join(["set %s %s" % (k, v)
- for k, v in debconf.items()])
+ for k, v in debconf.items()]) + "\n"
util.subp(['debconf-communicate'], data)
except:
- util.logexc(log, "Failed to run debconf-communicate for lxd")
+ util.logexc(log, "Failed to run '%s' for lxd with" % dconf_comm)
# Remove the existing configuration file (forces re-generation)
- if os.path.exists("/etc/default/lxd-bridge"):
- os.remove("/etc/default/lxd-bridge")
+ util.del_file("/etc/default/lxd-bridge")
# Run reconfigure
log.debug("Running dpkg-reconfigure for lxd")
util.subp(['dpkg-reconfigure', 'lxd',
'--frontend=noninteractive'])
+ elif bridge_cfg:
+ raise RuntimeError(
+ "Unable to configure lxd bridge without %s." + dconf_comm)
def bridge_to_debconf(bridge_cfg):