summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-04 19:51:37 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-04 21:45:23 +0100
commit5bf9dfd17096af6e7cf06e8e20eb16e8e55b9177 (patch)
tree6e02e47c2813d30c9bab5ce25b3a0d45061bb268 /python
parentbb705d1a90cad14f07b5e61c44365868283feee9 (diff)
downloadvyos-1x-5bf9dfd17096af6e7cf06e8e20eb16e8e55b9177.tar.gz
vyos-1x-5bf9dfd17096af6e7cf06e8e20eb16e8e55b9177.zip
vrf: T31: support add/remove of interfaces from vrf
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index beeafa420..430b3c4e4 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -202,6 +202,12 @@ 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}',
+ },
}
_sysfs_get = {
@@ -345,7 +351,7 @@ class Interface(Control):
self.del_addr(addr)
# ---------------------------------------------------------------------
- # A code refactoring is required as this type check is present as
+ # A code refactoring is required as this type check is present as
# Interface implement behaviour for one of it's sub-class.
# It is required as the current pattern for vlan is:
@@ -405,6 +411,26 @@ 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):
+ """
+ Remove interface from given VRF instance.
+
+ Example:
+ >>> from vyos.ifconfig import Interface
+ >>> Interface('eth0').del_vrf('foo')
+ """
+ self.set_interface('del_vrf', vrf)
+
def set_arp_cache_tmo(self, tmo):
"""
Set ARP cache timeout value in seconds. Internal Kernel representation