summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-02-13 07:59:42 +0100
committerChristian Poessinger <christian@poessinger.com>2020-02-13 08:01:48 +0100
commite2016b7229e727002e2fada805d14941855f5e7d (patch)
tree41e5f4e2bdac5eebe8a0dfdd3eadcb6a39c88c97 /python/vyos
parentc624e198974790e5d7fa9a158aa879fe75068090 (diff)
downloadvyos-1x-e2016b7229e727002e2fada805d14941855f5e7d.tar.gz
vyos-1x-e2016b7229e727002e2fada805d14941855f5e7d.zip
macvlan: T1635: migrate pseudo-ethernet interface definition to XML/Python
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 90b8fc169..52eab5717 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -1325,6 +1325,44 @@ class EthernetIf(VLANIf):
cmd = '/sbin/ethtool -K {} ufo {}'.format(self._ifname, state)
return self._cmd(cmd)
+class MACVLANIf(VLANIf):
+ """
+ Abstraction of a Linux MACvlan interface
+ """
+ def __init__(self, ifname, config=''):
+ self._ifname = ifname
+
+ if not os.path.exists('/sys/class/net/{}'.format(self._ifname)) and config:
+ cmd = 'ip link add {intf} link {link} type macvlan mode {mode}' \
+ .format(intf=self._ifname, link=config['link'], mode=config['mode'])
+ self._cmd(cmd)
+
+ super().__init__(ifname, type='macvlan')
+
+ @staticmethod
+ def get_config():
+ """
+ VXLAN interfaces require a configuration when they are added using
+ iproute2. This static method will provide the configuration dictionary
+ used by this class.
+
+ Example:
+ >> dict = MACVLANIf().get_config()
+ """
+ config = {
+ 'address': '',
+ 'link': 0,
+ 'mode': ''
+ }
+ return config
+
+ def set_mode(self, mode):
+ """
+ """
+
+ cmd = 'ip link set dev {} type macvlan mode {}'.format(self._ifname, mode)
+ return self._cmd(cmd)
+
class BondIf(VLANIf):
"""