From 53636b4ba9534744e4f461dae1a8b81640f30afc Mon Sep 17 00:00:00 2001 From: Jan Vcelak Date: Thu, 6 Dec 2012 19:04:28 +0100 Subject: [PATCH] net plugin: use hardware enumeration --- tuned/plugins/plugin_net.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tuned/plugins/plugin_net.py b/tuned/plugins/plugin_net.py index 570f770..24751a7 100644 --- a/tuned/plugins/plugin_net.py +++ b/tuned/plugins/plugin_net.py @@ -2,6 +2,7 @@ import base import tuned.logs from tuned.utils.nettool import ethcard import os +import re log = tuned.logs.get() @@ -10,21 +11,19 @@ class NetTuningPlugin(base.Plugin): Plugin for ethernet card options tuning. """ + @classmethod + def device_requirements(cls): + return { + "subsystem": "net", + "device_path": re.compile('(?!.*/virtual/.*)') + } + def _post_init(self): self.devidle = {} self.stats = {} log.info("devices: %s" % str(self._devices)); self._load_monitor = self._monitors_repository.create("net", self._devices) - @classmethod - def tunable_devices(cls): - available = [] - for root, dirs, files in os.walk("/sys/devices"): - if root.endswith("/net") and not root.endswith("/virtual/net"): - available += dirs - log.info("Tunable devices: %s" % str(available)) - return available - def _calc_speed(self, speed): # 0.6 is just a magical constant (empirical value): Typical workload on netcard won't exceed # that and if it does, then the code is smart enough to adapt it.