Changeset 13276 in genesis for tools/gformat.py
- Timestamp:
- Jun 13, 2015, 7:30:13 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r13274 r13276 56 56 from pprint import pprint 57 57 from collections import defaultdict 58 from sys import stderr 58 59 try: 59 60 import yaml … … 1684 1685 1685 1686 # Find dependency tree based on output of lvrouted.mytree of nearest node 1686 parent = defaultdict(list)1687 parents = defaultdict(list) 1687 1688 stack = ['root'] 1688 1689 prev_depth = 0 … … 1692 1693 1693 1694 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] 1696 1699 stack.append(ip) 1697 1700 elif prev_depth > depth: 1698 1701 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 1699 1708 1700 1709 prev_depth = depth … … 1866 1875 hostgroups srv_hybrid,%(monitoring_group)s\ 1867 1876 ''' % datadump 1868 if len(parent [datadump['autogen_fqdn']]) > 0:1877 if len(parents[datadump['autogen_fqdn']]) > 0: 1869 1878 print '''\ 1870 parent %(parent)s\1871 ''' % { 'parent ' : parent[datadump['autogen_fqdn']][0] }1879 parents %(parents)s\ 1880 ''' % { 'parents' : parents[datadump['autogen_fqdn']][0] } 1872 1881 print '''\ 1873 1882 }
Note:
See TracChangeset
for help on using the changeset viewer.