1
0
Fork 0

Added is_supported class method into plugin API. It is used to detect if the plugin is supported by the HW and can be loaded.

This commit is contained in:
Jan Kaluza 2012-04-16 10:55:50 +02:00
parent b23cd44124
commit 4c8d64f98a
4 changed files with 23 additions and 2 deletions

View file

@ -19,6 +19,10 @@ class Plugin(object):
def tunable_devices(cls):
return None
@classmethod
def is_supported(cls):
return True
# instance methods
def __init__(self, devices = None, options = None):

View file

@ -17,11 +17,14 @@ class EeePCSHEPlugin(tuned.plugins.Plugin):
self._she_mode = None
self._load_monitor = tuned.monitors.get_repository().create("load", devices)
@classmethod
def is_supported(cls):
try:
os.open("/sys/devices/platform/eeepc/cpufv", os.O_WRONLY)
return True
except:
log.info("eeepc_she is not supported on you system")
raise
return False
@classmethod
def _get_default_options(cls):

View file

@ -31,6 +31,14 @@ class PluginRepository(tuned.patterns.Singleton):
plugin_exception = tuned.plugins.exception.LoadPluginException(plugin_name, exception)
raise plugin_exception
def is_supported(self, plugin_name):
try:
plugin_cls = self._loader.load(plugin_name)
return plugin_cls.is_supported()
except Exception as exception:
plugin_exception = tuned.plugins.exception.LoadPluginException(plugin_name, exception)
raise plugin_exception
def delete(self, plugin):
assert isinstance(plugin, self._loader.interface)
log.debug("removing plugin %s" % plugin)

View file

@ -134,6 +134,12 @@ class Profile(object):
def _store_plugin_config(self, name, plugin_cfg):
plugin = plugin_cfg["type"]
# Check if the plugin is supported on this HW
if not tuned.plugins.get_repository().is_supported(plugin):
log.info("Plugin %s is not supported on this HW" % (plugin))
return
# If there are no devices set, set all tunable_devices as default
if not plugin_cfg.has_key("devices"):
try: