Changeset 8340 in genesis
- Timestamp:
- Aug 13, 2010, 5:38:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/get-network-status.py
r8333 r8340 19 19 # When force is used as argument, use this range 20 20 DEFAULT_SCAN_RANGE= ['172.16.0.0/21'] 21 22 # Default node status output 23 nodemap_status_file = '/tmp/nodemap_status.yaml' 21 24 22 25 # … … 254 257 255 258 # Data store format used for nodemap generation 256 nodemap_status_file = '/tmp/nodemap_status.yaml'257 259 nodemap = { 'node' : {}, 'link' : {}} 258 260 … … 305 307 print "# Wrote nodemap status to '%s'" % nodemap_status_file 306 308 309 310 def do_merge(files): 311 """ Merge all external statuses in our own nodestatus, using optimistic approch """ 312 stream = file(nodemap_status_file,'r') 313 status = yaml.load(stream) 314 for cfile in files: 315 try: 316 print "# Merging '%s'" % cfile 317 stream = file(cfile,'r') 318 new_status = yaml.load(stream) 319 for item in ['node', 'link']: 320 for key, value in status[item].iteritems(): 321 if not status[item].has_key(key): 322 # New items always welcome 323 status[item][key] = value 324 print "## [%s][%] is new (%s)" % (item, key, value) 325 elif value < status[item][key]: 326 # Better values always welcome 327 status[item][key] = value 328 print "## [%s][%] is better (%s)" % (item, key, value) 329 except IOError, e: 330 print "## ERROR '%s'" % e 331 332 # Save results back to file 333 stream = file(nodemap_status_file,'w') 334 yaml.dump(status, stream, default_flow_style=False) 335 307 336 def usage(): 308 337 print "Usage: %s <arguments>" … … 355 384 opt_nmap_scan = False 356 385 opt_store_scan = False 386 elif sys.argv[1] == "merge": 387 do_merge(sys.argv[2:]) 388 sys.exit(0) 357 389 else: 358 390 usage()
Note:
See TracChangeset
for help on using the changeset viewer.