Usage of this method is similar to using config. You need to specify device, value of mtu and optionally persistency. Eg. host.set_mtu("testiface", 8000, persistency=True)
Signed-off-by: Jiri Prochazka jprochaz@redhat.com --- lnst/Controller/Task.py | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py index 034dc5f..e78edee 100644 --- a/lnst/Controller/Task.py +++ b/lnst/Controller/Task.py @@ -173,6 +173,10 @@ class HostAPI(object):
return self._ctl._run_command(cmd)
+ def set_mtu(self, device, mtu, persistent=False): + path = "/sys/class/net/%s/mtu" % self.get_devname(device) + self.config(path, mtu, persistent) + def run(self, what, **kwargs): """ Configure an option in /sys or /proc on the host.
This method uses sysfs for getting MTU value from a device.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com --- lnst/Controller/Machine.py | 3 +++ lnst/Controller/Task.py | 7 +++++++ lnst/Slave/NetTestSlave.py | 6 ++++++ 3 files changed, 16 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py index e303c1a..08c251f 100644 --- a/lnst/Controller/Machine.py +++ b/lnst/Controller/Machine.py @@ -612,6 +612,9 @@ class Interface(object): except IndexError: raise PrefixMissingError
+ def get_mtu(self): + return self._machine._rpc_call("get_mtu", self._id) + def _get_config(self): config = {"hwaddr": self._hwaddr, "type": self._type, "addresses": self._addresses, "slaves": self._slaves.keys(), diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py index e78edee..14e8620 100644 --- a/lnst/Controller/Task.py +++ b/lnst/Controller/Task.py @@ -177,6 +177,10 @@ class HostAPI(object): path = "/sys/class/net/%s/mtu" % self.get_devname(device) self.config(path, mtu, persistent)
+ def get_mtu(self, interface_id): + iface = self._interfaces[interface_id] + return iface.get_mtu() + def run(self, what, **kwargs): """ Configure an option in /sys or /proc on the host. @@ -357,6 +361,9 @@ class InterfaceAPI(object): def get_ip_prefix(self, ip_index): return VolatileValue(self._if.get_prefix, ip_index)
+ def get_mtu(self): + return VolatileValue(self._if.get_mtu) + class ModuleAPI(object): """ An API class representing a module. """
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py index 8eb1f99..0d1b49b 100644 --- a/lnst/Slave/NetTestSlave.py +++ b/lnst/Slave/NetTestSlave.py @@ -609,6 +609,12 @@ class SlaveMethods: device.set_netns(None) return True
+ def get_mtu(self, if_id): + device = self._if_manager.get_mapped_device(if_id) + dev_name = device.get_name() + mtu, _ = exec_cmd("cat /sys/class/net/%s/mtu" % dev_name, log_outputs=False) + return mtu + class ServerHandler(ConnectionHandler): def __init__(self, addr): super(ServerHandler, self).__init__()
lnst-developers@lists.fedorahosted.org