Last change
on this file since 10729 was 10376, checked in by rick, 13 years ago |
IP cannot be shared between normal and hybrid proxy.
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Id
|
File size:
1.3 KB
|
Rev | Line | |
---|
[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>
|
---|
| 6 | import gformat
|
---|
| 7 | import sys
|
---|
| 8 |
|
---|
| 9 | __version__ = '$Id: syntax-checker.py 10376 2012-04-07 11:46:13Z rick $'
|
---|
| 10 |
|
---|
| 11 | allowed_multi_use = ['0.0.0.0', '192.168.1.100']
|
---|
| 12 |
|
---|
| 13 | def check_double_ip():
|
---|
| 14 | pool = {}
|
---|
| 15 | try:
|
---|
[10376] | 16 | for host in gformat.get_hostlist():
|
---|
[8268] | 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 |
|
---|
| 51 | if __name__ == "__main__":
|
---|
| 52 | sys.exit(check_double_ip())
|
---|
| 53 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.