I think the InterfaceManager automatically creates a "disabled" Device
class instance for the loopback device.
So I'm not against the creation of a special class type for it but I
think maybe we need a bit more integration if we want to go that way so
that we avoid having 2 instances for loopback tracked in the
Interfacemanager.
On the other hand maybe we don't need this at all and the Device class
already suuports all of this... we should check.
-Ondrej
On Tue, May 18, 2021 at 03:10:36PM +0200, Jan Tluka wrote:
This patch adds implementation of a device class for the loopback
device (lo)
so that users can benefit from the common API for the other devices, for
example IP address configuration.
The up() and down() methods are disabled for this type of device as this
breaks connection between the controller and LNST agents during recipe
execution.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Devices/LoopbackDevice.py | 29 +++++++++++++++++++++++++++++
lnst/Devices/__init__.py | 2 ++
2 files changed, 31 insertions(+)
create mode 100644 lnst/Devices/LoopbackDevice.py
diff --git a/lnst/Devices/LoopbackDevice.py b/lnst/Devices/LoopbackDevice.py
new file mode 100644
index 00000000..2154897d
--- /dev/null
+++ b/lnst/Devices/LoopbackDevice.py
@@ -0,0 +1,29 @@
+"""
+Defines the LoopbackDevice 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)
+"""
+
+import pyroute2
+import logging
+from lnst.Devices.Device import Device
+
+class LoopbackDevice(Device):
+ @Device.name.getter
+ def name(self):
+ return "lo"
+
+ def _create(self):
+ pass
+
+ def up(self):
+ logging.warning("Link state operations on LoopbackDevice are
disallowed")
+
+ def down(self):
+ logging.warning("Link state operations on LoopbackDevice are
disallowed")
diff --git a/lnst/Devices/__init__.py b/lnst/Devices/__init__.py
index 52e4499e..b294ff57 100644
--- a/lnst/Devices/__init__.py
+++ b/lnst/Devices/__init__.py
@@ -1,5 +1,6 @@
from lnst.Common.DeviceError import DeviceError
from lnst.Devices.Device import Device
+from lnst.Devices.LoopbackDevice import LoopbackDevice
from lnst.Devices.BridgeDevice import BridgeDevice
from lnst.Devices.OvsBridgeDevice import OvsBridgeDevice
from lnst.Devices.BondDevice import BondDevice
@@ -22,6 +23,7 @@ from lnst.Devices.RemoteDevice import RemoteDevice,
remotedev_decorator
device_classes = [
("Device", Device),
+ ("LoopbackDevice", LoopbackDevice),
("BridgeDevice", BridgeDevice),
("OvsBridgeDevice", OvsBridgeDevice),
("MacvlanDevice", MacvlanDevice),
--
2.26.3
_______________________________________________
LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedora...
Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure