diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-23 11:50:22 +0000 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-23 11:50:22 +0000 |
commit | 193d0f416807b3eb5980dcf209e93774282b85f3 (patch) | |
tree | 1e7a2597872b04bc8e5af69d32a33b8b7ce4c4e8 | |
parent | f71a7461e44a98e862810bed3d0b9d280ee5dae0 (diff) | |
download | vyos-1x-193d0f416807b3eb5980dcf209e93774282b85f3.tar.gz vyos-1x-193d0f416807b3eb5980dcf209e93774282b85f3.zip |
ifconfig: T31: convert all interface to set_vrf api
-rw-r--r-- | python/vyos/ifconfig/interface.py | 25 | ||||
-rw-r--r-- | python/vyos/ifconfig_vlan.py | 7 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-bonding.py | 7 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-bridge.py | 7 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-dummy.py | 7 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-ethernet.py | 7 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-pseudo-ethernet.py | 7 | ||||
-rwxr-xr-x | src/conf_mode/interfaces-wireless.py | 7 |
8 files changed, 19 insertions, 55 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 9de24d729..718fe93db 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -85,12 +85,6 @@ 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', - }, 'vrf': { 'force': True, 'convert': lambda v: f'master {v}' if v else 'nomaster', @@ -303,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): """ diff --git a/python/vyos/ifconfig_vlan.py b/python/vyos/ifconfig_vlan.py index 1d57283ac..fe94a5af4 100644 --- a/python/vyos/ifconfig_vlan.py +++ b/python/vyos/ifconfig_vlan.py @@ -68,11 +68,8 @@ def apply_vlan_config(vlan, config): # Maximum Transmission Unit (MTU) vlan.set_mtu(config['mtu']) - # assign to VRF - if config['vrf']: - vlan.add_vrf(config['vrf']) - else: - vlan.del_vrf(config['vrf']) + # assign/remove VRF + vlan.set_vrf(config['vrf']) # Change VLAN interface MAC address if config['mac']: diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py index a75beabd1..03df6e16a 100755 --- a/src/conf_mode/interfaces-bonding.py +++ b/src/conf_mode/interfaces-bonding.py @@ -461,11 +461,8 @@ def apply(bond): for addr in bond['address']: b.add_addr(addr) - # assign to VRF - if bond['vrf']: - b.add_vrf(bond['vrf']) - else: - b.del_vrf(bond['vrf']) + # assign/remove VRF + b.set_vrf(bond['vrf']) # remove no longer required service VLAN interfaces (vif-s) for vif_s in bond['vif_s_remove']: diff --git a/src/conf_mode/interfaces-bridge.py b/src/conf_mode/interfaces-bridge.py index f189ce36d..f8f20bf5c 100755 --- a/src/conf_mode/interfaces-bridge.py +++ b/src/conf_mode/interfaces-bridge.py @@ -295,11 +295,8 @@ def apply(bridge): # store DHCPv6 config dictionary - used later on when addresses are aquired br.set_dhcpv6_options(opt) - # assign to VRF - if bridge['vrf']: - br.add_vrf(bridge['vrf']) - else: - br.del_vrf(bridge['vrf']) + # assign/remove VRF + br.set_vrf(bridge['vrf']) # Change interface MAC address if bridge['mac']: diff --git a/src/conf_mode/interfaces-dummy.py b/src/conf_mode/interfaces-dummy.py index 10cae5d7d..bf55b13ec 100755 --- a/src/conf_mode/interfaces-dummy.py +++ b/src/conf_mode/interfaces-dummy.py @@ -105,11 +105,8 @@ def apply(dummy): for addr in dummy['address']: d.add_addr(addr) - # assign to VRF - if dummy['vrf']: - d.add_vrf(dummy['vrf']) - else: - d.del_vrf(dummy['vrf']) + # assign/remove VRF + d.set_vrf(dummy['vrf']) # disable interface on demand if dummy['disable']: diff --git a/src/conf_mode/interfaces-ethernet.py b/src/conf_mode/interfaces-ethernet.py index ba3a5e8c8..2f5d796b4 100755 --- a/src/conf_mode/interfaces-ethernet.py +++ b/src/conf_mode/interfaces-ethernet.py @@ -369,11 +369,8 @@ def apply(eth): for addr in eth['address']: e.add_addr(addr) - # assign to VRF - if eth['vrf']: - e.add_vrf(eth['vrf']) - else: - e.del_vrf(eth['vrf']) + # assign/remove VRF + e.set_vrf(eth['vrf']) # remove no longer required service VLAN interfaces (vif-s) for vif_s in eth['vif_s_remove']: diff --git a/src/conf_mode/interfaces-pseudo-ethernet.py b/src/conf_mode/interfaces-pseudo-ethernet.py index 989b1432b..0afae8388 100755 --- a/src/conf_mode/interfaces-pseudo-ethernet.py +++ b/src/conf_mode/interfaces-pseudo-ethernet.py @@ -297,11 +297,8 @@ def apply(peth): # Enable private VLAN proxy ARP on this interface p.set_proxy_arp_pvlan(peth['ip_proxy_arp_pvlan']) - # assign to VRF - if peth['vrf']: - p.add_vrf(peth['vrf']) - else: - p.del_vrf(peth['vrf']) + # assign/remove VRF + p.set_vrf(peth['vrf']) # Change interface MAC address if peth['mac']: diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index 40d8912cc..59fb21125 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -1443,11 +1443,8 @@ def apply(wifi): # ignore link state changes w.set_link_detect(wifi['disable_link_detect']) - # assign to VRF - if wifi['vrf']: - w.add_vrf(wifi['vrf']) - else: - w.del_vrf(wifi['vrf']) + # assign/remove VRF + w.set_vrf(wifi['vrf']) # Change interface MAC address - re-set to real hardware address (hw-id) # if custom mac is removed |