Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/unit/plugins/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_get_matching_devices(self):
instance = self._plugin.create_instance(\
'first_instance',0,'right_device*',None,'test','test',\
{'default_option1':'default_value2'})
instance.plugin.init_devices()

self.assertEqual(self._plugin._get_matching_devices(\
instance,['bad_device','right_device1','right_device2']),\
Expand All @@ -77,6 +78,7 @@ def test_get_matching_devices(self):
instance = self._plugin.create_instance(\
'second_instance',0,'right_device*','device[1-2]','test','test',\
{'default_option1':'default_value2'})
instance.plugin.init_devices()

device1 = DummyDevice('device1',{'name':'device1'})
device2 = DummyDevice('device2',{'name':'device2'})
Expand Down Expand Up @@ -177,6 +179,10 @@ def _get_config_options(self):
def _instance_cleanup(self, instance):
self.cleaned_instances.append(instance)

def _init_devices(self):
super(DummyPlugin,self)._init_devices()
self._devices_supported = True

def _get_device_objects(self, devices):
objects = []
for device in devices:
Expand Down
8 changes: 0 additions & 8 deletions tuned/daemon/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,6 @@ def instance_create(self, plugin_name, instance_name, options, caller = None):
log.error(rets)
return (False, rets)
plugin = plugins[plugin_name]
if not isinstance(plugin, hotplug.Plugin):
rets = "Plugin '%s' does not support hotplugging or dynamic instances." % plugin.name
log.error(rets)
return (False, rets)
devices = options.pop("devices", None)
devices_udev_regex = options.pop("devices_udev_regex", None)
script_pre = options.pop("script_pre", None)
Expand Down Expand Up @@ -543,10 +539,6 @@ def instance_destroy(self, instance_name, caller = None):
log.error(rets)
return (False, rets)
plugin = instance.plugin
if not isinstance(plugin, hotplug.Plugin):
rets = "Plugin '%s' does not support hotplugging or dynamic instances." % plugin.name
log.error(rets)
return (False, rets)
devices = instance.processed_devices.copy()
try:
plugin._remove_devices_nocheck(instance, devices)
Expand Down
15 changes: 15 additions & 0 deletions tuned/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def _get_device_objects(self, devices):
return None

def _get_matching_devices(self, instance, devices):
if not self._devices_supported:
return set()

if instance.devices_udev_regex is None:
return set(self._device_matcher.match_list(instance.devices_expression, devices))
else:
Expand All @@ -164,6 +167,18 @@ def _get_matching_devices(self, instance, devices):
udev_devices = self._device_matcher_udev.match_list(instance.devices_udev_regex, udev_devices)
return set([x.sys_name for x in udev_devices])

def _add_device(self, device_name):
pass

def _add_devices_nocheck(self, instance, device_names):
pass

def _remove_device(self, device_name):
pass

def _remove_devices_nocheck(self, instance, device_names):
pass

def assign_free_devices(self, instance):
if not self._devices_supported:
return
Expand Down