Esempio n. 1
0
def getIntialNodes(username,password,host,slice,key,cmd_args):
    nodes={}
    filename=''
    if len(cmd_args) > 1:
        filename=cmd_args[1]+'_nodes.pck'
        nodes=readNodes(filename)
    else:
        filename=get_install_path()+'/nodes.pck'
        if os.path.isfile(filename):
            nodes=readNodes(filename)
        else:
            try:
                myops_nodes=MyOps().getAvailableNodes()
                #print 'getting monitor data'
                monitor_nodes=Monitor(username,password,host,slice,key,myops_nodes.keys()).getHealthyNodes()
                print 'merging nodes'
                nodes=dict(myops_nodes.items()+monitor_nodes.items())
            except Exception as e: 
                traceback.print_exc()
                print(e)
                print 'FATAL EEROR: failed to get myops or monitor information: nodes=MyOps().getAvailableNodes(). bye.'
                sys.exit(-1)
    return nodes,filename
Esempio n. 2
0
       



      

if __name__ == '__main__':
    if not online():
        log('offline')
        sys.exit(-1)
    log('run get_rtt... ')
    config=ConfigObj(PLE_CONF_FILE)
    nodes,filename=getIntialNodes(config['username'],config['password'],config['host'],config['slice'],config['key'],sys.argv) 
    alive_nodes={}  
    try:
        myops_nodes=MyOps().getAvailableNodes()
        monitor_nodes=Monitor(config['username'],config['password'],config['host'],config['slice'],config['key'],myops_nodes.keys()).getHealthyNodes()
        alive_nodes=dict(myops_nodes.items()+monitor_nodes.items())
    except:
        print 'failed to get myops information: myops_nodes=MyOps().getAvailableNodes()'
    bad_nodes=[]
    #checking existing nodes, and excluding bad nodes
    checkNodes(nodes, alive_nodes, bad_nodes)
    #checking remaining potential new nodes
    checkNodes(nodes, {}, [], alive_nodes)
    #clean up bad nodes
    for hostname in bad_nodes:
        del nodes[hostname]
    saveNodes(nodes, filename)
    db=Mongo()
    db.save_raw_nodes(nodes)