kylinsoong / f5-tmsh-generator

Apache License 2.0
0 stars 0 forks source link

create 1800 timeout source_addr persistent #28

Closed kylinsoong closed 5 months ago

kylinsoong commented 5 months ago

Current source_addr persistent timeout are hard code 300s

def generator_tmsh_persist(persistname, protocol, dict, rollback_tmsh_list):
    results = is_persist_exist(persistname, dict)
    if results == False and protocol == "tcp":
        tmsh_persist_create = tmsh.get('tmsh', 'create.ltm.persist').replace("${replace.persist.type}", "source-addr").replace("${replace.persist.name}", persistname).replace("${replace.perist.timeout}", "300")

Change if persistent name contains 1800 then set 1800 as timeout.

kylinsoong commented 5 months ago
 % ./f5-tmsh-generator.py config/bigip-v13-new.running-config config/app/request-perist-sourceip_1800s.txt
---- 一号机网络配置 ----
---- 二号机网络配置 ----
----  业务变更配置  ----
tmsh create ltm pool CeShiYingYong_192.168.20.100_80_pool members add {  192.168.10.21:8080 192.168.10.22:8080 192.168.10.23:8080 192.168.10.24:8080 } monitor tcp
tmsh create ltm snatpool CeShiYingYong_192.168.20.100_80_snat members add {  192.168.20.101 192.168.20.102 }
tmsh create ltm persistence source-addr sourceip_1800s timeout 1800
tmsh create ltm virtual CeShiYingYong_192.168.20.100_80_vs destination 192.168.20.100:80 pool CeShiYingYong_192.168.20.100_80_pool ip-protocol tcp profiles add { fastL4 { } } source-address-translation { type snat pool CeShiYingYong_192.168.20.100_80_snat } persist replace-all-with { sourceip_1800s }
tmsh save sys config
----  变更回退配置  ----
tmsh delete ltm virtual CeShiYingYong_192.168.20.100_80_vs
tmsh delete ltm persistence source-addr sourceip_1800s
tmsh delete ltm snatpool CeShiYingYong_192.168.20.100_80_snat
tmsh delete ltm pool CeShiYingYong_192.168.20.100_80_pool
tmsh save sys config
% ./f5-tmsh-generator.py config/bigip-v13-new.running-config config/app/request-perist-sourceip_300s.txt 
---- 一号机网络配置 ----
---- 二号机网络配置 ----
----  业务变更配置  ----
tmsh create ltm pool CeShiYingYong_192.168.20.100_80_pool members add {  192.168.10.21:8080 192.168.10.22:8080 192.168.10.23:8080 192.168.10.24:8080 } monitor tcp
tmsh create ltm snatpool CeShiYingYong_192.168.20.100_80_snat members add {  192.168.20.101 192.168.20.102 }
tmsh create ltm persistence source-addr sourceip_300s timeout 300
tmsh create ltm virtual CeShiYingYong_192.168.20.100_80_vs destination 192.168.20.100:80 pool CeShiYingYong_192.168.20.100_80_pool ip-protocol tcp profiles add { fastL4 { } } source-address-translation { type snat pool CeShiYingYong_192.168.20.100_80_snat } persist replace-all-with { sourceip_300s }
tmsh save sys config
----  变更回退配置  ----
tmsh delete ltm virtual CeShiYingYong_192.168.20.100_80_vs
tmsh delete ltm persistence source-addr sourceip_300s
tmsh delete ltm snatpool CeShiYingYong_192.168.20.100_80_snat
tmsh delete ltm pool CeShiYingYong_192.168.20.100_80_pool
tmsh save sys config
% ./f5-tmsh-generator.py config/bigip-v13-new.running-config config/app/request-perist-cookie_300s.txt  
---- 一号机网络配置 ----
---- 二号机网络配置 ----
----  业务变更配置  ----
tmsh create ltm pool CeShiYingYong_192.168.20.100_80_pool members add {  192.168.10.21:8080 192.168.10.22:8080 192.168.10.23:8080 192.168.10.24:8080 } monitor tcp
tmsh create ltm snatpool CeShiYingYong_192.168.20.100_80_snat members add {  192.168.20.101 192.168.20.102 }
tmsh create ltm persistence cookie cookie_300s
tmsh create ltm virtual CeShiYingYong_192.168.20.100_80_vs destination 192.168.20.100:80 pool CeShiYingYong_192.168.20.100_80_pool ip-protocol tcp profiles add { http { } } service-down-immediate-action reset source-address-translation { type snat pool CeShiYingYong_192.168.20.100_80_snat } persist replace-all-with { cookie_300s }
tmsh save sys config
----  变更回退配置  ----
tmsh delete ltm virtual CeShiYingYong_192.168.20.100_80_vs
tmsh delete ltm persistence cookie cookie_300s
tmsh delete ltm snatpool CeShiYingYong_192.168.20.100_80_snat
tmsh delete ltm pool CeShiYingYong_192.168.20.100_80_pool
tmsh save sys config
% ./f5-tmsh-generator.py config/bigip-v13-new.running-config config/app/request-perist-cookie_1800s.txt
---- 一号机网络配置 ----
---- 二号机网络配置 ----
----  业务变更配置  ----
tmsh create ltm pool CeShiYingYong_192.168.20.100_80_pool members add {  192.168.10.21:8080 192.168.10.22:8080 192.168.10.23:8080 192.168.10.24:8080 } monitor tcp
tmsh create ltm snatpool CeShiYingYong_192.168.20.100_80_snat members add {  192.168.20.101 192.168.20.102 }
tmsh create ltm persistence cookie cookie_1800s
tmsh create ltm virtual CeShiYingYong_192.168.20.100_80_vs destination 192.168.20.100:80 pool CeShiYingYong_192.168.20.100_80_pool ip-protocol tcp profiles add { http { } } service-down-immediate-action reset source-address-translation { type snat pool CeShiYingYong_192.168.20.100_80_snat } persist replace-all-with { cookie_1800s }
tmsh save sys config
----  变更回退配置  ----
tmsh delete ltm virtual CeShiYingYong_192.168.20.100_80_vs
tmsh delete ltm persistence cookie cookie_1800s
tmsh delete ltm snatpool CeShiYingYong_192.168.20.100_80_snat
tmsh delete ltm pool CeShiYingYong_192.168.20.100_80_pool
tmsh save sys config
% ./f5-tmsh-generator.py config/bigip-v13-new.running-config config/app/request-perist-none.txt 
---- 一号机网络配置 ----
---- 二号机网络配置 ----
----  业务变更配置  ----
tmsh create ltm pool CeShiYingYong_192.168.20.100_80_pool members add {  192.168.10.21:8080 192.168.10.22:8080 192.168.10.23:8080 192.168.10.24:8080 } monitor tcp
tmsh create ltm snatpool CeShiYingYong_192.168.20.100_80_snat members add {  192.168.20.101 192.168.20.102 }
tmsh create ltm virtual CeShiYingYong_192.168.20.100_80_vs destination 192.168.20.100:80 pool CeShiYingYong_192.168.20.100_80_pool ip-protocol tcp profiles add { fastL4 { } } source-address-translation { type snat pool CeShiYingYong_192.168.20.100_80_snat } persist none
tmsh save sys config
----  变更回退配置  ----
tmsh delete ltm virtual CeShiYingYong_192.168.20.100_80_vs
tmsh delete ltm snatpool CeShiYingYong_192.168.20.100_80_snat
tmsh delete ltm pool CeShiYingYong_192.168.20.100_80_pool
tmsh save sys config
kylinsoong commented 5 months ago

#62468ceaa282dd686cd2184b5135fcfdda19dd5f