summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-01-24 17:34:52 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-01-24 17:34:52 -0800
commit8c7aecbb695f50514ae1bea9c105176b6345fb95 (patch)
tree739719e4c55bc71fae90d5f1e81ad2467cdfde1b /cloudinit
parent62f6ce9a28d38cccbce560469de229397e06cccc (diff)
downloadvyos-cloud-init-8c7aecbb695f50514ae1bea9c105176b6345fb95.tar.gz
vyos-cloud-init-8c7aecbb695f50514ae1bea9c105176b6345fb95.zip
Fix logexc usage in freebsd distro
- There appeared to be a few logexc calls that did not pass the logger in, fix those locations where this occured. - When a group member adding fails, log the error and try the next member instead of failing adding any more members
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/freebsd.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py
index ab5e334a..0f1656c3 100644
--- a/cloudinit/distros/freebsd.py
+++ b/cloudinit/distros/freebsd.py
@@ -109,16 +109,20 @@ class Distro(distros.Distro):
util.subp(group_add_cmd)
LOG.info("Created new group %s", name)
except Exception:
- util.logexc("Failed to create group %s", name)
+ util.logexc(LOG, "Failed to create group %s", name)
if len(members) > 0:
for member in members:
if not util.is_user(member):
LOG.warn("Unable to add group member '%s' to group '%s'"
- "; user does not exist.", member, name)
+ "; user does not exist.", member, name)
continue
- util.subp(['pw', 'usermod', '-n', name, '-G', member])
- LOG.info("Added user '%s' to group '%s'", member, name)
+ try:
+ util.subp(['pw', 'usermod', '-n', name, '-G', member])
+ LOG.info("Added user '%s' to group '%s'", member, name)
+ except Exception:
+ util.logexc(LOG, "Failed to add user '%s' to group '%s'",
+ member, name)
def add_user(self, name, **kwargs):
if util.is_user(name):
@@ -230,15 +234,16 @@ class Distro(distros.Distro):
util.write_file(self.login_conf_fn, newconf.getvalue())
try:
- util.logexc("Running cap_mkdb for %s", locale)
+ LOG.debug("Running cap_mkdb for %s", locale)
util.subp(['cap_mkdb', self.login_conf_fn])
except util.ProcessExecutionError:
# cap_mkdb failed, so restore the backup.
- util.logexc("Failed to apply locale %s", locale)
+ util.logexc(LOG, "Failed to apply locale %s", locale)
try:
util.copy(self.login_conf_fn_bak, self.login_conf_fn)
except IOError:
- util.logexc("Failed to restore %s backup", self.login_conf_fn)
+ util.logexc(LOG, "Failed to restore %s backup",
+ self.login_conf_fn)
def install_packages(self, pkglist):
return