Changeset 12574 in genesis


Ignore:
Timestamp:
Dec 17, 2013, 8:12:22 PM (11 years ago)
Author:
rick
Message:

Neem ook masterip mee in de checks.

Fixes beheer:ticket:411

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/syntax-checker.py

    r12291 r12574  
    77import sys
    88
     9from collections import defaultdict
     10
    911__version__ = '$Id$'
    1012
     
    1214
    1315def check_double_ip():
    14   pool = {}
     16  pool = defaultdict(list)
    1517  try:
    1618    for host in gformat.get_hostlist():
    17       print "## Processing host %-20s: " % host,
     19      print "## Processing host %-25s: " % host,
    1820      datadump = gformat.get_yaml(host,add_version_info=False)
    1921      try:
     22        # Process interfaces
    2023        iface_keys = [elem for elem in datadump.keys() if (elem.startswith('iface_') and not "lo0" in elem)]
    2124        for iface_key in iface_keys:
     
    2326          addr, mask = l.split('/')
    2427
    25           label = "%s - %s" % (host, iface_key)
    26           if pool.has_key(addr):
    27             pool[addr] += [label]
    28           else:
    29             pool[addr] = [label]
     28          pool[addr].append((host, iface_key))
     29
     30        iface_key = 'masterip'
     31        addr = datadump['masterip']
     32        # Add masterip to the list if IP has not been defined at interface
     33        if not host in [x[0] for x in pool[addr]]:
     34          pool[addr].append((host, 'masterip'))
     35
    3036        print "OK"
    3137      except (KeyError, ValueError), e:
    32         print "[ERROR] in '%s' interface '%s' (%s)" % (host,iface_key, e)
     38        print "[ERROR] in '%s' interface '%s' (%s)" % (host, iface_key, e)
    3339        raise
    3440  except Exception as e:
     
    4147      if not any(map(lambda x: addr.startswith(x), allowed_multi_use)):
    4248        print "[ERROR] Multiple usages of IP %s:" % (addr)
    43         print "  -", "\n  - ".join(leden)
     49        for host, key in leden:
     50          print "  - %s - %s" % (host, key)
    4451        error = True
    4552
Note: See TracChangeset for help on using the changeset viewer.