summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/airbag.py36
-rw-r--r--python/vyos/configdict.py23
-rw-r--r--python/vyos/ifconfig/dhcp.py3
-rw-r--r--python/vyos/ifconfig/interface.py2
-rw-r--r--python/vyos/ifconfig/pppoe.py10
-rw-r--r--python/vyos/ifconfig/vtun.py12
-rw-r--r--python/vyos/ifconfig_vlan.py7
7 files changed, 52 insertions, 41 deletions
diff --git a/python/vyos/airbag.py b/python/vyos/airbag.py
index b7838d8a2..510ab7f46 100644
--- a/python/vyos/airbag.py
+++ b/python/vyos/airbag.py
@@ -17,17 +17,20 @@ import sys
from datetime import datetime
from vyos import debug
-from vyos.config import Config
from vyos.logger import syslog
from vyos.version import get_version
from vyos.version import get_full_version_data
-# we allow to disable the extra logging
-DISABLE = False
+
+def enable(log=True):
+ if log:
+ _intercepting_logger()
+ _intercepting_exceptions()
_noteworthy = []
+
def noteworthy(msg):
"""
noteworthy can be use to take note things which we may not want to
@@ -45,8 +48,6 @@ class _IO(object):
def write(self, message):
self.std.write(message)
- if DISABLE:
- return
for line in message.split('\n'):
s = line.rstrip()
if s:
@@ -90,14 +91,14 @@ def bug_report(dtype, value, trace):
# define an exception handler to be run when an exception
# reach the end of __main__ and was not intercepted
-def intercepter(dtype, value, trace):
+def _intercepter(dtype, value, trace):
bug_report(dtype, value, trace)
if debug.enabled('developer'):
import pdb
pdb.pm()
-def InterceptingLogger(_singleton=[False]):
+def _intercepting_logger(_singleton=[False]):
skip = _singleton.pop()
_singleton.append(True)
if skip:
@@ -110,7 +111,7 @@ def InterceptingLogger(_singleton=[False]):
# lists as default arguments in function is normally dangerous
# as they will keep any modification performed, unless this is
# what you want to do (in that case to only run the code once)
-def InterceptingException(excepthook,_singleton=[False]):
+def _intercepting_exceptions(_singleton=[False]):
skip = _singleton.pop()
_singleton.append(True)
if skip:
@@ -118,24 +119,7 @@ def InterceptingException(excepthook,_singleton=[False]):
# install the handler to replace the default behaviour
# which just prints the exception trace on screen
- sys.excepthook = excepthook
-
-
-# Do not attempt the extra logging for operational commands
-try:
- # This fails during boot
- insession = Config().in_session()
-except:
- # we save info on boot to help debugging
- insession = True
-
-
-# Installing the interception, it currently does not work when
-# running testing so we are checking that we are on the router
-# as otherwise it prevents dpkg-buildpackage to work
-if get_version() and insession:
- InterceptingLogger()
- InterceptingException(intercepter)
+ sys.excepthook = _intercepter
# Messages to print
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py
index eec64e964..ead7e8637 100644
--- a/python/vyos/configdict.py
+++ b/python/vyos/configdict.py
@@ -103,16 +103,21 @@ def get_ethertype(ethertype_val):
else:
raise ConfigError('invalid ethertype "{}"'.format(ethertype_val))
+dhcpv6_pd_default_data = {
+ 'dhcpv6_prm_only': False,
+ 'dhcpv6_temporary': False,
+ 'dhcpv6_pd_length': '',
+ 'dhcpv6_pd_interfaces': []
+}
+
interface_default_data = {
+ **dhcpv6_pd_default_data,
'address': [],
'address_remove': [],
'description': '',
'dhcp_client_id': '',
'dhcp_hostname': '',
'dhcp_vendor_class_id': '',
- 'dhcpv6_prm_only': False,
- 'dhcpv6_temporary': False,
- 'dhcpv6_pd': [],
'disable': False,
'disable_link_detect': 1,
'ip_disable_arp_filter': 1,
@@ -229,9 +234,9 @@ def intf_to_dict(conf, default):
# DHCPv6 prefix delegation (RFC3633)
current_level = conf.get_level()
- if conf.exists(['dhcpv6-options', 'delegate']):
- for interface in conf.list_nodes(['dhcpv6-options', 'delegate']):
- conf.set_level(current_level + ['dhcpv6-options', 'delegate', interface])
+ if conf.exists(['dhcpv6-options', 'prefix-delegation']):
+ for interface in conf.list_nodes(['dhcpv6-options', 'prefix-delegation', 'interface']):
+ conf.set_level(current_level + ['dhcpv6-options', 'prefix-delegation', 'interface', interface])
pd = {
'ifname': interface,
'sla_id': '',
@@ -245,10 +250,10 @@ def intf_to_dict(conf, default):
if conf.exists(['sla-len']):
pd['sla_len'] = conf.return_value(['sla-len'])
- if conf.exists(['interface-id']):
- pd['if_id'] = conf.return_value(['interface-id'])
+ if conf.exists(['address']):
+ pd['if_id'] = conf.return_value(['address'])
- intf['dhcpv6_pd'].append(pd)
+ intf['dhcpv6_pd_interfaces'].append(pd)
# re-set config level
conf.set_level(current_level)
diff --git a/python/vyos/ifconfig/dhcp.py b/python/vyos/ifconfig/dhcp.py
index f8fdeb6a9..a8b9a2a87 100644
--- a/python/vyos/ifconfig/dhcp.py
+++ b/python/vyos/ifconfig/dhcp.py
@@ -86,7 +86,8 @@ class _DHCPv6 (Control):
'ifname': ifname,
'dhcpv6_prm_only': False,
'dhcpv6_temporary': False,
- 'dhcpv6_pd': [],
+ 'dhcpv6_pd_interfaces': [],
+ 'dhcpv6_pd_length': ''
})
self._conf_file = f'/run/dhcp6c/dhcp6c.{ifname}.conf'
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 07efc6d97..2c2396440 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -644,7 +644,7 @@ class Interface(Control):
IPv4: add IPv4 address to interface
IPv6: add IPv6 address to interface
dhcp: start dhclient (IPv4) on interface
- dhcpv6: start dhclient (IPv6) on interface
+ dhcpv6: start WIDE DHCPv6 (IPv6) on interface
Returns False if address is already assigned and wasn't re-added.
Example:
diff --git a/python/vyos/ifconfig/pppoe.py b/python/vyos/ifconfig/pppoe.py
index 7504408cf..787245696 100644
--- a/python/vyos/ifconfig/pppoe.py
+++ b/python/vyos/ifconfig/pppoe.py
@@ -30,4 +30,12 @@ class PPPoEIf(Interface):
},
}
- # The _create and _delete need to be moved from interface-ppoe to here
+ # stub this interface is created in the configure script
+
+ def _create(self):
+ # we can not create this interface as it is managed outside
+ pass
+
+ def _delete(self):
+ # we can not create this interface as it is managed outside
+ pass
diff --git a/python/vyos/ifconfig/vtun.py b/python/vyos/ifconfig/vtun.py
index 07d39fcbb..60c178b9a 100644
--- a/python/vyos/ifconfig/vtun.py
+++ b/python/vyos/ifconfig/vtun.py
@@ -31,4 +31,14 @@ class VTunIf(Interface):
},
}
- # The _create and _delete need to be moved from interface-ppoe to here
+ # stub this interface is created in the configure script
+
+ def _create(self):
+ # we can not create this interface as it is managed outside
+ # it requires configuring OpenVPN
+ pass
+
+ def _delete(self):
+ # we can not create this interface as it is managed outside
+ # it requires configuring OpenVPN
+ pass
diff --git a/python/vyos/ifconfig_vlan.py b/python/vyos/ifconfig_vlan.py
index a53136ebf..53a77c651 100644
--- a/python/vyos/ifconfig_vlan.py
+++ b/python/vyos/ifconfig_vlan.py
@@ -87,8 +87,11 @@ def apply_vlan_config(vlan, config):
if config['dhcpv6_temporary']:
vlan.dhcp.v6.options['dhcpv6_temporary'] = True
- if config['dhcpv6_pd']:
- vlan.dhcp.v6.options['dhcpv6_pd'] = config['dhcpv6_pd']
+ if config['dhcpv6_pd_length']:
+ vlan.dhcp.v6.options['dhcpv6_pd_length'] = config['dhcpv6_pd_length']
+
+ if config['dhcpv6_pd_interfaces']:
+ vlan.dhcp.v6.options['dhcpv6_pd_interfaces'] = config['dhcpv6_pd_interfaces']
# update interface description used e.g. within SNMP
vlan.set_alias(config['description'])