Access of IP Address Management (IPAM)

Another requirement in networking is to use the IPAM database for IPAM. It is provided by different vendors, and as an example here, we would refer to SolarWind's IPAM. SolarWinds is again an industry standard tool for monitoring and performing various functionalities on a network, and it has a good set of APIs to interact with using its ORION SDK toolkit.

In Python, we can install the library orionsdk to achieve interaction with SolarWinds. Let's see an example in which we fetch the next available IP address from the IPAM module in SolarWinds:

from orionsdk import SwisClient

npm_server = 'mysolarwindsserver'
username = "test"
password = "test"

verify = False
if not verify:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

swis = SwisClient(npm_server, username, password)

print("My IPAM test:")
results=swis.query("SELECT TOP 1 Status, DisplayName FROM IPAM.IPNode WHERE Status=2")
print (results)

### for a formatted printing
for row in results['results']:
print("Avaliable: {DisplayName}".format(**row))

The output is as follows:

As we see in the preceding code, we use the orionsdk library to call the API for SolarWinds from the mysolarwindsserver server. The username and password needed for the SolarWinds are passed in script, and we use a simple SQL query (which is understandable by SolarWinds) which is as follows:

 SELECT TOP 1 Status, DisplayName FROM IPAM.IPNode  WHERE Status=2 

This query fetches the next available IP address (denoted by Status=2 in SolarWinds) and prints it. The first print is the raw print and the one in for loop; it prints out the value in a better understandable format as shown in the preceding output.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.235.210