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.
This commit is contained in:
parent
074e7db59c
commit
1ef447fad3
2 changed files with 3 additions and 4 deletions
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue