Forum Discussion
satishs_370505
Nimbostratus
Aug 24, 2018IRule update for multiple VIP's
Hi,
what is the best way to update an irule for multiple VIP's ?
Thanks!
Stanislas_Piro2
Cumulonimbus
Aug 27, 2018I found this code on codeshare to remove irule for all virtual servers with TMSH::script...
I changed it to append the irule in the list of rules for selected virtual servers
modify script add_irule.tcl {
proc script::init {} {
}
proc script::run {} {
if { $tmsh::argc < 3 } {
puts "A single rule name must be provided"
exit
}
set rulename [lindex $tmsh::argv 1]
set rules ""
set vips [tmsh::get_config /ltm virtual [lrange $tmsh::argv 2 end]]
set vips_in_play ""
tmsh::begin_transaction
foreach vip $vips {
tmsh::get_field_value $vip "rules" rules
Rule keyword is present, but not $rulename rule
if { [lsearch -exact $rules $rulename] != -1 || [lsearch -exact $rules [lindex [split $rulename "/" ] 2]] != -1 } {
puts "The $rulename iRule was already assigned to the virtual server [tmsh::get_name $vip] "
continue
} else {
lappend rules $rulename
tmsh::modify /ltm virtual [tmsh::get_name $vip] rules "{ $rules }"
lappend vips_in_play $vip
}
}
tmsh::commit_transaction
puts "The $rulename iRule was added to the following virtuals: "
foreach x $vips_in_play {
puts "\t[tmsh::get_name $x]"
}
}
proc script::help {} {
}
proc script::tabc {} {
}
}
to use it, create in in tmsh with (this is a VI editor)
create cli script add_irule.tcl
Then run it with
run cli script add_irule.tcl irulename virtual_server1 virtual_server2 virtual_server3 virtual_server4 ...
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects