Get Network Inventory IPs with Script


Userlevel 2
I'm working on a Python script to help with some networking tasks. Is there a way that I can get the IPs of my network devices from EMC programatically? Rather than hardcoding the IPs in the script, I'd like to use EMC as the authoritative source for that information. It would be even better if I could pull other attributes like OS and Version, as well.

I've been looking at the API, but I haven't seen a way to use that method to pull the information.

4 replies

Userlevel 5
Hello Terren,

are you looking for network devices like switches or end systems (=clients)?

All switch data you will receive with:

  1. Get all devices (and there ips) with this command: "https://YourNetSightIP:8443/axis/services/NetSightDeviceWebService/getAllDevices". Take all ips form the answer to this request and put the ips in the command here:
  2. "https://YourNetSightIP:8443/axis/services/InventoryWebService/getDeviceProperties?ipAddress=IpFromStepOne" in a loop of you script.
Best regards
Stephan
Userlevel 2
SH wrote:

Hello Terren,

are you looking for network devices like switches or end systems (=clients)?

All switch data you will receive with:

  1. Get all devices (and there ips) with this command: "https://YourNetSightIP:8443/axis/services/NetSightDeviceWebService/getAllDevices". Take all ips form the answer to this request and put the ips in the command here:
  2. "https://YourNetSightIP:8443/axis/services/InventoryWebService/getDeviceProperties?ipAddress=IpFromStepOne" in a loop of you script.
Best regards
Stephan

Yeah, I'm looking for the switches.

Thanks, I'll give this a shot.
Hi Terren,

The APIs are defined in the wsdl file.

Here are several lines of python code for your reference:

import deep
def service (self, xmc_ip):[/code] wsdl_url = 'https://' + xmc_ip +':8443/axis/services/NetSightDeviceWebService?wsdl'
client = zeep.CachingClient (wsdl=wsdl_url, transport=self.transport, strict=False)
return client.bind ('NetSightDeviceWebService', "NetSightDeviceWebServiceSOAP11port_https1")
[/code]
Userlevel 5
Or if you don't like soap 😉, you can use REST calls like:

import requests[/code]user = 'your user'
pw = 'your password'
xmcip = 'your xmcip:8443'
request = '/axis/services/NetSightDeviceWebService/getAllDevices'
r = requests.get('https://' + user + ':' + pw + '@' + xmcip + request, verify = False)[/code]

Reply