diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/ifconfig/interface.py | 43 | ||||
-rw-r--r-- | python/vyos/utils/network.py | 26 |
2 files changed, 0 insertions, 69 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index f295c1066..fbbc04532 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -36,7 +36,6 @@ from vyos.template import render from vyos.utils.network import mac2eui64 from vyos.utils.dict import dict_search from vyos.utils.network import get_interface_config -from vyos.utils.network import get_interface_namespace from vyos.utils.process import is_systemd_service_active from vyos.template import is_ipv4 from vyos.template import is_ipv6 @@ -137,9 +136,6 @@ class Interface(Control): 'validate': assert_mtu, 'shellcmd': 'ip link set dev {ifname} mtu {value}', }, - 'netns': { - 'shellcmd': 'ip link set dev {ifname} netns {value}', - }, 'vrf': { 'convert': lambda v: f'master {v}' if v else 'nomaster', 'shellcmd': 'ip link set dev {ifname} {value}', @@ -538,35 +534,6 @@ class Interface(Control): if prev_state == 'up': self.set_admin_state('up') - def del_netns(self, netns): - """ - Remove interface from given NETNS. - """ - - # If NETNS does not exist then there is nothing to delete - if not os.path.exists(f'/run/netns/{netns}'): - return None - - # As a PoC we only allow 'dummy' interfaces - if 'dum' not in self.ifname: - return None - - # Check if interface realy exists in namespace - if get_interface_namespace(self.ifname) != None: - self._cmd(f'ip netns exec {get_interface_namespace(self.ifname)} ip link del dev {self.ifname}') - return - - def set_netns(self, netns): - """ - Add interface from given NETNS. - - Example: - >>> from vyos.ifconfig import Interface - >>> Interface('dum0').set_netns('foo') - """ - - self.set_interface('netns', netns) - def get_vrf(self): """ Get VRF from interface @@ -1489,16 +1456,6 @@ class Interface(Control): if mac: self.set_mac(mac) - # If interface is connected to NETNS we don't have to check all other - # settings like MTU/IPv6/sysctl values, etc. - # Since the interface is pushed onto a separate logical stack - # Configure NETNS - if dict_search('netns', config) != None: - self.set_netns(config.get('netns', '')) - return - else: - self.del_netns(config.get('netns', '')) - # Update interface description self.set_alias(config.get('description', '')) diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 63c9e263d..a3bd5c58f 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -40,13 +40,6 @@ def interface_exists(interface) -> bool: import os return os.path.exists(f'/sys/class/net/{interface}') -def interface_exists_in_netns(interface_name, netns): - from vyos.utils.process import rc_cmd - rc, out = rc_cmd(f'ip netns exec {netns} ip link show dev {interface_name}') - if rc == 0: - return True - return False - def get_vrf_members(vrf: str) -> list: """ Get list of interface VRF members @@ -101,25 +94,6 @@ def get_interface_address(interface): tmp = loads(cmd(f'ip --detail --json addr show dev {interface}'))[0] return tmp -def get_interface_namespace(iface): - """ - Returns wich netns the interface belongs to - """ - from json import loads - from vyos.utils.process import cmd - # Check if netns exist - tmp = loads(cmd(f'ip --json netns ls')) - if len(tmp) == 0: - return None - - for ns in tmp: - netns = f'{ns["name"]}' - # Search interface in each netns - data = loads(cmd(f'ip netns exec {netns} ip --json link show')) - for tmp in data: - if iface == tmp["ifname"]: - return netns - def is_ipv6_tentative(iface: str, ipv6_address: str) -> bool: """Check if IPv6 address is in tentative state. |