aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dpdk/dpdk.py4
-rw-r--r--tools/module_manager.py42
-rw-r--r--vswitches/ovs_vanilla.py4
3 files changed, 21 insertions, 29 deletions
diff --git a/src/dpdk/dpdk.py b/src/dpdk/dpdk.py
index 0633c7a1..0a63c161 100644
--- a/src/dpdk/dpdk.py
+++ b/src/dpdk/dpdk.py
@@ -28,13 +28,13 @@ import locale
from tools import tasks
from conf import settings
-from tools.module_manager import ModuleManager, KernelModuleInsertMode
+from tools.module_manager import ModuleManager
_LOGGER = logging.getLogger(__name__)
RTE_PCI_TOOL = os.path.join(
settings.getValue('RTE_SDK'), 'tools', 'dpdk_nic_bind.py')
-_DPDK_MODULE_MANAGER = ModuleManager(KernelModuleInsertMode.MODPROBE)
+_DPDK_MODULE_MANAGER = ModuleManager()
#
# system management
diff --git a/tools/module_manager.py b/tools/module_manager.py
index 6ed80e93..39ad5cf4 100644
--- a/tools/module_manager.py
+++ b/tools/module_manager.py
@@ -19,34 +19,21 @@ import subprocess
import logging
from tools import tasks
-class KernelModuleInsertMode(object):
- """Module manager type of insert definition.
- """
- MODPROBE = 1
- INSMOD = 2 #NOT IMPLEMENTED
-
class ModuleManager(object):
"""Simple module manager which acts as system wrapper for Kernel Modules.
"""
_logger = logging.getLogger(__name__)
- def __init__(self, insert_mode=KernelModuleInsertMode.MODPROBE):
- """Initializes data and sets insert mode.
-
- :param insert_mode: insert mode defines how modules are going to
- be inserted in system.
+ def __init__(self):
+ """Initializes data
"""
self._modules = None
- self._insert_mode = insert_mode
def insert_modules(self, modules):
- """Method inserts list of modules using defined insert mode.
-
- :param modules: list of modules to be inserted. Each element on
- list should represent format which is expected
- by KernelModuleInsertMode (e.g. for MODPROBE it
- would be module name).
+ """Method inserts list of modules. In case that module name ends
+ with .ko suffix then insmod will be used for its insertion. Otherwise
+ modprobe will be called.
:returns: None
"""
@@ -56,13 +43,12 @@ class ModuleManager(object):
continue
try:
- if self._insert_mode == KernelModuleInsertMode.MODPROBE:
- tasks.run_task(['sudo', 'modprobe', module], self._logger,
- 'Inserting module \'%s\'...' % module, True)
+ if module.endswith('.ko'):
+ tasks.run_task(['sudo', 'insmod', module], self._logger,
+ 'Insmod module \'%s\'...' % module, True)
else:
- self._logger.error(
- "Kernel module insert mode NOT IMPLEMENTED.")
- raise
+ tasks.run_task(['sudo', 'modprobe', module], self._logger,
+ 'Modprobe module \'%s\'...' % module, True)
except subprocess.CalledProcessError:
self._logger.error('Unable to insert module \'%s\'.', module)
@@ -77,6 +63,8 @@ class ModuleManager(object):
continue
try:
+ # rmmod supports both simple module name and full module path
+ # with .ko suffix
tasks.run_task(['sudo', 'rmmod', module], self._logger,
'Removing module \'%s\'...' % module, True)
except subprocess.CalledProcessError:
@@ -87,11 +75,15 @@ class ModuleManager(object):
def is_module_inserted(module):
"""Check if a module is inserted on system.
"""
+ # get module base name, i.e strip path and .ko suffix if possible
+ module_base_name = module.split('.')[0].split('/').pop()
+
+ # get list of modules from kernel
with open('/proc/modules') as mod_file:
loaded_mods = mod_file.readlines()
# first check if module is loaded
for line in loaded_mods:
- if line.startswith(module):
+ if line.startswith(module_base_name):
return True
return False
diff --git a/vswitches/ovs_vanilla.py b/vswitches/ovs_vanilla.py
index 6716401d..36ad6054 100644
--- a/vswitches/ovs_vanilla.py
+++ b/vswitches/ovs_vanilla.py
@@ -19,7 +19,7 @@ import logging
from conf import settings
from vswitches.vswitch import IVSwitch
from src.ovs import VSwitchd, OFBridge
-from tools.module_manager import ModuleManager, KernelModuleInsertMode
+from tools.module_manager import ModuleManager
from tools import tasks
_LOGGER = logging.getLogger(__name__)
@@ -47,7 +47,7 @@ class OvsVanilla(IVSwitch):
self._vswitchd = VSwitchd(vswitchd_args=vswitchd_args,
expected_cmd="db.sock: connected")
self._bridges = {}
- self._module_manager = ModuleManager(KernelModuleInsertMode.MODPROBE)
+ self._module_manager = ModuleManager()
def start(self):
"""See IVswitch for general description