If you ever wonder how to change settings with API in the IP Fabric, then this is the right reading for you. In the previous article, from our API series, we focused on the first steps with IP Fabric's API. It was all about how to authenticate and collect data from inventory.
Today we will take one step further with automation. There are cases where we need to change settings for new network discovery in IP Fabric or start fresh snapshots without interacting with the Graphical User Interface (GUI) by using scripts.
There are multiple endpoints with each specific function in IP Fabric that can help us to change settings with API. In this quick tutorial, we will just mention a few basic ones. The current list of all available endpoints can be found at this site. Let's start with the Seed IP or the starting point for discovery settings.
The seed IP address can be a very important part of the discovery process whenever we are about to discover new networks. By default, if there are no discovered devices, the process starts from the default gateway relative from the IP Fabric server. If not reachable the IPF tries to traceroute over the gateway to discover new hops and if there's nothing found from the traceroute, we will need to define at least 1 device as a starting point.
The main endpoint for Seed modification is:
https://IPFserver/api/v1/settings/seed
and the Seed setup has 3 available methods: GET, POST & PUT. The GET request will respond with the list of available IP addresses or subnets in the Seed. The POST request with a payload including a list of additional IPs will add those to the current list. And the PUT request will remove existing data with new IPs int the payload.
Following code snippet may be used to update the Seed information:
def updateSeed(postSeedServer, postSeedHeaders, postSeedLoad):
seedPost = requests.post(postSeedServer + 'api/v1/settings/seed', headers=postSeedHeaders, json=postSeedLoad, verify=False)
if seedPost.reason == 'Not Modified': print(' Seed is remaining the same.')
elif seedPost.ok: print(' Seed updated successfully with: ' + str(postSeedLoad))
else: print(' UNABLE to update the Seed: ' + seedPost.text)
return seedPost
The IP Fabric is an extremely flexible system with plenty of available tweaks related to the Discovery process, SSH connections, or system options, like backups. The API endpoint is:
https://IPFserver/api/v1/settings
The main methods are GET for reading all currently applied settings and PATCH will allow us to change settings with API. The following snippet will collect Settings information and provides a complete JSON format.
def getSettings(getSettServer, getSettHeaders):
settingsGet = requests.get(getSettServer + 'api/v1/settings', headers=getSettHeaders, verify=False)
if settingsGet.ok: print(' Following Settings are in use: ' + settingsGet.text)
else: print(' UNABLE to get Settings info: ' + settingsGet.text)
return settingsGet
Thank you for reading and now enjoy the second part of our recording!
If you have found this article helpful, please follow our company’s LinkedIn or Blog, where there will be more content emerging. Furthermore, if you would like to test our platform to evaluate how it can assist you in managing your network more effectively, please let us know through www.ipfabric.io.