Forum Discussion
stucky101_88485
Feb 27, 2013Nimbostratus
In case you want to see how I create the irule in the first place...
lines = [" This iRule redirects to the standard maintenance page with the highest priority.\n",
" Generated by pycontrol. Manual edits will be undone.\n",
"priority 1\n",
"when HTTP_REQUEST {\n",
" HTTP::redirect http://webassets.scea.com/generic_maintenance/sceait_generic/maintenance.html\n",
"}"]
maintenance_irule = ''.join(lines)
maintenance_irule_name = 'api_maintenance'
irule_definition = { 'rule_name': maintenance_irule_name,
'rule_definition': maintenance_irule }
If rule already exists refresh it, otherwise create it.
existing_rules = lb.LocalLB.Rule.get_list()
for rule in existing_rules:
if maintenance_irule_name in rule:
pre_exists = True
break
else:
pre_exists = False
if pre_exists is True:
try:
lb.LocalLB.Rule.modify_rule([irule_definition])
print "\nThe iRule '%s' already existed but got refreshed.\n" % maintenance_irule_name
except Exception, e:
print e
sys.exit()
else:
try:
lb.LocalLB.Rule.create([irule_definition])
print "\nThe iRule '%s' was successfully created.\n" % maintenance_irule_name
except Exception, e:
print e
sys.exit()