Python Bigsuds - Massive iRule removal
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
Published Mar 09, 2015
Version 1.0No CommentsBe the first to comment