Update an irule remotely?

Hi there,

I’m trying to automate the procedure of updating an irule. We have a single iRule that does a bunch of redirects based on URI and this list changes periodically. Is there a will to update an iRule remotely? I see that iControl can query, add and delete but I don’t see where it can update…

Thanks much,

Chris

yes, you can make an update via iControl. In fact, the iRule editor uses icontrol (SOAP interface) to make these changes, but you can use the REST interface as well by issuing a PUT. Here’s a REST example I wrote in python a while back:

import requests, json

def modify_rule(bigip, name, code):
    payload = {}
    payload['apiAnonymous'] = code
    bigip.put('%s/ltm/rule/%s' % (b_url_base, name), data=json.dumps(payload))
    print 'Modifying rule...'

mycode = 'proc sequence {from to} {\n\tfor {set lst {}} {$from <=$to} {incr from} {\n\t\tlappend lst $from\n\t}\n\treturn $lst\n}'

b = requests.session()
b.auth = ('admin', 'admin')
b.verify = False
b.headers.update({'Content-Type' : 'application/json'})
b_url_base = 'https://172.16.44.15/mgmt/tm'

modify_rule(b, 'ruleProcLib', mycode)