Changed from re.search to re.match in db.py
because re.search would match on broken regex, nodes that have a part of the name in common with other nodes etc.
This commit is contained in:
parent
56c8355c17
commit
c591d6fe4b
|
@ -17,7 +17,7 @@ def _load_db():
|
||||||
members = dict()
|
members = dict()
|
||||||
for node_name in all_hosts:
|
for node_name in all_hosts:
|
||||||
for reg,cls in rules.iteritems():
|
for reg,cls in rules.iteritems():
|
||||||
if re.search(reg,node_name):
|
if re.match(reg,node_name):
|
||||||
for cls_name in cls.keys():
|
for cls_name in cls.keys():
|
||||||
h = members.get(cls_name,[])
|
h = members.get(cls_name,[])
|
||||||
h.append(node_name)
|
h.append(node_name)
|
||||||
|
@ -28,10 +28,14 @@ def _load_db():
|
||||||
for node_name in all_hosts:
|
for node_name in all_hosts:
|
||||||
node_classes = dict()
|
node_classes = dict()
|
||||||
for reg,cls in rules.iteritems():
|
for reg,cls in rules.iteritems():
|
||||||
if re.search(reg,node_name):
|
if re.match(reg,node_name):
|
||||||
node_classes.update(cls)
|
node_classes.update(cls)
|
||||||
classes[node_name] = node_classes
|
classes[node_name] = node_classes
|
||||||
|
|
||||||
|
# Sort member lists for a more easy to read diff
|
||||||
|
for cls in members.keys():
|
||||||
|
members[cls].sort()
|
||||||
|
|
||||||
return dict(classes=classes,members=members)
|
return dict(classes=classes,members=members)
|
||||||
|
|
||||||
_db = None
|
_db = None
|
||||||
|
|
Loading…
Reference in a new issue