- Timestamp:
- Jun 13, 2015, 6:30:54 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r13264 r13274 1672 1672 'wzoeterwoude' : 'Stichting Wireless Leiden - Afdeling Zoeterwoude - Free-WiFi Project', 1673 1673 'walphen' : 'Stichting Wireless Alphen', 1674 'westeinder' : 'West Einder Plassen',1674 'westeinder' : 'Westeinder Plassen', 1675 1675 } 1676 1677 # Convert IP to Host 1678 ip2host = {'root' : 'root'} 1679 for host in get_hostlist(): 1680 datadump = get_yaml(host) 1681 ip2host[datadump['masterip']] = datadump['autogen_fqdn'] 1682 for iface in datadump['autogen_iface_keys']: 1683 ip2host[datadump[iface]['autogen_gateway']] = datadump['autogen_fqdn'] 1684 1685 # Find dependency tree based on output of lvrouted.mytree of nearest node 1686 parent = defaultdict(list) 1687 stack = ['root'] 1688 prev_depth = 0 1689 for line in open('lvrouted.mytree').readlines(): 1690 depth = line.count('\t') 1691 ip = line.strip().split()[0] 1692 1693 if prev_depth < depth: 1694 print ip2host[stack[-1]], " -> ", ip2host[ip] 1695 parent[ip2host[ip]].append(ip2host[stack[-1]]) 1696 stack.append(ip) 1697 elif prev_depth > depth: 1698 stack = stack[:(depth - prev_depth)] 1699 1700 prev_depth = depth 1701 # Observe that some nodes has themself as parent or multiple parents 1702 # for now take only the first parent, other behaviour is yet to be explained 1703 1704 1676 1705 1677 1706 params = { … … 1835 1864 host_name %(autogen_fqdn)s 1836 1865 address %(masterip)s 1837 hostgroups srv_hybrid,%(monitoring_group)s 1866 hostgroups srv_hybrid,%(monitoring_group)s\ 1867 ''' % datadump 1868 if len(parent[datadump['autogen_fqdn']]) > 0: 1869 print '''\ 1870 parent %(parent)s\ 1871 ''' % { 'parent' : parent[datadump['autogen_fqdn']][0] } 1872 print '''\ 1838 1873 } 1839 ''' % datadump 1874 ''' 1875 1840 1876 1841 1877 for name,alias in hostgroup_details.iteritems():
Note:
See TracChangeset
for help on using the changeset viewer.