diff options
Diffstat (limited to 'python/vyos/ifconfig/control.py')
-rw-r--r-- | python/vyos/ifconfig/control.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py index e8f25c014..1c9f7e284 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): @@ -50,9 +55,6 @@ class Control(Register): """ Using the defined names, set data write to sysfs. """ - if not value and not self._command_set[name].get('force', False): - return None - # the code can pass int as int value = str(value) @@ -110,9 +112,6 @@ class Control(Register): """ Using the defined names, set data write to sysfs. """ - if not value and not self._sysfs_set[name].get('force', False): - return None - # the code can pass int as int value = str(value) |