diff options
Diffstat (limited to 'python/vyos')
-rwxr-xr-x | python/vyos/ifconfig/interface.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 58d130ef6..50da2553a 100755 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -135,6 +135,9 @@ 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}', @@ -512,6 +515,21 @@ class Interface(Control): if prev_state == 'up': self.set_admin_state('up') + def set_netns(self, netns): + """ + Add/Remove interface from given NETNS. + + Example: + >>> from vyos.ifconfig import Interface + >>> Interface('dum0').set_netns('foo') + """ + + #tmp = self.get_interface('netns') + #if tmp == netns: + # return None + + self.set_interface('netns', netns) + def set_vrf(self, vrf): """ Add/Remove interface from given VRF instance. @@ -1405,6 +1423,13 @@ class Interface(Control): # checked before self.set_vrf(config.get('vrf', '')) + # If interface attached to NETNS we shouldn't check all other settings + # As interface placed to separate logical stack + # Configure NETNS + if dict_search('netns', config) != None: + self.set_netns(config.get('netns', '')) + return + # Configure MSS value for IPv4 TCP connections tmp = dict_search('ip.adjust_mss', config) value = tmp if (tmp != None) else '0' |