[PATCH] NmConfigDevice: beter detection of nm_managed
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit adds functionality to the slave. Now when checking the
Managed property of a device if the device doesn't exist yet, we check
the slave devices first and if they are all not managed we declare that
the master device is also not managed. The same goes for all slaves
being managed.
This gives us a bit more flexibility when trying to mix NM configuration
with the traditional one.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index c743ce8..7a236f9 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -54,6 +54,12 @@ def is_nm_managed_by_name(dev_name):
dev_props = dbus.Interface(dev, "org.freedesktop.DBus.Properties")
return dev_props.Get(IF_PRE + ".Device", "Managed")
+def _dev_exists(hwaddr):
+ devnames = scan_netdevs()
+ for dev in devnames:
+ if dev["hwaddr"] == hwaddr:
+ return True
+
class NmConfigDeviceGeneric(object):
'''
Generic class for device manipulation all type classes should
@@ -234,11 +240,10 @@ class NmConfigDeviceEth(NmConfigDeviceGeneric):
@classmethod
def is_nm_managed(cls, netdev, config):
managed = super(NmConfigDeviceEth, cls).is_nm_managed(netdev, config)
- devnames = scan_netdevs()
- for dev in devnames:
- if dev["hwaddr"] == netdev["hwaddr"]:
- return managed
- return False
+ if _dev_exists(netdev["hwaddr"]):
+ return managed
+ else:
+ return False
def up(self):
netdev = self._netdev
@@ -302,7 +307,13 @@ class NmConfigDeviceBond(NmConfigDeviceGeneric):
@classmethod
def is_nm_managed(cls, netdev, config):
- managed = super(NmConfigDeviceBond, cls).is_nm_managed(netdev, config)
+ if _dev_exists(netdev["hwaddr"]):
+ managed = super(NmConfigDeviceBond, cls).is_nm_managed(netdev,
+ config)
+ else:
+ slave_id = get_slaves(netdev)[1]
+ netdev = config[slave_id]
+ managed = is_nm_managed(netdev, config)
for slave in get_slaves(netdev):
netdev = config[slave]
@@ -429,7 +440,13 @@ class NmConfigDeviceBridge(NmConfigDeviceGeneric):
@classmethod
def is_nm_managed(cls, netdev, config):
- managed = super(NmConfigDeviceBridge, cls).is_nm_managed(netdev, config)
+ if _dev_exists(netdev["hwaddr"]):
+ managed = super(NmConfigDeviceBond, cls).is_nm_managed(netdev,
+ config)
+ else:
+ slave_id = get_slaves(netdev)[1]
+ netdev = config[slave_id]
+ managed = is_nm_managed(netdev, config)
for slave in get_slaves(netdev):
netdev = config[slave]
@@ -560,7 +577,13 @@ class NmConfigDeviceVlan(NmConfigDeviceGeneric):
@classmethod
def is_nm_managed(cls, netdev, config):
- managed = super(NmConfigDeviceVlan, cls).is_nm_managed(netdev, config)
+ if _dev_exists(netdev["hwaddr"]):
+ managed = super(NmConfigDeviceBond, cls).is_nm_managed(netdev,
+ config)
+ else:
+ slave_id = get_slaves(netdev)[1]
+ netdev = config[slave_id]
+ managed = is_nm_managed(netdev, config)
for slave in get_slaves(netdev):
slave_netdev = config[slave]
--
1.8.3.1
10 years, 8 months
[PATCH] NetConfigDevice: is_nm_managed_by_name checks use_nm option
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
The function is_nm_managed_by_name now checks both if NM is running and
if the option use_nm is set to True.
I made this change so that I could delete a few lines where we check
these parameters.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NetConfigDevice.py | 8 ++------
lnst/Slave/NetTestSlave.py | 4 +---
lnst/Slave/NmConfigDevice.py | 4 +++-
3 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py
index 27f4cb3..91dce5e 100644
--- a/lnst/Slave/NetConfigDevice.py
+++ b/lnst/Slave/NetConfigDevice.py
@@ -298,9 +298,7 @@ def NetConfigDevice(netdev, config):
'''
Class dispatcher
'''
- if check_process_running("NetworkManager") and \
- lnst_config.get_option("environment", "use_nm") and \
- is_nm_managed(netdev, config):
+ if is_nm_managed(netdev, config):
return nm_type_class_mapping[netdev["type"]](netdev, config)
else:
return type_class_mapping[netdev["type"]](netdev, config)
@@ -309,9 +307,7 @@ def NetConfigDeviceType(netdev, config):
'''
Class dispatcher for classmethods
'''
- if check_process_running("NetworkManager") and \
- lnst_config.get_option("environment", "use_nm") and \
- is_nm_managed(netdev, config):
+ if is_nm_managed(netdev, config):
return nm_type_class_mapping[netdev["type"]]
else:
return type_class_mapping[netdev["type"]]
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 272cb76..4775a42 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -118,9 +118,7 @@ class SlaveMethods:
devs = self.get_devices_by_hwaddr(hwaddr)
for dev in devs:
- if check_process_running("NetworkManager") and \
- lnst_config.get_option("environment", "use_nm") and \
- is_nm_managed_by_name(dev["name"]):
+ if is_nm_managed_by_name(dev["name"]):
bus = dbus.SystemBus()
nm_obj = bus.get_object("org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager")
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index bf08afd..c743ce8 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -23,6 +23,7 @@ from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
from lnst.Common.NetUtils import scan_netdevs
from lnst.Common.Utils import check_process_running
+from lnst.Common.Config import lnst_config
NM_BUS = "org.freedesktop.NetworkManager"
OBJ_PRE = "/org/freedesktop/NetworkManager"
@@ -34,7 +35,8 @@ _DEV_UNAVAILABLE = 20
_DEV_DISCONNECTED = 30
def is_nm_managed_by_name(dev_name):
- if not check_process_running("NetworkManager"):
+ if not check_process_running("NetworkManager") or\
+ not lnst_config.get_option("environment", "use_nm"):
return False
bus = dbus.SystemBus()
--
1.8.3.1
10 years, 8 months
[PATCH] NmConfigDevice: add function import
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
I forgot to import this function... sorry.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index 5168aff..bf08afd 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -22,6 +22,7 @@ from lnst.Common.ExecCmd import exec_cmd
from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
from lnst.Common.NetUtils import scan_netdevs
+from lnst.Common.Utils import check_process_running
NM_BUS = "org.freedesktop.NetworkManager"
OBJ_PRE = "/org/freedesktop/NetworkManager"
--
1.8.3.1
10 years, 9 months
[lnst] NmConfigDevice: add function import
by Jiří Pírko
commit 2c0aa5083da808705b4a48bc34a52fb01b328c94
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jul 26 13:36:41 2013 +0200
NmConfigDevice: add function import
I forgot to import this function... sorry.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NmConfigDevice.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index 5168aff..bf08afd 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -22,6 +22,7 @@ from lnst.Common.ExecCmd import exec_cmd
from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
from lnst.Common.NetUtils import scan_netdevs
+from lnst.Common.Utils import check_process_running
NM_BUS = "org.freedesktop.NetworkManager"
OBJ_PRE = "/org/freedesktop/NetworkManager"
10 years, 9 months
[PATCH 0/2] NM management detection
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
These two patches add support for detecting if a device is managed by NM. This
is useful for combining the two approaches lnst can use for configuration. The
functionality for mixed configuration was already there, but it wouldn't work
because lnst would try to use NM for both managed and not managed devices. Now
the mixed configuration should work.
It is important to note that it is impossible to have several devices in a
master-slave relationship where some of them are configured by NM and some in
the traditional way. In these cases LNST will throw an exception and stop the
test execution.
This is a bit impractical because the controller can't detect which interfaces
are managed when it's matching the recipe topology against what the pool offers,
so fixing this exception will require manual intervention from the user. But
since this is a corner case of a corner case the user should probably know what
he's doing when this occurs.
Other than this restriction lnst should be able to mix configration of sepparate
eth interfaces (without a master), and groups of interfaces (in a master-slave
relationship) which are all configured in the same way.
Ondrej Lichtner (2):
NmConfigDevice: add NM management check functions
Slave: use function is_nm_managed
lnst/Slave/NetConfig.py | 2 +-
lnst/Slave/NetConfigDevice.py | 17 ++++---
lnst/Slave/NetTestSlave.py | 6 ++-
lnst/Slave/NmConfigDevice.py | 101 +++++++++++++++++++++++++++++++++++++++++-
4 files changed, 114 insertions(+), 12 deletions(-)
--
1.8.3.1
10 years, 9 months
[lnst] Slave: use function is_nm_managed
by Jiří Pírko
commit 7922c4e2b3f5f38ec6f5d0fd5bc5a75e24a5907c
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jul 26 13:08:48 2013 +0200
Slave: use function is_nm_managed
This commit adds the usage of the new function to the appropriate
places. Now instead of just checking if NM is running and if the
variable use_nm is set, we also check if the device is actually managed
by NM and can therefore be configured by it.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NetConfig.py | 2 +-
lnst/Slave/NetConfigDevice.py | 17 ++++++++++-------
lnst/Slave/NetTestSlave.py | 6 ++++--
3 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/lnst/Slave/NetConfig.py b/lnst/Slave/NetConfig.py
index a9c3729..d159321 100644
--- a/lnst/Slave/NetConfig.py
+++ b/lnst/Slave/NetConfig.py
@@ -81,7 +81,7 @@ class NetConfig:
dev_type = config["type"]
if not dev_type in self._get_used_types():
logging.info("Cleaning up '%s' device class.", dev_type)
- NetConfigDeviceType(dev_type).type_cleanup()
+ NetConfigDeviceType(config, self._config).type_cleanup()
def get_interface_config(self, if_id):
return self._config[if_id]
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py
index c66fa50..27f4cb3 100644
--- a/lnst/Slave/NetConfigDevice.py
+++ b/lnst/Slave/NetConfigDevice.py
@@ -18,6 +18,7 @@ from lnst.Common.ExecCmd import exec_cmd
from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
from lnst.Slave.NmConfigDevice import type_class_mapping as nm_type_class_mapping
+from lnst.Slave.NmConfigDevice import is_nm_managed
from lnst.Common.Utils import check_process_running
from lnst.Common.Config import lnst_config
@@ -298,26 +299,28 @@ def NetConfigDevice(netdev, config):
Class dispatcher
'''
if check_process_running("NetworkManager") and \
- lnst_config.get_option("environment", "use_nm"):
+ lnst_config.get_option("environment", "use_nm") and \
+ is_nm_managed(netdev, config):
return nm_type_class_mapping[netdev["type"]](netdev, config)
else:
return type_class_mapping[netdev["type"]](netdev, config)
-def NetConfigDeviceType(dev_type):
+def NetConfigDeviceType(netdev, config):
'''
Class dispatcher for classmethods
'''
if check_process_running("NetworkManager") and \
- lnst_config.get_option("environment", "use_nm"):
- return nm_type_class_mapping[dev_type]
+ lnst_config.get_option("environment", "use_nm") and \
+ is_nm_managed(netdev, config):
+ return nm_type_class_mapping[netdev["type"]]
else:
- return type_class_mapping[dev_type]
+ return type_class_mapping[netdev["type"]]
def NetConfigDeviceAllCleanup():
if check_process_running("NetworkManager") and \
lnst_config.get_option("environment", "use_nm"):
for dev_type in nm_type_class_mapping:
- NetConfigDeviceType(dev_type).type_cleanup()
+ nm_type_class_mapping[dev_type].type_cleanup()
else:
for dev_type in type_class_mapping:
- NetConfigDeviceType(dev_type).type_cleanup()
+ type_class_mapping[dev_type].type_cleanup()
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index af9ab90..272cb76 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -32,6 +32,7 @@ from lnst.Common.NetTestCommand import NetTestCommandContext
from lnst.Common.NetTestCommand import CommandException, NetTestCommand
from lnst.Slave.NetConfig import NetConfig
from lnst.Slave.NetConfigDevice import NetConfigDeviceAllCleanup
+from lnst.Slave.NmConfigDevice import is_nm_managed_by_name
from lnst.Common.Utils import check_process_running
from lnst.Common.ConnectionHandler import recv_data, send_data
from lnst.Common.ConnectionHandler import ConnectionHandler
@@ -117,8 +118,9 @@ class SlaveMethods:
devs = self.get_devices_by_hwaddr(hwaddr)
for dev in devs:
- if check_process_running("NetworkManager") and\
- lnst_config.get_option("environment", "use_nm"):
+ if check_process_running("NetworkManager") and \
+ lnst_config.get_option("environment", "use_nm") and \
+ is_nm_managed_by_name(dev["name"]):
bus = dbus.SystemBus()
nm_obj = bus.get_object("org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager")
10 years, 9 months
[lnst] NmConfigDevice: add NM management check functions
by Jiří Pírko
commit 63be3a2e85df6bda4831a7a539cbf313e4bdb5cd
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jul 26 13:08:47 2013 +0200
NmConfigDevice: add NM management check functions
This commit adds a function is_nm_managed_by_name which checks if the
device with a specified name is managed by NM. When the device doesn't
exist it assumes that NM manages it as it's probably a soft device that
will be created.
Additionaly a class method is_nm_managed was added to the NmConfigDevice
class hierarchy that uses the new function and returns if the specified
device and potentially it's group of slaves is managed by NM and in case
of a conflict an Exception can be raised.
Lastly a function is_nm_managed has been added that just calls the
class method is_nm_managed from the approriate class.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NmConfigDevice.py | 101 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 99 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index e7d6418..5168aff 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -21,6 +21,7 @@ import time
from lnst.Common.ExecCmd import exec_cmd
from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
+from lnst.Common.NetUtils import scan_netdevs
NM_BUS = "org.freedesktop.NetworkManager"
OBJ_PRE = "/org/freedesktop/NetworkManager"
@@ -31,6 +32,25 @@ _ACON_ACTIVATED = 2
_DEV_UNAVAILABLE = 20
_DEV_DISCONNECTED = 30
+def is_nm_managed_by_name(dev_name):
+ if not check_process_running("NetworkManager"):
+ return False
+
+ bus = dbus.SystemBus()
+ nm_obj = bus.get_object(NM_BUS, OBJ_PRE)
+ nm_if = dbus.Interface(nm_obj, IF_PRE)
+ try:
+ device_obj_path = nm_if.GetDeviceByIpIface(dev_name)
+ except:
+ #There is a higher possibility that if the interface doesn't exist
+ #it's a software interface that can be created by NM so we say that it's
+ #managed and check existance of physical interfaces sepparately
+ return True
+
+ dev = bus.get_object(NM_BUS, device_obj_path)
+ dev_props = dbus.Interface(dev, "org.freedesktop.DBus.Properties")
+ return dev_props.Get(IF_PRE + ".Device", "Managed")
+
class NmConfigDeviceGeneric(object):
'''
Generic class for device manipulation all type classes should
@@ -81,6 +101,10 @@ class NmConfigDeviceGeneric(object):
def type_cleanup(self):
pass
+ @classmethod
+ def is_nm_managed(cls, netdev, config):
+ return is_nm_managed_by_name(netdev["name"])
+
def _wait_for_state(self, new_state, old_state, reason):
self._device_state = new_state
if self._device_state == self._wait_for:
@@ -204,6 +228,15 @@ class NmConfigDeviceGeneric(object):
netdev["acon_obj_path"] = ""
class NmConfigDeviceEth(NmConfigDeviceGeneric):
+ @classmethod
+ def is_nm_managed(cls, netdev, config):
+ managed = super(NmConfigDeviceEth, cls).is_nm_managed(netdev, config)
+ devnames = scan_netdevs()
+ for dev in devnames:
+ if dev["hwaddr"] == netdev["hwaddr"]:
+ return managed
+ return False
+
def up(self):
netdev = self._netdev
@@ -264,6 +297,19 @@ class NmConfigDeviceBond(NmConfigDeviceGeneric):
_modulename = "bonding"
_moduleparams = "max_bonds=0"
+ @classmethod
+ def is_nm_managed(cls, netdev, config):
+ managed = super(NmConfigDeviceBond, cls).is_nm_managed(netdev, config)
+
+ for slave in get_slaves(netdev):
+ netdev = config[slave]
+ if is_nm_managed(netdev, config) != managed:
+ msg = "Mixing NM managed and not managed devices in a "\
+ "master-slave relationship is not allowed!"
+ raise Exception(msg)
+
+ return managed
+
def up(self):
super(NmConfigDeviceBond, self).up()
@@ -378,6 +424,19 @@ class NmConfigDeviceBond(NmConfigDeviceGeneric):
class NmConfigDeviceBridge(NmConfigDeviceGeneric):
_modulename = "bridge"
+ @classmethod
+ def is_nm_managed(cls, netdev, config):
+ managed = super(NmConfigDeviceBridge, cls).is_nm_managed(netdev, config)
+
+ for slave in get_slaves(netdev):
+ netdev = config[slave]
+ if is_nm_managed(netdev, config) != managed:
+ msg = "Mixing NM managed and not managed devices in a "\
+ "master-slave relationship is not allowed!"
+ raise Exception(msg)
+
+ return managed
+
def up(self):
super(NmConfigDeviceBridge, self).up()
@@ -480,11 +539,35 @@ class NmConfigDeviceBridge(NmConfigDeviceGeneric):
class NmConfigDeviceMacvlan(NmConfigDeviceGeneric):
#Not supported by NetworkManager yet
- pass
+ @classmethod
+ def is_nm_managed(cls, netdev, config):
+ managed = False
+
+ for slave in get_slaves(netdev):
+ slave_netdev = config[slave]
+ if is_nm_managed(slave_netdev, config) != managed:
+ msg = "Mixing NM managed and not managed devices in a "\
+ "master-slave relationship is not allowed!"
+ raise Exception(msg)
+
+ return managed
class NmConfigDeviceVlan(NmConfigDeviceGeneric):
_modulename = "8021q"
+ @classmethod
+ def is_nm_managed(cls, netdev, config):
+ managed = super(NmConfigDeviceVlan, cls).is_nm_managed(netdev, config)
+
+ for slave in get_slaves(netdev):
+ slave_netdev = config[slave]
+ if is_nm_managed(slave_netdev, config) != managed:
+ msg = "Mixing NM managed and not managed devices in a "\
+ "master-slave relationship is not allowed!"
+ raise Exception(msg)
+
+ return managed
+
def _check_ip_link_add(self):
output = exec_cmd("ip link help", die_on_err=False,
log_outputs=False)[1]
@@ -541,7 +624,18 @@ class NmConfigDeviceVlan(NmConfigDeviceGeneric):
class NmConfigDeviceTeam(NmConfigDeviceGeneric):
#Not supported by NetworkManager yet
- pass
+ @classmethod
+ def is_nm_managed(cls, netdev, config):
+ managed = False
+
+ for slave in get_slaves(netdev):
+ slave_netdev = config[slave]
+ if is_nm_managed(slave_netdev, config) != managed:
+ msg = "Mixing NM managed and not managed devices in a "\
+ "master-slave relationship is not allowed!"
+ raise Exception(msg)
+
+ return managed
type_class_mapping = {
"eth": NmConfigDeviceEth,
@@ -551,3 +645,6 @@ type_class_mapping = {
"vlan": NmConfigDeviceVlan,
"team": NmConfigDeviceTeam
}
+
+def is_nm_managed(netdev, config):
+ return type_class_mapping[netdev["type"]].is_nm_managed(netdev, config)
10 years, 9 months
[PATCH 0/4] changes to slave configuration cleanup
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch series extends the amount of cleanup that the slave does by itself.
In the past cleanup was only executed when the controller requested it through
rpc, which was not the best way since both the controller or the slave can stop
before that happens and leave the slave machine in an inconsistent state.
Now the slave detects when the controller disconnects and cleans any leftover
configuration by itself, the same happens when the slave is terminated.
Finally I added an exception handler to the connection handler since it could
cause the slave to crash without cleanup.
There should be a followup patch that also notifies the controller about the
fact that the slave is terminating, but that will have to wait a bit when Radek
stabilizes his Controller code ans submits it.
Ondrej Lichtner (4):
NetConfig: store references to NetConfigDevice objects
NetTestSlave: cleanup on controller disconnect
NetTestSlave: add cleanup on slave finish
ConnectionHandler: add handling of select exceptions
lnst/Common/ConnectionHandler.py | 5 +++-
lnst/Slave/NetConfig.py | 26 +++++++++++---------
lnst/Slave/NetTestSlave.py | 53 ++++++++++++++++++++--------------------
3 files changed, 45 insertions(+), 39 deletions(-)
--
1.8.3.1
10 years, 9 months
[lnst] ConnectionHandler: add handling of select exceptions
by Jiří Pírko
commit 95e770593cd247d1ce284871262d00b82ffe5a48
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jul 26 12:59:45 2013 +0200
ConnectionHandler: add handling of select exceptions
When slave was in a select call and a keyboard interrupt was recieved it
cased the slave to crash with an exception. This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/ConnectionHandler.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Common/ConnectionHandler.py b/lnst/Common/ConnectionHandler.py
index 8e9e548..80a9538 100644
--- a/lnst/Common/ConnectionHandler.py
+++ b/lnst/Common/ConnectionHandler.py
@@ -67,7 +67,10 @@ class ConnectionHandler(object):
def check_connections(self):
requests = []
- rl, wl, xl = select.select(self._connections.values(), [], [])
+ try:
+ rl, wl, xl = select.select(self._connections.values(), [], [])
+ except select.error:
+ return []
for f in rl:
try:
data = recv_data(f)
10 years, 9 months
[lnst] NetTestSlave: add cleanup on slave finish
by Jiří Pírko
commit 69eaa1b369eb18399037d06f1dc17cdb989f42a3
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jul 26 12:59:44 2013 +0200
NetTestSlave: add cleanup on slave finish
When killed slaves were only cleaning runing processes. Now slaves also
deconfigure any configured interfaces.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NetTestSlave.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 182bb41..af9ab90 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -449,7 +449,11 @@ class NetTestSlave:
for msg in msgs:
self._process_msg(msg[1])
+ logging.info("Cleaning up leftover commands.")
self._cmd_context.cleanup()
+ logging.info("Cleaning up configured interfaces.")
+ self._netconfig.deconfigure_all()
+ self._netconfig.cleanup()
def _process_msg(self, msg):
if msg["type"] == "command":
10 years, 9 months