Esempio n. 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)
Esempio n. 2
0
    f = open(gparser_cfg_path)

    for line in f:
        index = line.find('\t')
        if index > 0:
            ovs = line[0:index]
            ovss.append(ovs)
    
    print ovss
    
    for ovs in ovss:
        ovs_path = ovs[3:]
        path = '%s%s' %(resource_path, ovs_path)
        #print path
        
        file_md5 = md5_lib.get_md5(path)
        #print file_md5
        file_md5_ordered = OrderedDict(sorted(file_md5.items(), key=lambda t: t[0]))

        m = hashlib.md5()
        m.update('%s' %(file_md5_ordered))
        md5 = m.hexdigest()
        
        ovs_md5[ovs] = md5
    
    print ovs_md5
    
    result = ovs_version_collection.find_one({'address':address,'env':env})

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