diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-23 12:57:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-23 12:57:34 +0100 |
commit | 52e20fa562968dcfd7b524031f0cad2b6f4fff57 (patch) | |
tree | 8adba1fa5916b47a65b1b77f4b490e0b1fe6d1ae /python/vyos/ifconfig | |
parent | cefed7ae3fbbb93142051633ff00d3a9e19889c0 (diff) | |
parent | 193d0f416807b3eb5980dcf209e93774282b85f3 (diff) | |
download | vyos-1x-52e20fa562968dcfd7b524031f0cad2b6f4fff57.tar.gz vyos-1x-52e20fa562968dcfd7b524031f0cad2b6f4fff57.zip |
Merge pull request #258 from thomas-mangin/31-vrf
tunnel: T31: fix vrf deletion, add support for vrf on tunnels
Diffstat (limited to 'python/vyos/ifconfig')
-rw-r--r-- | python/vyos/ifconfig/control.py | 4 | ||||
-rw-r--r-- | python/vyos/ifconfig/interface.py | 28 |
2 files changed, 11 insertions, 21 deletions
diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py index 635b626e8..89deba40a 100644 --- a/python/vyos/ifconfig/control.py +++ b/python/vyos/ifconfig/control.py @@ -48,7 +48,7 @@ class Control: """ Using the defined names, set data write to sysfs. """ - if not value: + if not value and not self._command_set[name].get('force', False): return None # the code can pass int as int @@ -108,7 +108,7 @@ class Control: """ Using the defined names, set data write to sysfs. """ - if not value: + if not value and not self._sysfs_set[name].get('force', False): return None # the code can pass int as int diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 21ffa88f6..718fe93db 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -85,11 +85,10 @@ class Interface(Control): 'validate': assert_mac, 'shellcmd': 'ip link set dev {ifname} address {value}', }, - 'add_vrf': { - 'shellcmd': 'ip link set dev {ifname} master {value}', - }, - 'del_vrf': { - 'shellcmd': 'ip link set dev {ifname} nomaster {value}', + 'vrf': { + 'force': True, + 'convert': lambda v: f'master {v}' if v else 'nomaster', + 'shellcmd': 'ip link set dev {ifname} {value}', }, } @@ -298,25 +297,16 @@ class Interface(Control): """ self.set_interface('mac', mac) - def add_vrf(self, vrf): - """ - Add interface to given VRF instance. - - Example: - >>> from vyos.ifconfig import Interface - >>> Interface('eth0').add_vrf('foo') - """ - self.set_interface('add_vrf', vrf) - - def del_vrf(self, vrf): + def set_vrf(self, vrf=''): """ - Remove interface from given VRF instance. + Add/Remove interface from given VRF instance. Example: >>> from vyos.ifconfig import Interface - >>> Interface('eth0').del_vrf('foo') + >>> Interface('eth0').set_vrf('foo') + >>> Interface('eth0').set_vrf() """ - self.set_interface('del_vrf', vrf) + self.set_interface('vrf', vrf) def set_arp_cache_tmo(self, tmo): """ |