summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/distros')
-rwxr-xr-xcloudinit/distros/__init__.py5
-rw-r--r--cloudinit/distros/arch.py4
-rw-r--r--cloudinit/distros/parsers/resolv_conf.py7
3 files changed, 9 insertions, 7 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index effb4276..2537608f 100755
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -607,10 +607,11 @@ class Distro(metaclass=abc.ABCMeta):
lock_tools = (['passwd', '-l', name], ['usermod', '--lock', name])
try:
cmd = next(tool for tool in lock_tools if subp.which(tool[0]))
- except StopIteration:
+ except StopIteration as e:
raise RuntimeError((
"Unable to lock user account '%s'. No tools available. "
- " Tried: %s.") % (name, [c[0] for c in lock_tools]))
+ " Tried: %s.") % (name, [c[0] for c in lock_tools])
+ ) from e
try:
subp.subp(cmd)
except Exception as e:
diff --git a/cloudinit/distros/arch.py b/cloudinit/distros/arch.py
index 038aa9ac..967be168 100644
--- a/cloudinit/distros/arch.py
+++ b/cloudinit/distros/arch.py
@@ -61,9 +61,9 @@ class Distro(distros.Distro):
def _write_network_config(self, netconfig):
try:
return self._supported_write_network_config(netconfig)
- except RendererNotFoundError:
+ except RendererNotFoundError as e:
# Fall back to old _write_network
- raise NotImplementedError
+ raise NotImplementedError from e
def _write_network(self, settings):
entries = net_util.translate_network(settings)
diff --git a/cloudinit/distros/parsers/resolv_conf.py b/cloudinit/distros/parsers/resolv_conf.py
index 299d54b5..62929d03 100644
--- a/cloudinit/distros/parsers/resolv_conf.py
+++ b/cloudinit/distros/parsers/resolv_conf.py
@@ -150,9 +150,10 @@ class ResolvConf(object):
tail = ''
try:
(cfg_opt, cfg_values) = head.split(None, 1)
- except (IndexError, ValueError):
- raise IOError("Incorrectly formatted resolv.conf line %s"
- % (i + 1))
+ except (IndexError, ValueError) as e:
+ raise IOError(
+ "Incorrectly formatted resolv.conf line %s" % (i + 1)
+ ) from e
if cfg_opt not in ['nameserver', 'domain',
'search', 'sortlist', 'options']:
raise IOError("Unexpected resolv.conf option %s" % (cfg_opt))