cancel
Showing results for 
Search instead for 
Did you mean: 

Problem this snippet solves:

The goal of this script is to do a massive removal of a previously deployed iRule. It will search for iRule name applied on Virtual Server and will remove it.

Code :

# This python script is used to remove a specific iRule for ALL VS
#
import bigsuds
import sys
 
try:
b = bigsuds.BIGIP(
hostname = 'ip',
username = 'admin',
password = 'admin',
)
except Exception, e:
print e
               
#Change system partition
b.System.Session.set_active_folder("/mypartition")
 
virtualservers = b.LocalLB.VirtualServer.get_list()
rules = b.LocalLB.VirtualServer.get_rule(virtualservers)
rule_to_remove = '/mypartition/myiRulename'
irules_list = b.LocalLB.Rule.get_list()
found_rule = False


# check if iRule is present
for irule in irules_list:
if irule == rule_to_remove:
found_rule = True
break
               
if found_rule:
print "Found iRule with name: %s" % rule_to_remove
else:
print "iRule not Found"
sys.exit() 
 
count = 0
for vs in virtualservers:
print "\n\nVS: %s" % vs
for rule in rules[count]:
print "\tRules %i: %s" % (count, rule)
    count += 1
 
count = 0
for id_rule in rules:
for rule in id_rule:
  if rule["rule_name"] == rule_to_remove:
try:
b.LocalLB.VirtualServer.remove_rule([virtualservers[count]], [[rule]])
print "\nRemove rule: %s, from vs: %s" % (rule, [virtualservers[count]])
except Exception, e:
print e
        break
    count +=1
Version history
Last update:
‎09-Mar-2015 13:38
Updated by:
Contributors