- Timestamp:
- Mar 22, 2012, 11:04:29 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r10264 r10270 73 73 DOWN = 20 74 74 UNKNOWN = 90 75 76 77 def make_graph(): 78 """ Process _ALL_ yaml files to get connection relations """ 79 errors = "" 80 poel = {} 81 for host in get_hostlist(): 82 try: 83 datadump = get_yaml(host) 84 for iface_key in datadump['autogen_iface_keys']: 85 l = datadump[iface_key]['ip'] 86 addr, mask = l.split('/') 87 88 # Not parsing of these folks please 89 if not valid_addr(addr): 90 continue 91 92 addr = parseaddr(addr) 93 mask = int(mask) 94 addr = addr & ~((1 << (32 - mask)) - 1) 95 if poel.has_key(addr): 96 poel[addr] += [host] 97 else: 98 poel[addr] = [host] 99 except (KeyError, ValueError), e: 100 errors += "[FOUT] in '%s' interface '%s'" % (host,iface_key) 101 errors += e 102 continue 103 return (poel, errors) 75 104 76 105 … … 192 221 return "\n".join(files) 193 222 223 def generate_node_overview(host): 224 """ Print overview of all files available for node """ 225 datadump = get_yaml(host) 226 params = { 'host' : host } 227 output = "<em><a href='..'>Back to overview</a></em><hr />" 228 output += "<h2>Available files:</h2><ul>" 229 for cf in files: 230 params['cf'] = cf 231 output += '<li><a href="%(host)s/%(cf)s">%(cf)s</a></li>\n' % params 232 output += "</ul>" 233 234 # Generate and connection listing 235 output += "<h2>Connected To:</h2><ul>" 236 (poel, errors) = make_graph() 237 for addr, hosts in poel.iteritems(): 238 if host in hosts and len(hosts) > 1: 239 for remote in [x for x in hosts if x != host]: 240 params = { 'remote': remote} 241 output += '<li><a href="%(remote)s">%(remote)s</a></li>\n' % params 242 output += "</ul>" 243 244 output += "<hr /><em><a href='..'>Back to overview</a></em>" 245 return output 194 246 195 247 … … 656 708 657 709 658 uri = os.environ['PATH_INFO'].strip('/').split('/') 710 base_uri = os.environ['PATH_INFO'] 711 uri = base_uri.strip('/').split('/') 712 659 713 output = "" 660 714 if not uri[0]: … … 666 720 output += generate_title(get_hostlist()) 667 721 elif len(uri) == 1: 668 output += "Content-type:text/plain\r\n\r\n" 669 output += generate_node(uri[0]) 722 if is_text_request(): 723 output += "Content-type:text/plain\r\n\r\n" 724 output += generate_node(uri[0]) 725 else: 726 output += "Content-type:text/html\r\n\r\n" 727 output += generate_node_overview(uri[0]) 670 728 elif len(uri) == 2: 671 729 output += "Content-type:text/plain\r\n\r\n" … … 868 926 \ttest CNodeRick dnsmasq.conf = Receive output of CGI script 869 927 \t for arguments CNodeRick/dnsmasq.conf 870 \tlist < nodes|proxies>= List systems which marked up.928 \tlist <all|nodes|proxies> = List systems which marked up. 871 929 """ 872 930 exit(0) … … 1012 1070 elif sys.argv[2] == "proxies": 1013 1071 systems = get_proxylist() 1072 elif sys.argv[2] == "all": 1073 systems = get_hostlist() 1014 1074 else: 1015 1075 usage()
Note:
See TracChangeset
for help on using the changeset viewer.