add script to generate bat-hosts
This commit is contained in:
		
							parent
							
								
									c0f229325c
								
							
						
					
					
						commit
						9ec7840e92
					
				
					 1 changed files with 13 additions and 0 deletions
				
			
		
							
								
								
									
										13
									
								
								bat-hosts-gen
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								bat-hosts-gen
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					#!/usr/bin/python
 | 
				
			||||||
 | 
					from __future__ import division, print_function
 | 
				
			||||||
 | 
					import requests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					r = requests.get('http://mapsrv0.ffka.net/json/ffka/nodes.json')
 | 
				
			||||||
 | 
					j = r.json()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for nodeid in j['nodes'].keys():
 | 
				
			||||||
 | 
					    nodeinfo = j['nodes'][nodeid]['nodeinfo']
 | 
				
			||||||
 | 
					    hostname = nodeinfo['hostname']
 | 
				
			||||||
 | 
					    for i, mac in enumerate(nodeinfo['network']['mesh_interfaces']):
 | 
				
			||||||
 | 
					        print('{} {}_int{}'.format(mac, hostname, i))
 | 
				
			||||||
		Reference in a new issue