From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch adds a new method 'get_if_data' to the SlaveMethods class.
It returns information about a mapped interface, it will be used after
interface configuration to fill out missing information on the
Controller side.
This also changes the format of 'if_update' messages sent from the Slave
to the Controller, that now sends the return value of the get_if_data
method.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 2 +-
lnst/Slave/InterfaceManager.py | 11 ++++++++---
lnst/Slave/NetTestSlave.py | 6 ++++++
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 52e85e4..c4f5aa6 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -91,7 +91,7 @@ class Machine(object):
except:
iface = None
if iface:
- iface.update(if_data)
+ iface.update(if_data['if_data'])
#
# Factory methods for constructing interfaces on this machine. The
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index c815d5f..ab7efcd 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -327,9 +327,7 @@ class Device(object):
#return an update message that will be sent to the controller
return {"type": "if_update",
- "devname": self._name,
- "hwaddr": self._hwaddr,
- "mtu": self._mtu}
+ "if_data": self.get_if_data()}
return None
def del_link(self):
@@ -500,3 +498,10 @@ class Device(object):
out, _ = exec_cmd("ethtool -i %s" % self._name, False, False, False)
match = re.search("^driver: (.*)$", out, re.MULTILINE)
return match.group(1)
+
+ def get_if_data(self):
+ if_data = {"devname": self._name,
+ "hwaddr": self._hwaddr,
+ "mtu": self._mtu,
+ "driver": self._driver}
+ return if_data
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index ec6de85..04e6dec 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -149,6 +149,12 @@ class SlaveMethods:
return matched
+ def get_if_data(self, if_id):
+ dev = self._if_manager.get_mapped_device(if_id)
+ if dev is None:
+ return None
+ return dev.get_if_data()
+
def set_device_up(self, if_id):
dev = self._if_manager.get_mapped_device(if_id)
dev.up()
--
2.1.0