08-14-2017 07:06 PM
What is the API method to get the list of Interfaces including IP address for a given device?
Here is what I'm doing
1. Get list of switch and switch-router for device name like 081010 -
2. Get the interfaces of device type 'switch-router' -
When i use the web interface(iresults/DeviceViewer/index.tdf?DeviceID=1657709&Content=/webui/settings/management_status&selectedAccordion=Settings___Status&selectedMenu=Management_Status&selectedTitle=Management%20Status)
I see only 21 interfaces. It shows IP address and Interface name . But through API it return 80 interfaces and it has no IP address.
08-23-2017 07:39 AM - edited 08-23-2017 07:56 AM
There is not a single API call that will return the list of all interfaces, including their IP address. The Interface Table and the Address Table are queried seperately. This is similar to the way the data is obtained via SNMP from the devices themselves -- with interfaces in ifTable, and addresses in ipAddrTable, and using the value of ifIndex to connect them.
So you would use a call like api/3.1/interfaces?DeviceID=2 to get all the physical interfaces, and then use a second call to api/3.1/if_addrs?DeviceID=2 to get the list of IP addresses. Only those interfaces whose ifIndex appears in both outputs have IP addresses.
Of course, if you are only interested in getting a list of IP addresses, and not any of the other interface data from ifTable, then the call to if_addrs is all you need.