Python + bigsuds: What format to create iRule
I am not able to find an example of this anywhere and I am having a lot of trouble creating an iRule with bigsuds + python. I cannot figure out how to deliver the data to the Rule.create method. I am trying to pull the iRules from one F5 and import them into another. I get various errors when I try to pass the rule_name and rule_definition to the create rule method. I've tried all kinds of brackets and quotes and spaces... Any help would be appreciated. I've
!/usr/bin/env python
import sys
import bigsuds
import ssl
import getpass
'''SSL CERT FIX'''
'''------------'''
ssl._create_default_https_context = ssl._create_unverified_context
def get_rules_list(obj):
try:
return obj.LocalLB.Rule.get_list()
except Exception, e:
print e
def get_rule(obj, rule):
try:
return obj.LocalLB.Rule.query_rule([rule])
except Exception, e:
print e
def create_rule(obj):
try:
return obj.LocalLB.Rule.create(obj,rule, rule_txt)
except Exception, e:
print e
try:
b = bigsuds.BIGIP(
hostname = "192.168.1.2",
username = "admin",
password = "admin",
)
except Exception, e:
print e
try: c = bigsuds.BIGIP( hostname = "192.168.1.1", username = "admin", password = "admin", ) except Exception, e: print e
irules = get_rules_list(b) print irules for rule in irules: rule_txt = get_rule(b, rule) create_rule(c, rule, rule_txt)