source: genesis/tools/syntax-checker.py@ 8858

Last change on this file since 8858 was 8615, checked in by rick, 14 years ago

Bezempje door alle files. Rommel weg. Tooljes op de juiste locatie.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.3 KB
RevLine 
[8268]1#!/usr/bin/env python
2# vim:ts=2:et:sw=2:ai
3#
4# Build topological network graph
5# Rick van der Zwet <info@rickvanderzwet.nl>
6import gformat
7import sys
8
9__version__ = '$Id: syntax-checker.py 8615 2010-10-31 19:59:34Z rick $'
10
11allowed_multi_use = ['0.0.0.0', '192.168.1.100']
12
13def check_double_ip():
14 pool = {}
15 try:
16 for host in gformat.get_proxylist() + gformat.get_nodelist():
17 print "## Processing host %-20s: " % host,
18 datadump = gformat.get_yaml(host)
19 iface_keys = [elem for elem in datadump.keys() if (elem.startswith('iface_') and not "lo0" in elem)]
20 for iface_key in iface_keys:
21 l = datadump[iface_key]['ip']
22 addr, mask = l.split('/')
23
24 label = "%s - %s" % (host, iface_key)
25 if pool.has_key(addr):
26 pool[addr] += [label]
27 else:
28 pool[addr] = [label]
29 print "OK"
30 except (KeyError, ValueError), e:
31 print "[ERROR] in '%s' interface '%s'" % (host,iface_key)
32 print e
33 sys.exit(1)
34
35 error = False
36 for addr,leden in pool.iteritems():
37 if len(leden) > 1:
38 if not addr in allowed_multi_use:
39 print "[ERROR] Multiple usages of IP %s:" % (addr)
40 print " -", "\n - ".join(leden)
41 error = True
42
43 if error:
44 print "# Errors found"
45 return 1
46 else:
47 print "# No multiple usages of IPs found"
48 return 0
49
50
51if __name__ == "__main__":
52 sys.exit(check_double_ip())
53
Note: See TracBrowser for help on using the repository browser.