From 35dcd0a1cb5d9a63dbebcb299eb9425b57258537 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 3 Sep 2019 18:59:50 +0200 Subject: Python/ifconfig: T1557: cleanup __init__/debug --- python/vyos/ifconfig.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 8cf5e1645..1d03e4e74 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -57,18 +57,16 @@ class Interface: >>> from vyos.ifconfig import Interface >>> i = Interface('eth0') """ + self._ifname = str(ifname) if not os.path.exists('/sys/class/net/{}'.format(ifname)) and not type: - raise Exception('interface "{}" not found'.format(str(ifname))) - - self._ifname = str(ifname) - self._debug = False + raise Exception('interface "{}" not found'.format(self._ifname)) if os.path.isfile('/tmp/vyos.ifconfig.debug'): self._debug = True - if not os.path.exists('/sys/class/net/{}'.format(ifname)): - cmd = 'ip link add dev "{}" type "{}"'.format(ifname, type) + if not os.path.exists('/sys/class/net/{}'.format(self._ifname)): + cmd = 'ip link add dev "{}" type "{}"'.format(self._ifname, type) self._cmd(cmd) # per interface DHCP config files @@ -83,7 +81,7 @@ class Interface: def _debug_msg(self, msg): - if self._debug: + if os.path.isfile('/tmp/vyos.ifconfig.debug'): print('DEBUG/{:<6} {}'.format(self._ifname, msg)) -- cgit v1.2.3