From 0d666d9aa45bc76322480baf30f863d714f1b0fa Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Thu, 26 Mar 2020 13:04:49 +0000 Subject: ifconfig: T2158: never fail when setting flowcontrol the result of the commands used to setup the interface is now checked. flowcontrol can not always be set on all interfaces, and when/if it fails, it prevents the interace to come up. This is problematic as it may prevent the router to come up. Therefore flowcontrol must be allowed to fail gracefully/silently. --- python/vyos/ifconfig/control.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'python/vyos/ifconfig/control.py') diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py index 28adc80d1..f7b032478 100644 --- a/python/vyos/ifconfig/control.py +++ b/python/vyos/ifconfig/control.py @@ -28,15 +28,20 @@ class Control(Register): if os.path.isfile('/tmp/vyos.ifconfig.debug'): print('DEBUG/{:<6} {}'.format(self.config['ifname'], msg)) - def _cmd(self, command): + def _popen(self, command): p = Popen(command, stdout=PIPE, stderr=STDOUT, shell=True) tmp = p.communicate()[0].strip() 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, p.returncode + + def _cmd(self, command): + decoded, code = self._popen(command) + if code != 0: + # error code can be recovered with .errno + raise OSError(code, f'{command}\nreturned: {decoded}') return decoded def _get_command(self, config, name): -- cgit v1.2.3