{"id":945,"date":"2015-10-20T11:54:13","date_gmt":"2015-10-20T11:54:13","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2015\/10\/20\/f5-python-bigsuds-a-look-at-the-get-instance-method\/"},"modified":"2023-02-24T12:59:54","modified_gmt":"2023-02-24T12:59:54","slug":"f5-python-bigsuds-a-look-at-the-get-instance-method","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Loadbalancers\/F5-BIG-IP\/f5-python-bigsuds-a-look-at-the-get-instance-method.html","title":{"rendered":"F5 Interacting with iControl’s get_instance method via BigSuds"},"content":{"rendered":"
In order to interact with the F5 via Python the best option available is bigsuds. This is a Python module that allows you to interact with the F5 API iControl<\/a> via a set of Python classes.<\/p>\n 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. \u00a0This is were the get_instance<\/span><\/a> method comes into play. get_instance<\/span> allows you to return the configuration as a string.<\/p>\n 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.<\/p>\n First of all we import the bigsuds module and also build a connection to our F5.<\/p>\n 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.<\/p>\n Once we have our class we next to obtain the instances for the class.<\/p>\n Now that we have our instance. We can pass this to the F5 so that the configuration is returned.<\/p>\n In order to interact with the F5 via Python the best option available is bigsuds. This is a Python module that 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 … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"yoast_head":"\nImport\/Build Connection<\/h2>\n
>>> import bigsuds\r\n>>> import pprint\r\n>>> b = bigsuds.BIGIP(hostname = '10.1.1.10',username = \"admin\", password = \"#####\")<\/pre>\n
Classes<\/h2>\n
>>> pprint.pprint([x['name'] for x in b.Management.ChangeControl.get_class_info(filter=\"\")])\r\n['Local Traffic \/ Profiles \/ profile_mblb',\r\n'Local Traffic \/ Profiles \/ profile_ntlm',\r\n'System \/ dns',\r\n'System \/ httpd',\r\n'System \/ logrotate',\r\n'System \/ ntp',\r\n'System \/ password_policy',\r\n'System \/ sshd',\r\n'System \/ remote_users',\r\n'System \/ syslog',\r\n'System \/ ltm', \r\n....<\/pre>\n
Instances<\/h2>\n
>>> b.Management.ChangeControl.get_instance_info(classes=[{\"name\":\"System \/ failover\",\"transact\r\nion_id\":0}])\r\n[[{'name': 'System \/ failover \/ failover', 'transaction_id': 55485}]]<\/pre>\n
Get Config<\/h2>\n
>>> b.Management.ChangeControl.get_instance(instance_names=[\"System \/ failover \/ failover\"],ins\r\ntance_format=\"FORMAT_SHELL\")\r\n[{'info': {'name': 'System \/ failover \/ failover', 'transaction_id': 55485}, 'data': 'failover \r\n{\\n network failover enable\\n peer mgmt addr 8.8.8.8\\n redundant enable\\n standby link \r\ndown time 0\\n unit 2\\n unicast peer FAILOVER {\\n dest addr 8.8.8.8\\n port 1\r\n026\\n source addr 8.8.8.7\\n }\\n}', 'format': 'FORMAT_SHELL'}]<\/pre>\n