Beispiel #1
0
    sys_scale = int(request.POST['scale'])
    noarea = int(request.POST['noarea'])
    
    bconf['scale'] = sys_scale
    bconf['num_of_areas'] = noarea

    mdb_host_id = -1
    mdb_host = None
    mdb_hosts = Host.objects.filter(name__exact=bconf['store_mongo_db']['host'])
    if len(mdb_hosts) == 0:
        mdb_host = Host(name=bconf['store_mongo_db']['host'],
                        ipaddr=bconf['store_mongo_db']['host'],
#                        if_worker = False,
#                        if_result_store = True
                        )
        mdb_host.save()
        mdb_host_id = mdb_host.id
    else:
        mdb_host = mdb_hosts[0]
        mdb_host_id = mdb_host.id
        
    mdb_id = 0
    mdb = None
    mdbs = ResultSourceMongodb.objects.filter(host_id__exact=mdb_host_id,
                                              port__exact=bconf['store_mongo_db']['port'])
    if len(mdbs) == 0:
        # add entry
        mdb = ResultSourceMongodb(host=mdb_host,
                                  port=bconf['store_mongo_db']['port'])
        mdb.save()
        mdb_id = mdb.id