Changeset 13276 in genesis


Ignore:
Timestamp:
Jun 13, 2015, 7:30:13 PM (7 years ago)
Author:
rick
Message:
  • Same depth nodes should also be travered
  • Deal with unknown IP address in the network
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r13274 r13276  
    5656from pprint import pprint
    5757from collections import defaultdict
     58from sys import stderr
    5859try:
    5960  import yaml
     
    16841685
    16851686      # Find dependency tree based on output of lvrouted.mytree of nearest node
    1686       parent = defaultdict(list)
     1687      parents = defaultdict(list)
    16871688      stack = ['root']
    16881689      prev_depth = 0
     
    16921693     
    16931694        if prev_depth < depth:
    1694           print ip2host[stack[-1]], " -> ", ip2host[ip]
    1695           parent[ip2host[ip]].append(ip2host[stack[-1]])
     1695          try:
     1696            parents[ip2host[ip]].append(ip2host[stack[-1]])
     1697          except KeyError as e:
     1698            print >> stderr, "# Unable to find %s in configuration files" % e.args[0]
    16961699          stack.append(ip)
    16971700        elif prev_depth > depth:
    16981701          stack = stack[:(depth - prev_depth)]
     1702        elif prev_depth == depth:
     1703          try:
     1704            parents[ip2host[ip]].append(ip2host[stack[-1]])
     1705          except KeyError as e:
     1706            print >> stderr, "# Unable to find %s in configuration files" % e.args[0]
     1707
    16991708
    17001709        prev_depth = depth
     
    18661875        hostgroups            srv_hybrid,%(monitoring_group)s\
    18671876''' % datadump
    1868         if len(parent[datadump['autogen_fqdn']]) > 0:
     1877        if len(parents[datadump['autogen_fqdn']]) > 0:
    18691878          print '''\
    1870         parent                %(parent)s\
    1871 ''' % { 'parent' : parent[datadump['autogen_fqdn']][0] }
     1879        parents               %(parents)s\
     1880''' % { 'parents' : parents[datadump['autogen_fqdn']][0] }
    18721881        print '''\
    18731882}
Note: See TracChangeset for help on using the changeset viewer.