summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-20 17:30:56 +0000
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-03-20 18:07:12 +0000
commit72c065c686b062dc9529722ab51aa38f29c6f733 (patch)
treeb6ec45b9fdaed777457c06ddcefd21f1b0887170 /python/vyos/ifconfig
parentaca6154bfd25cf62dbbce21d6a3bf56024f62035 (diff)
downloadvyos-1x-72c065c686b062dc9529722ab51aa38f29c6f733.tar.gz
vyos-1x-72c065c686b062dc9529722ab51aa38f29c6f733.zip
ifconfig: T2057: fail change when command are failing
Diffstat (limited to 'python/vyos/ifconfig')
-rw-r--r--python/vyos/ifconfig/control.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py
index c8568ac96..635b626e8 100644
--- a/python/vyos/ifconfig/control.py
+++ b/python/vyos/ifconfig/control.py
@@ -29,12 +29,13 @@ class Control:
def _cmd(self, command):
p = Popen(command, stdout=PIPE, stderr=STDOUT, shell=True)
tmp = p.communicate()[0].strip()
- self._debug_msg("cmd '{}'".format(command))
- if tmp.decode():
- self._debug_msg("returned:\n{}".format(tmp.decode()))
-
- # do we need some error checking code here?
- return tmp.decode()
+ self._debug_msg(f"cmd '{command}'")
+ decoded = tmp.decode()
+ if decoded:
+ self._debug_msg(f"returned:\n{decoded}")
+ if p.returncode != 0:
+ raise RuntimeError(f'{command}\nreturned: {decoded}')
+ return decoded
def _get_command(self, config, name):
"""