haproxy配置增删改查

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了haproxy配置增删改查相关的知识,希望对你有一定的参考价值。


shutil
json


():
   quit_flag = quit_flag:
       item_list()
       choice = ().strip()
       choice == :
           backend_info = ().strip()
           result = fetch(backend_info)
           (result)
       choice == :
           back_up()
           backend_record_dict = input_json()  key backend_record_dict:
               backend = key
               record = backend_record_dict[key]
           delete(backendrecord)
       choice == :
           back_up()
           backend_record_dict = input_json()  key backend_record_dict:
               backend = key
               record = backend_record_dict[key]
           add(backendrecord)
       choice == :
           back_up()
           backend_record_dict = input_json()  key backend_record_dict:
               backend = key
               record = backend_record_dict[key]
           modify(backendrecord)
       choice == choice == :
           quit_flag = ()
       :
           ()


():
    lis = []
    (lis)


():
    shutil.copyfile()


():
    flag = fetch_list = []
    (=) f:
        line f:
            line.strip() == %():
                flag = line.strip().startswith():  flag = flag line.strip():
                fetch_list.append(line.strip())
    fetch_list


():
    flag = fetch_list = []
    (=) f:
        line f:
            line.strip() == %():
                fetch_list.append()
                flag = line.strip().startswith():  flag = flag line.strip():
                fetch_list.append(line.strip())
    fetch_list


():
    (=) old(=) new:
        flag = line old:
            line.strip().startswith() line.strip() == % :
                flag = new.write(line)
                new_line :
                    new.write(* + new_line + )
                flag line.strip().startswith():  flag = new.write(line)
                line.strip() flag:
                new.write(line)


():
    (=) old(=) new:
        flag = line old:
            line.strip().startswith() line.strip() == % :
                flag = new_line :
                    new.write(* + new_line + )
                    new.flush()
                flag line.strip().startswith():  flag = new.write(line)
                new.flush()
                line.strip() flag:
                new.write(line)
                new.flush()


():
    (=) old(=) new:
        flag = line old:
            line.strip().startswith() line.strip() == % :
                flag = flag line.strip().startswith():  flag = new.write(line)
                new.flush()
                line.strip() flag:
                new.write(line)
                new.flush()


():
    change_flag
    record_list = fetch()  record_list:  (=) old(=) new:
            line old:
                new.write(line)
            new.write(+ + )
            new.write(* + + )
        ()
        change_flag = :  record_list:
            ()
            change_flag = :  record_list.append()
            writer(record_list)
            ()
            change_flag = change_flag :  shutil.move()


():
    change_flag
    record_list = fetch1()  (record_list)
    record_list:  (.center())
        change_flag = :  record_list:
            record_list.remove()  writer1(record_list)  ()
            change_flag = :  writer2()
            ()
            change_flag = change_flag :  shutil.move()
    change_flag


():
    change_flag
    record_list = fetch1()  record_list:  (=) old(=) new:
            line old:
                new.write(line)
            new.write(+ + )
            new.write(* + + )
        change_flag = change_flag :  shutil.move()
    :  delete()
        add()
    change_flag


():
    continue_flag = continue_flag :
        backend_record = ().strip()
        :
            backend_record_dict = json.loads(backend_record)
        :
            ()
            continue_flag = backend_record_dict

__name__ == :
    main()


以上是关于haproxy配置增删改查的主要内容,如果未能解决你的问题,请参考以下文章

haproxy配置增删改查

对haproxy文件进行增删改查

作业:老板现在给你任务,公司有haproxy配置文件,希望通过python程序可以对ha配置文件进行增删改

python之haproxy配置文件操作(第三天)

Day5.对文件的增删改查+三次登陆后锁定

使用python更新haproxy配置文件