[lnst] allow to specify cleanup command for device types
Jiří Pírko
jirka at fedoraproject.org
Thu Aug 16 11:43:36 UTC 2012
commit af668d80d0c473943db85d0046ac65e8073d2204
Author: Jiri Pirko <jiri at resnulli.us>
Date: Wed Aug 15 14:07:58 2012 +0200
allow to specify cleanup command for device types
Signed-off-by: Jiri Pirko <jiri at resnulli.us>
NetConfig/NetConfigDevice.py | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/NetConfig/NetConfigDevice.py b/NetConfig/NetConfigDevice.py
index 6a81495..af343b2 100644
--- a/NetConfig/NetConfigDevice.py
+++ b/NetConfig/NetConfigDevice.py
@@ -24,6 +24,7 @@ class NetConfigDeviceGeneric:
'''
_modulename = ""
_moduleparams = ""
+ _cleanupcmd = ""
def __init__(self, netdev, config):
self._netdev = netdev
@@ -61,12 +62,7 @@ class NetConfigDeviceGeneric:
exec_cmd("modprobe %s %s" % (self._modulename, self._moduleparams))
@classmethod
- def type_cleanup(self):
- if self._modulename:
- exec_cmd("modprobe -r %s" % self._modulename, die_on_err=False)
-
- @classmethod
- def type_check(self):
+ def _module_check(self):
if self._modulename:
output = exec_cmd("modinfo -F filename %s" % self._modulename, die_on_err=False)[0]
for line in output.split("\n"):
@@ -74,6 +70,13 @@ class NetConfigDeviceGeneric:
return True
False
+ @classmethod
+ def type_cleanup(self):
+ if self._modulename and self._module_check():
+ exec_cmd("modprobe -r %s" % self._modulename, die_on_err=False)
+ if self._cleanupcmd:
+ exec_cmd(self._cleanupcmd, die_on_err=False)
+
class NetConfigDeviceEth(NetConfigDeviceGeneric):
def configure(self):
netdev = self._netdev
@@ -214,6 +217,7 @@ class NetConfigDeviceVlan(NetConfigDeviceGeneric):
class NetConfigDeviceTeam(NetConfigDeviceGeneric):
_pidfile = None
+ _cleanupcmd = "killall -q teamd"
def _slaves_up(self):
for slaveid in get_slaves(self._netdev):
@@ -268,5 +272,4 @@ def NetConfigDeviceType(dev_type):
def NetConfigDeviceAllCleanup():
for dev_type in type_class_mapping:
- if NetConfigDeviceType(dev_type).type_check():
- NetConfigDeviceType(dev_type).type_cleanup()
+ NetConfigDeviceType(dev_type).type_cleanup()
More information about the LNST-developers
mailing list