ca频谱web服务api包装器。
spectrum-client的Python项目详细描述
频谱客户端
ca频谱web服务api包装器
安装
spectrum客户端在pypi上发布,在linux/macos和windows上可用,并支持python 2.7、3.4+。
pip install -U spectrum-client
用法
fromspectrum_clientimportSpectrumoc=Spectrum('http://oneclick.mydomain:8080','myuser','secret')# Update a model attributeoc.update_attribute(0x210afa,0x10024,'MySNMPSecret')# Update multiple attributesnotes='Some notes'updates=[(0x11564,notes),(0x12db9,'JKL002'),(0x1295d,False)]oc.update_attributes(mh,updates)# Get a list of devices by name, using regex, restricting the search to landscape 0x200000oc.devices_by_name('^SW00',0x200000)# Get a lis tof devices by specific attribute from all landscapesoc.devices_by_attr(0x12db9,'XYZ001')# Get a list of devices by multipe matching filtersoc.devices_by_filters([(attr1,'equals',value1),(attr2,'has-pcre','^foo.*bar')],landscape)# Put a model in maintenance modeoc.set_maintenance(model_handle,True)# Remove a model from maintenance modeoc.set_maintenance(model_handle,False)# Create an event of type 0x10f06 (generates a High Memory Utilization alarm) on a device with IP Address.event='0x10f06'device_ip='10.10.0.1'var_binds={0:75,1:99,3:'mem_instance',5:'name'}oc.generate_event_by_ip(event,device_ip,var_binds)
如果不提供,将从环境变量SPECTRUM_URL
、SPECTRUM_USERNAME
、SPECTRUM_PASSWORD
读取服务器和凭据。