summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/tunnel.py2
-rw-r--r--python/vyos/template.py4
-rw-r--r--python/vyos/util.py71
3 files changed, 3 insertions, 74 deletions
diff --git a/python/vyos/ifconfig/tunnel.py b/python/vyos/ifconfig/tunnel.py
index 964ffe383..4122d1a2f 100644
--- a/python/vyos/ifconfig/tunnel.py
+++ b/python/vyos/ifconfig/tunnel.py
@@ -179,7 +179,7 @@ class GRETapIf(_Tunnel):
default = {'type': 'gretap'}
required = ['local', ]
- options = ['local', 'remote', ]
+ options = ['local', 'remote', 'ttl',]
updates = ['mtu', ]
create = 'ip link add {ifname} type {type}'
diff --git a/python/vyos/template.py b/python/vyos/template.py
index c88ab04a0..1f1ddc000 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -131,7 +131,7 @@ def vyos_address_from_cidr(text):
Example:
192.0.2.0/24 -> 192.0.2.0, 2001:db8::/48 -> 2001:db8::
"""
- return ip_network(text).network_address
+ return str(ip_network(text).network_address)
@register_filter("netmask_from_cidr")
@@ -140,4 +140,4 @@ def vyos_netmask_from_cidr(text):
Example:
192.0.2.0/24 -> 255.255.255.0, 2001:db8::/48 -> ffff:ffff:ffff::
"""
- return ip_network(text).netmask
+ return str(ip_network(text).netmask)
diff --git a/python/vyos/util.py b/python/vyos/util.py
index b5f0ea36e..e3e389baf 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -581,77 +581,6 @@ def get_half_cpus():
cpu /= 2
return int(cpu)
-def ifname_from_config(conf):
- """
- Gets interface name with VLANs from current config level.
- Level must be at the interface whose name we want.
-
- Example:
- >>> from vyos.util import ifname_from_config
- >>> from vyos.config import Config
- >>> conf = Config()
- >>> conf.set_level('interfaces ethernet eth0 vif-s 1 vif-c 2')
- >>> ifname_from_config(conf)
- 'eth0.1.2'
- """
- level = conf.get_level()
-
- # vlans
- if level[-2] == 'vif' or level[-2] == 'vif-s':
- return level[-3] + '.' + level[-1]
- if level[-2] == 'vif-c':
- return level[-5] + '.' + level[-3] + '.' + level[-1]
-
- # no vlans
- return level[-1]
-
-def get_bridge_member_config(conf, br, intf):
- """
- Gets bridge port (member) configuration
-
- Arguments:
- conf: Config
- br: bridge name
- intf: interface name
-
- Returns:
- dict with the configuration
- False if bridge or bridge port doesn't exist
- """
- old_level = conf.get_level()
- conf.set_level([])
-
- bridge = f'interfaces bridge {br}'
- member = f'{bridge} member interface {intf}'
- if not ( conf.exists(bridge) and conf.exists(member) ):
- return False
-
- # default bridge port configuration
- # cost and priority initialized with linux defaults
- # by reading /sys/devices/virtual/net/br0/brif/eth2/{path_cost,priority}
- # after adding interface to bridge after reboot
- memberconf = {
- 'cost': 100,
- 'priority': 32,
- 'arp_cache_tmo': 30,
- 'disable_link_detect': 1,
- }
-
- if conf.exists(f'{member} cost'):
- memberconf['cost'] = int(conf.return_value(f'{member} cost'))
-
- if conf.exists(f'{member} priority'):
- memberconf['priority'] = int(conf.return_value(f'{member} priority'))
-
- if conf.exists(f'{bridge} ip arp-cache-timeout'):
- memberconf['arp_cache_tmo'] = int(conf.return_value(f'{bridge} ip arp-cache-timeout'))
-
- if conf.exists(f'{bridge} disable-link-detect'):
- memberconf['disable_link_detect'] = 2
-
- conf.set_level(old_level)
- return memberconf
-
def check_kmod(k_mod):
""" Common utility function to load required kernel modules on demand """
from vyos import ConfigError