From 1ef447fad39d4bc549b11245ff0589d3ad787a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Thu, 29 Nov 2012 17:57:03 +0100 Subject: [PATCH] manager: devices matching: reverted the previous fix, added comma support Now it matches: sd*,cciss*, dm-* vd* So comma or whitespace can be used as delimiters. Also the following works: !sd*,!cciss*, !dm-* !vd* It matches anything but the above list, e.g. the 'vg1' will match, but 'vd1' not. --- tuned/units/device_matcher.py | 3 ++- tuned/units/manager.py | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tuned/units/device_matcher.py b/tuned/units/device_matcher.py index bc42718..03f3468 100644 --- a/tuned/units/device_matcher.py +++ b/tuned/units/device_matcher.py @@ -1,4 +1,5 @@ import fnmatch +import re class DeviceMatcher(object): """ @@ -16,7 +17,7 @@ class DeviceMatcher(object): which matches all devices is added. The device matches if and only if it matches some positive rule, but no negative rule. """ - rules = rules_str.split() + rules = re.split(r"\s|,\s*", rules_str) positive_rules = filter(lambda rule: not rule.startswith("!"), rules) negative_rules = [rule[1:] for rule in rules if rule not in positive_rules] diff --git a/tuned/units/manager.py b/tuned/units/manager.py index bf22c23..78fe390 100644 --- a/tuned/units/manager.py +++ b/tuned/units/manager.py @@ -70,9 +70,7 @@ class Manager(object): log.info("skipping unit '%s', all devices are already claimed by another unit" % unit_info.name) return None - devices = [] - for dev in unit_info.devices.split(","): - devices += self._device_matcher.match_list(str(dev).strip(), available_devices) + devices = self._device_matcher.match_list(unit_info.devices, available_devices) if not devices: log.info("skipping unit '%s', no matching devices available" % unit_info.name) return None