From 0e032f5df4f567195abc7562e8cf6b1164eeec7b Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 31 Aug 2019 18:59:07 +0200 Subject: Python/ifconfig: T1557: enable debugging with DEBUG=1 environment variable --- python/vyos/ifconfig.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 7ae1d71bb..58fed7f62 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -41,7 +41,7 @@ interface "{{ intf }}" { dhclient_base = r'/var/lib/dhcp/dhclient_' class Interface: - def __init__(self, ifname=None, type=None, debug=False): + def __init__(self, ifname=None, type=None): """ Create instance of an IP interface @@ -57,9 +57,11 @@ class Interface: if not os.path.exists('/sys/class/net/{}'.format(ifname)) and not type: raise Exception('interface "{}" not found'.format(str(ifname))) - # variable already referenced from _debug() - self._debug = debug self._ifname = str(ifname) + self._debug = False + + if os.getenv('DEBUG') == '1': + self._debug = True if not os.path.exists('/sys/class/net/{}'.format(ifname)): cmd = 'ip link add dev "{}" type "{}"'.format(ifname, type) @@ -81,12 +83,6 @@ class Interface: print('"DEBUG/{}: {}'.format(self._ifname, msg)) - def set_debug(self, debug): - if debug not in [True, False]: - raise ValueError('must specify True or False for debug') - self._debug = debug - - def remove(self): """ Remove system interface -- cgit v1.2.3