f5 python sdk
36 TopicsGetting module 'signal' has no attribute 'SIGALRM' error from f5-sdk on Windows
Hi, I am trying to use python sdk for F5 from here https://github.com/F5Networks/f5-common-python. I am on Windows. I am running Python 3 (tried python 3.3.5 and python 3.5.4). I am getting the following error when I run this (some information masked): from import ManagementRoot mgmt = ManagementRoot("...", "...", "...") File "...\lib\site-packages\f5\bigip__init__.py", line 150, in init self.post_configuration_setup() File "...\lib\site-packages\f5\bigip__init__.py", line 111, in post_configuration_setup self._get_tmos_version() File "...\lib\site-packages\f5\bigip__init__.py", line 117, in _get_tmos_version signal.signal(signal.SIGALRM, timeout_handler) AttributeError: module 'signal' has no attribute 'SIGALRM' Pip shows it installed version 3.0.8 of f5-sdk. How can I run this from python? Thanks.Solved3.5KViews0likes2Commentspython show running-config
I am trying to get a Python script to output the running config of my F5, to show everything from authentication to pools to ntp settings. With TMSH/SSH it's so easy doing 'show running-config' and then saving that output. Is there anything similar to this that I can do with the Python F5-SDK? I am trying to generate this in a cleaner fashion than 'show running-config' does it as I use this for PCI compliance evidence. Any help would be appreciated. To muddy the waters a bit I am EXTREMELY new to F5 products.Solved2.9KViews0likes10CommentsUpload programatically external data group file?
Hi everyone, I use external data group file contains more than 350K records. And now I would like to programmatically update (overwrite) the data group file for the automation process. I did some research and found something bigsuds library but the python version we used is not supported. Does someone have any idea about uploading external data group file using python? F5 version is 12.1.3.3 Python version is 3.7.0. Thanks in advance. -- Oguz1KViews0likes2CommentsSSL Cert expiration Tracker
Problem this snippet solves: Script is useful for large F5 LTM infrastructure. Instead of checking certs being expired on individual LTM, just list all your LB's in single file and script will check and create a report. How to use this snippet: This is made up of 3 parts: 1- hosts file (hosts.txt) 2- The Script 3- Report (bigip.data) Make sure you have Python 3 installed on your system. Install F5 SDK - i.e "pip install f5-sdk" and other modules such as dateutil, getpass, datetime etc. Create Text file "hosts.txt" and keep it in same directory as script. List all your LB's in "hosts.txt", each on new line. That's all! Run the script. If you face any issue let me know. Please provide any suggestions. Code : 92601961Views0likes3CommentsCPU, memory, disk usage and http profile using the BIG-IP Python SDK
I've been busy with the Python SDK for a couple of weeks now. While I managed to get a lot of information out of it, I'm struggling with a couple of API endpoints. Does anyone have an idea where I can find the statistics for CPU, Memory, Disk as well as the http profile? REST endpoints: mgmt/tm/sys/hostInfo (for CPU and memory) mgmt/tm/sys/disk/logical-disk (for disks) mgmt/tm/ltm/profile/http/stats (for http profile) Thanks! MikeSolved899Views0likes3CommentsUse F5 Python SDK to Create Node with Pool in Separate Partition
I have seen multiple samples on creating a pool and loading a member in that pool. I have looked at the "; for creating nodes but so far I am not getting the idea. Is there a way using Python Rest or Python SDK to create a node in the common partition with no pool? After the node is loaded I will then take that node and use it in a pool/s but the pool/s are in different partition.799Views0likes6CommentsHow do I retrieve the BIG-IP version using F5-SDK?
I am trying to figure out how to get the running version of a BIG-IP using the F5-sdk. I am able to get it by making a REST request: restcurl -u admin:admin '/mgmt/tm/sys/version?$select=Product,Version,Build,Edition' { "entries": { "https://localhost/mgmt/tm/sys/version/0": { "nestedStats": { "entries": { "Build": { "description": "2.234.1671" }, "Edition": { "description": "Engineering Hotfix HF2" }, "Product": { "description": "BIG-IP" }, "Version": { "description": "13.0.0" ... I cannot seem to find a way to do this with the SDK. >>> from f5.bigip import ManagementRoot >>> mgmt = ManagementRoot('10.97.243.52', 'admin', 'admin') >>> globalSettings = mgmt.tm.sys.global_settings.load() >>> print globalSettings.hostname host1.example.com >>> mgmt.tm.sys.version Traceback (most recent call last): File "", line 1, in File "/home/tech1/.local/lib/python2.7/site-packages/f5/bigip/mixins.py", line 102, in __getattr__ raise AttributeError(error_message) AttributeError: '' object has no attribute 'version' Can anyone point in the right direction?701Views0likes5CommentsSet a Virtual Server Type in F5 Python SDK
Can I set up a Virtual Server Type, among the existing, for example Standard, Performance (Layer 4), Performance (HTTP), or Forwarding IP? When I create a Virtual Server, by default it is created with the Performance (Layer 4) type. Thanks in advance.651Views0likes5CommentsDebugging API calls with the python sdk
In version 3.0.10 of the iControl REST python SDK, we introduced a new feature that allows you to debug the API call tracing. In this article, I’ll show you how to use it to debug an issue with pool members. Consider the following existing pool on my BIG-IP: ltm pool testpool { members { 192.168.103.20:http { address 192.168.103.20 session monitor-enabled state up } } monitor http } You can see that there is a single pool member in this pool, 192.168.103.20:80. So when I check from the SDK to see if the pool and pool member exist, I expect the answer to be true on both counts. >>> mgmt.tm.ltm.pools.pool.exists(name='testpool') True >>> pool = mgmt.tm.ltm.pools.pool.load(name='testpool') >>> pool.members_s.members.exists(name='192.168.103.20:80') False Both should be true, but the pool member exists check is returning false. This is where we can engage the debug data to see what is going on with the requests.You can set the debug attribute to true when you instantiate BIG-IP, or enable it only when you need it. >>> mgmt = ManagementRoot('ltm3.test.local', 'admin', 'admin', debug=True) # set on instantiation >>> mgmt.debug = True # turn on after instantiation >>> mgmt.debug = False # turn off Once you enable the debug attribute, the debug_output attribute will begin appending to a list the API calls made to the BIG-IP, in the format of the curl command. Note that the API is not using curl, but the debug output is formatted this way to allow you to grab the command and run it directly from the command line. For the instantiation, pool exists check, loading the pool, and then the pool member exists check, this debug output looks like this: >>> for x in mgmt.debug_output: ... print x ... curl -k -X GET https://ltm3.test.local:443/mgmt/tm/sys/ -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'User-Agent: python-requests/2.18.4 f5-icontrol-rest-python/1.3.8' -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW46YWRtaW4=' curl -k -X GET https://ltm3.test.local:443/mgmt/tm/ltm/pool/testpool -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'User-Agent: python-requests/2.18.4 f5-icontrol-rest-python/1.3.8' -H 'Content-Type: application/json' -H 'Cookie: BIGIPAuthUsernameCookie=admin; BIGIPAuthCookie=3CF752E8B6DC27B20D42B9C2BBF152B10B400407' -H 'Authorization: Basic YWRtaW46YWRtaW4=' curl -k -X GET https://ltm3.test.local:443/mgmt/tm/ltm/pool/testpool -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'User-Agent: python-requests/2.18.4 f5-icontrol-rest-python/1.3.8' -H 'Content-Type: application/json' -H 'Cookie: BIGIPAuthUsernameCookie=admin; BIGIPAuthCookie=3CF752E8B6DC27B20D42B9C2BBF152B10B400407' -H 'Authorization: Basic YWRtaW46YWRtaW4=' curl -k -X GET https://ltm3.test.local:443/mgmt/tm/ltm/pool/testpool/members/192.168.103.20:80 -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip, deflate' -H 'Accept: */*' -H 'User-Agent: python-requests/2.18.4 f5-icontrol-rest-python/1.3.8' -H 'Content-Type: application/json' -H 'Cookie: BIGIPAuthUsernameCookie=admin; BIGIPAuthCookie=3CF752E8B6DC27B20D42B9C2BBF152B10B400407' -H 'Authorization: Basic YWRtaW46YWRtaW4=' After running the pool member curl command I get this response: {"code":404,"message":"Object not found - 192.168.103.20:80","errorStack":[],"apiError":1} Now we know why the SDK returned false, but we know this pool member exists, so what gives? If we back off and just make an API call via curl to the members collection, we can investigate the response data for clues. {"kind":"tm:ltm:pool:members:memberscollectionstate","selfLink":"https://localhost/mgmt/tm/ltm/pool/testpool/members?ver=13.1.0.5","items":[{"kind":"tm:ltm:pool:members:membersstate","name":"192.168.103.20:80","partition":"Common","fullPath":"/Common/192.168.103.20:80","generation":175,"selfLink":"https://localhost/mgmt/tm/ltm/pool/testpool/members/~Common~192.168.103.20:80?ver=13.1.0.5","address":"192.168.103.20","connectionLimit":0,"dynamicRatio":1,"ephemeral":"false","fqdn":{"autopopulate":"disabled"},"inheritProfile":"enabled","logging":"disabled","monitor":"default","priorityGroup":0,"rateLimit":"disabled","ratio":1,"session":"monitor-enabled","state":"up"}]} Notice in the selfLink field there, the pool member has the partition as part of the name of the pool member. If we update our curl command to include the partition (changing 192.168.103.20:80 to ~Common~192.168.103.20:80,) let's see if that fixes our 404 error: {"kind":"tm:ltm:pool:members:membersstate","name":"192.168.103.20:80","partition":"Common","fullPath":"/Common/192.168.103.20:80","generation":175,"selfLink":"https://localhost/mgmt/tm/ltm/pool/testpool/members/~Common~192.168.103.20:80?ver=13.1.0.5","address":"192.168.103.20","connectionLimit":0,"dynamicRatio":1,"ephemeral":"false","fqdn":{"autopopulate":"disabled"},"inheritProfile":"enabled","logging":"disabled","monitor":"default","priorityGroup":0,"rateLimit":"disabled","ratio":1,"session":"monitor-enabled","state":"up"} Woot! Now we are getting the pool member data. It turns out that the pool member call requires the partition to be submitted, even if you do not use partitions on your BIG-IP. So now, if we update our python code to include the partition parameter, it should now return true, and sure enough, that is what we get: pool.members_s.members.exists(name='192.168.103.20:80', partition='Common') True The debug tracing details are documented in the SDK documentation linked at the top of this article, happy coding!625Views0likes1Comment