Beispiel #1
0
        agent_version_collection = db.sys_version
    except Exception, e:
        print traceback.format_exc()
        sys.exit(1)

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print('Usage: address, env')
        sys.exit()
    
    address = sys.argv[1]
    env = sys.argv[2]
    
    agent_md5 = {}
    
    init_mongodb()
    
    agent_md5 = md5_lib.get_md5(agent_file)
    agent_md5.update(md5_lib.get_resource(lib_path))
    agent_md5.update(md5_lib.get_resource(resource_path))
    
    result = agent_version_collection.find_one({'address':address,'env':env})

    if not result:
        result = {'address':address,'env':env}

    result['agent_md5'] = agent_md5
    result['time'] = datetime.now()
    
    agent_version_collection.update({'address':address,'env':env}, result, upsert=True)