Get Network Inventory IPs with Script

  • 0
  • 1
  • Question
  • Updated 4 months ago
  • Answered
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.
Photo of Terren Crider

Terren Crider

  • 1,564 Points 1k badge 2x thumb

Posted 5 months ago

  • 0
  • 1
Photo of SH

SH

  • 5,318 Points 5k badge 2x thumb
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
Photo of Terren Crider

Terren Crider

  • 1,564 Points 1k badge 2x thumb
Yeah, I'm looking for the switches.

Thanks, I'll give this a shot.
Photo of Gates Zeng

Gates Zeng, Employee

  • 172 Points 100 badge 2x thumb
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):
    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")
(Edited)
Photo of SH

SH

  • 5,318 Points 5k badge 2x thumb
Or if you don't like soap ;-), you can use REST calls like:

import requests
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)
(Edited)