summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig/control.py12
-rw-r--r--python/vyos/ifconfig/dhcp.py4
-rw-r--r--python/vyos/ifconfig/interface.py10
3 files changed, 20 insertions, 6 deletions
diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py
index 1c9f7e284..c1a073aef 100644
--- a/python/vyos/ifconfig/control.py
+++ b/python/vyos/ifconfig/control.py
@@ -24,8 +24,18 @@ class Control(Register):
_command_get = {}
_command_set = {}
+ def __init__(self, **kargs):
+ # some commands (such as operation comands - show interfaces, etc.)
+ # need to query the interface statistics. If the interface
+ # code is used and the debugging is enabled, the screen output
+ # will include both the command but also the debugging for that command
+ # to prevent this, debugging can be explicitely disabled
+
+ # if debug is not explicitely disabled the the config, enable it
+ self.debug = kargs.get('debug', True)
+
def _debug_msg(self, msg):
- if os.path.isfile('/tmp/vyos.ifconfig.debug'):
+ if os.path.isfile('/tmp/vyos.ifconfig.debug') and self.debug:
print('DEBUG/{:<6} {}'.format(self.config['ifname'], msg))
def _popen(self, command):
diff --git a/python/vyos/ifconfig/dhcp.py b/python/vyos/ifconfig/dhcp.py
index 8d3653433..8ec8263b5 100644
--- a/python/vyos/ifconfig/dhcp.py
+++ b/python/vyos/ifconfig/dhcp.py
@@ -50,7 +50,9 @@ interface "{{ intf }}" {
class DHCP (Control):
client_base = r'/var/lib/dhcp/dhclient_'
- def __init__ (self, ifname):
+ def __init__ (self, ifname, **kargs):
+ super().__init__(**kargs)
+
# per interface DHCP config files
self._dhcp = {
4: {
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 8b41d6158..4a34f96d6 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -162,15 +162,17 @@ class Interface(DHCP):
>>> i = Interface('eth0')
"""
- DHCP.__init__(self, ifname)
-
self.config = deepcopy(self.default)
- self.config['ifname'] = ifname
-
for k in self.options:
if k in kargs:
self.config[k] = kargs[k]
+ # make sure the ifname is the first argument and not from the dict
+ self.config['ifname'] = ifname
+
+ # we must have updated config before initialising the Interface
+ super().__init__(ifname, **kargs)
+
if not os.path.exists('/sys/class/net/{}'.format(self.config['ifname'])):
if not self.config['type']:
raise Exception('interface "{}" not found'.format(self.config['ifname']))