[python]Using F5 iControl API without F5-SDK

I am experimenting myself, I have not worked with json type before, I worked frequently with the xml type, I will need to learn how to parse json type data to get meaningful output..

here’s the sample code to test on GET.

import requests, logging


# Global parameters should be defined here
# credential
USERNAME = "admin"
PASSWORD = "121278"

# Bigip appliance address, use an array to store it

# Bigip LTM path, from this path we can cocatenate pool, member, and virtual server
BIGIP_LTM = "/mgmt/tm/ltm"

# Pools, use a dictionary so that the pool name can be reference to an index.
POOLS = {}

# Pool members (nodes), use an array to store the address with ports.

# Log filename
LOG_FILENAME = "bigip_script.log"

# Logging configuration
logging.basicConfig(filename=LOG_FILENAME, format="%(asctime)s %(levelname)s:%(message)s",

# Package the session for bigip
bigip = requests.session()
bigip.auth = requests.auth.HTTPBasicAuth(USERNAME,PASSWORD)
# Specify the request header
bigip.headers.update({"Content-Type" : "application/json"})
# ignoring certificate security warning, meaning do not check for valid bigip certificate
bigip.verify = False
logging.debug("Preparing for bigip REST API sessions...")

payload = {}

for bigip_address in BIGIP_ADDRESSES:
        response = bigip.get("https://" + bigip_address + BIGIP_LTM + "/pool")
    except Exception as e:

payload = response.json()

for item in payload['items']:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s