Merge pull request #8 from SUNET/gijutsu-fix-db.py

Changed from re.search to re.match in db.py
This commit is contained in:
Fredrik Thulin 2019-02-13 15:48:58 +01:00 committed by GitHub
commit 0084a8864d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -17,7 +17,7 @@ def _load_db():
members = dict()
for node_name in all_hosts:
for reg,cls in rules.iteritems():
if re.search(reg,node_name):
if re.match(reg,node_name):
for cls_name in cls.keys():
h = members.get(cls_name,[])
h.append(node_name)
@ -28,10 +28,14 @@ def _load_db():
for node_name in all_hosts:
node_classes = dict()
for reg,cls in rules.iteritems():
if re.search(reg,node_name):
if re.match(reg,node_name):
node_classes.update(cls)
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)
_db = None

View file

@ -1,2 +1,3 @@
'ns[0-9]?.mnt.se$':
# Note that the matching is done with re.match()
'^ns[0-9]?.mnt.se$':
nameserver: