summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-08-31 18:59:07 +0200
committerChristian Poessinger <christian@poessinger.com>2019-08-31 18:59:07 +0200
commit0e032f5df4f567195abc7562e8cf6b1164eeec7b (patch)
tree878c54bccd857815018dbb83b6457be05a0e29b0
parentf524254e0c0c5e5954ca3f2e939f6b510667ad8a (diff)
downloadvyos-1x-0e032f5df4f567195abc7562e8cf6b1164eeec7b.tar.gz
vyos-1x-0e032f5df4f567195abc7562e8cf6b1164eeec7b.zip
Python/ifconfig: T1557: enable debugging with DEBUG=1 environment variable
-rw-r--r--python/vyos/ifconfig.py14
1 files 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