Creating FQDN Nodes via iControl REST

A question came up in Q&A concerning the iControl REST interface. When the requestor is using python, I try to point them to the f5-common-python sdk that has been available for nearly a year now. It is under constant development and we try to remove obstacles and make things consistent for the user. Take this request on creating nodes from community member Chanan. In looking at the return data, he is trying rewrite as a payload and submit as a post, using token auth to do so. Without the sdk, this can be accomplished like so:

import requests, json

# Ignore SSL Errors

# Get Token Function
def get_token(bigip, url, creds):
    payload = {}
    payload['username'] = creds[0]
    payload['password'] = creds[1]
    payload['loginProviderName'] = 'tmos'

    token =, json.dumps(payload)).json()

    return token['token']['token']

# Set up request session
b = requests.session()
b.headers.update({'Content-Type': 'application/json'})
b.auth = ('admin', 'admin')
b.verify = False
# Call token function to get token
token = get_token(b, '',
                  ('admin', 'admin'))
# Update auth from basic to token
b.auth = None
b.headers.update({'X-F5-Auth-Token': token})

# Create a node with IP address
payload = {}
payload['name'] = 'node3'
payload['partition'] = 'Common'
payload['address'] = ''
node3 ='', data=json.dumps(payload))

# Create a node with FQDN
payload = {}
fqdn = {'tmName': 'node4.test.local', 'autopopulate': 'disabled'}
payload['fqdn'] = fqdn
payload['name'] = 'node4'
payload['address'] = 'any6'
payload['partition'] = 'Common'
node4 ='', data=json.dumps(payload))

However, if you use the sdk, almost all this leg work is taken care of for you, leaving you to just create nodes:

import requests
from f5.bigip import ManagementRoot

# Ignore SSL Errors

# Instantiate the BIG-IP
b = ManagementRoot('', 'admin', 'admin', token=True)

# Create a node with IP address
node1 ='node1', address='', partition='Common')

# Create a node with FQDN
node2 ='node2', address='any6', fqdn={'tmName': 'node2.test.local'}, partition='Common')

You don’t need to set those calls to variables for the nodes to be created, but if you want to do validation on the clientside it’s helpful to have those objects to interrogate.

Look for more sdk tips in the near future!

Published Jan 31, 2017
Version 1.0

Was this article helpful?


  • Bien_Nguyen_Tha's avatar
    Historic F5 Account

    Dear experts, Management port on my BIG-IP was changed to 8443 instead of the 443 as default. I've tried to set: mgmt = ManagementRoot("", "admin", "admin")


    and got this error: requests.exceptions.InvalidURL: Failed to parse: how can i set the new management port to 8443?


    Thank you!


  • supply it as kwarg:


    mgmt = ManagementRoot('x.x.x.x', 'admin', 'admin', port=8443)