This patch adds new device GreDevice to setup a gre tunnel device.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Devices/GreDevice.py | 44 +++++++++++++++++++++++++++++++++++++++
lnst/Devices/__init__.py | 2 ++
2 files changed, 46 insertions(+)
create mode 100644 lnst/Devices/GreDevice.py
diff --git a/lnst/Devices/GreDevice.py b/lnst/Devices/GreDevice.py
new file mode 100644
index 00000000..d1affbc3
--- /dev/null
+++ b/lnst/Devices/GreDevice.py
@@ -0,0 +1,44 @@
+"""
+Defines the GreDevice class.
+
+Copyright 2021 Red Hat, Inc.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+jtluka(a)redhat.com (Jan Tluka)
+"""
+
+from lnst.Common.IpAddress import ipaddress
+from lnst.Devices.SoftDevice import SoftDevice
+
+
+class GreDevice(SoftDevice):
+ _name_template = "t_gre"
+ _link_type = "gre"
+ _mandatory_opts = ["remote"]
+
+ @property
+ def local(self):
+ try:
+ return ipaddress(self._get_linkinfo_data_attr("IFLA_GRE_LOCAL"))
+ except:
+ return None
+
+ @local.setter
+ def local(self, val):
+ self._set_linkinfo_data_attr("IFLA_GRE_LOCAL", str(ipaddress(val)))
+ self._nl_link_sync("set")
+
+ @property
+ def remote(self):
+ try:
+ return ipaddress(self._get_linkinfo_data_attr("IFLA_GRE_REMOTE"))
+ except:
+ return None
+
+ @remote.setter
+ def remote(self, val):
+ self._set_linkinfo_data_attr("IFLA_GRE_REMOTE", str(ipaddress(val)))
+ self._nl_link_sync("set")
diff --git a/lnst/Devices/__init__.py b/lnst/Devices/__init__.py
index b38d1b60..ddc462e8 100644
--- a/lnst/Devices/__init__.py
+++ b/lnst/Devices/__init__.py
@@ -7,6 +7,7 @@ from lnst.Devices.TeamDevice import TeamDevice
from lnst.Devices.MacvlanDevice import MacvlanDevice
from lnst.Devices.VlanDevice import VlanDevice
from lnst.Devices.VxlanDevice import VxlanDevice
+from lnst.Devices.GreDevice import GreDevice
from lnst.Devices.VtiDevice import VtiDevice, Vti6Device
from lnst.Devices.VethDevice import VethDevice, PairedVethDevice
from lnst.Devices.VethPair import VethPair
@@ -20,6 +21,7 @@ device_classes = [
("MacvlanDevice", MacvlanDevice),
("VlanDevice", VlanDevice),
("VxlanDevice", VxlanDevice),
+ ("GreDevice", GreDevice),
("VethDevice", VethDevice),
("PairedVethDevice", PairedVethDevice),
("VtiDevice", VtiDevice),
--
2.26.3
Show replies by date