在zenoss中是否有任何API可以获取同一组下的所有设备名称?
请指出正确的方向。
我正在使用Python查询zenoss组下的设备。密钥是使用data ='{“ action”:“ DeviceRouter”,“ method”:“ getDevices”,“ data”:[{“ uid”:“ / zport / dmd / Devices /”}],“ tid”发送请求:1}')
import requests
def getZenossDeviceList(zenossURI, username, password, data):
try:
s = requests.Session()
s.auth = (username, password)
s.headers["Content-Type"] = "application/json"
r = s.post(zenossURI, data=data, timeout=(3.05, 30));
except Exception as ex:
raise Exception("getZenossDeviceList: {0}",ex )
else:
if r.status_code == requests.codes.ok:
return r.json()
else:
raise Exception("getZenossDeviceList: {0}", r.reason)
def getServerList(username,password):
hostList = []
zenossURI="https://<ZENOSSS_SERVER_IP>/zport/dmd/device_router"
try:
r = getZenossDeviceList(zenossURI, username, password,\
data='{"action":"DeviceRouter", "method":"getDevices","data":[{"uid":"/zport/dmd/Devices/<AbsolutePath_for_Groupname>"}],"tid":1}')
print r
except Exception as e:
print "Exception", e
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句