Ejemplo n.º 1
0
def insertnewstg(cid, load_id):
    insert_load_sql = '''
        INSERT INTO `strategy` 
            (`server_id`, `server_ip`, `domain_key`, `resource_ids`, `owner_type`, `owner_value`, `for_test_msg`, `switch_type`, `switch_value`, `init_group_size`, `min_group_size`, `last_update_time`, `from_domains`, `remark`) 
        VALUES 
            ('%s', '%s', 'qqdomain', '%s', '%s', '%s', 0, 'ByGroup', 12, %s, 1, '2013-03-22 16:28:00', NULL, NULL);
    '''
    if int(cid) < 3000:
        owner_type = 'Branch'
    else:
        owner_type = 'Client'
    #load_array = load[load_id]
    load_array = getLoadInfo(load_id)
    #print load_array
    #print insert_load_sql % (load_list[0], load_list[1], load_list[2], owner_type, cid, load_list[3]) 
    for load_list in load_array:
        try:
            #print load_list
            resource_conn = mdb.get_resource_conn()
            load_list['server_ip'] = getServerIp(load_list['server_id'])
            #print insert_load_sql % (load_list['server_id'], load_list['server_ip'], load_list['rids'], owner_type, cid, load_list['count'])
            row_info = mdb.exe_update_sql(resource_conn, insert_load_sql % (load_list['server_id'], load_list['server_ip'], load_list['rids'], owner_type, cid, load_list['count']), False, True, False, False)
            print row_info
        except Exception,e:
            print e
            sys.exit()
Ejemplo n.º 2
0
        print "Done! delete old strategy on client_id: %s " % owner_value
        sys.exit()

    owner_type = args.owner_type
    for_test_msg = args.for_test_msg

    flag = selectstg(domainkey, owner_value)
    if(flag):
        deloldstg(domainkey, owner_value)
    
    if args.resource_ids:
        rids = args.resource_ids
        rinfos = getresource(rids)
        for rinfo in rinfos:
            server_id = rinfo['server_id']
            server_ip = getServerIp(rinfo['server_id'])
            resource_ids = rinfo['rids']
            init_group_size = rinfo['count']
            try:
                resource_conn = mdb.get_resource_conn()
                insertnewstg(server_id, server_ip, domainkey, resource_ids, owner_type, owner_value, for_test_msg, 
                            switch_type, switch_value, init_group_size, min_group_size)
                print "Done! Add a new strategy at client_id: %s on %s " % (owner_value, domainkey)
            except Exception,e:
                print e
                sys.exit()
    elif args.load_id:
        load_id = args.load_id
        load_array = getLoadInfo(load_id)
        for load_list in load_array:
            try: