F5 - Interacting with iControl's get_instance method via BigSuds

In order to interact with the F5 via Python the best option available is bigsuds. This is a Python module allows you to interact with the F5 API iControl via a set of Python classes.

Typically you will normally find all the methods you need to interact with your F5 without issues. However, there are times that you may be unable to find the required method in order to obtain the information you require.  This is were the get_instance method comes into play. get_instance allows you to return the configuration as a string. 

Within this article we will provide the steps to obtain the network failover configuration as there is no direct method for obtaining this configuration via iControl in v10.2.4.

Import/Build Connection

First of all we import the bigsuds module and also build a connection to our F5.

>>> import bigsuds
>>> import pprint
>>> b = bigsuds.BIGIP(hostname = '',username = "admin", password = "#####")


We next perform a look up through our classes to confirm the class we are interested in. Add the nessacary strings to the filter key to filter the results.

>>> pprint.pprint([x['name'] for x in b.Management.ChangeControl.get_class_info(filter="")])
['Local Traffic / Profiles / profile_mblb',
'Local Traffic / Profiles / profile_ntlm',
'System / dns',
'System / httpd',
'System / logrotate',
'System / ntp',
'System / password_policy',
'System / sshd',
'System / remote_users',
'System / syslog',
'System / ltm', 


Once we have our class we next to obtain the instances for the class.

>>> b.Management.ChangeControl.get_instance_info(classes=[{"name":"System / failover","transaction_id":0}])
[[{'name': 'System / failover / failover', 'transaction_id': 55485}]]

Get Config

Now that we have our instance. We can pass this to the F5 so that the configuration is returned.

>>> b.Management.ChangeControl.get_instance(instance_names=["System / failover / failover"],instance_format="FORMAT_SHELL")
[{'info': {'name': 'System / failover / failover', 'transaction_id': 55485}, 'data': 'failover {\n   network failover enable\n   peer mgmt addr\n   redundant enable\n   standby link down time 0\n   unit 2\n   unicast peer FAILOVER {\n         dest addr\n         port 1026\n         source addr\n      }\n}', 'format': 'FORMAT_SHELL'}]

Tags: BIG-IP F5, iControl