summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-03-07 11:01:45 +0100
committerChristian Poessinger <christian@poessinger.com>2021-03-07 11:01:45 +0100
commit549251f5ae1bc40a475b68fa8e6183aafbe703d6 (patch)
tree1e2da26be1b3c89c0b18ec83cb6f8a1bea0e51e1 /python/vyos
parent2eab81070c5819dd6252a37bf74511b87a57368d (diff)
downloadvyos-1x-549251f5ae1bc40a475b68fa8e6183aafbe703d6.tar.gz
vyos-1x-549251f5ae1bc40a475b68fa8e6183aafbe703d6.zip
T3357: Fix invoking TunnelIf() from op-mode
As we can also use the TunnelIf() class from op-mode we must ensure that read-only access to the class works even if required configuration keys as "encapsulation" are not passed to the class on invokation. This fixes an isse where "show interfaces tunnel" returned: Traceback (most recent call last): File "/usr/libexec/vyos/op_mode/show_interfaces.py", line 313, in <module> args.vrrp File "/usr/libexec/vyos/op_mode/show_interfaces.py", line 48, in handled_function function(*args, **kwargs) File "/usr/libexec/vyos/op_mode/show_interfaces.py", line 222, in run_show_intf_brief for interface in filtered_interfaces(ifnames, iftypes, vif, vrrp): File "/usr/libexec/vyos/op_mode/show_interfaces.py", line 77, in filtered_interfaces interface = klass(ifname, create=False, debug=False) File "/usr/lib/python3/dist-packages/vyos/ifconfig/tunnel.py", line 99, in __init__ if self.iftype in ['gretap', 'ip6gretap']: AttributeError: 'TunnelIf' object has no attribute 'iftype'
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig/tunnel.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/python/vyos/ifconfig/tunnel.py b/python/vyos/ifconfig/tunnel.py
index 439d88dbc..e5e1300b2 100644
--- a/python/vyos/ifconfig/tunnel.py
+++ b/python/vyos/ifconfig/tunnel.py
@@ -90,19 +90,21 @@ class TunnelIf(Interface):
}
def __init__(self, ifname, **kargs):
- self.iftype = kargs['encapsulation']
- super().__init__(ifname, **kargs)
-
- # The gretap interface has the possibility to act as L2 bridge
- if self.iftype in ['gretap', 'ip6gretap']:
- # no multicast, ttl or tos for gretap
- self.definition = {
- **TunnelIf.definition,
- **{
- 'bridgeable': True,
- },
- }
+ # T3357: we do not have the 'encapsulation' in kargs when calling this
+ # class from op-mode like "show interfaces tunnel"
+ if 'encapsulation' in kargs:
+ self.iftype = kargs['encapsulation']
+ # The gretap interface has the possibility to act as L2 bridge
+ if self.iftype in ['gretap', 'ip6gretap']:
+ # no multicast, ttl or tos for gretap
+ self.definition = {
+ **TunnelIf.definition,
+ **{
+ 'bridgeable': True,
+ },
+ }
+ super().__init__(ifname, **kargs)
def _create(self):
if self.config['encapsulation'] in ['ipip6', 'ip6ip6', 'ip6gre']: