简介:
Remedy 是个流行的cmdb 管理平台,下面就其接口调用做个总结。
方法一: 调用pyARS
1.下载安装客户端 https://rrr.se/cgi/index?pg=arapi (8的客户端,可以调用7的 server版本)
2.设置环境变量 export LD_LIBRARY_PATH=/root/test/api811linux/lib/:$LD_LIBRARY_PATH
3.安装pyARS http://freefr.dl.sourceforge.net/project/pyars/pyars/1.8.2/pyars-1.8.2.zip
4.使用:
from pyars import erars, cars ars = erars.erARS() a=ars.Login('10.1.64.16:2722','username','passwd')
手册:http://pyars.sourceforge.net/docs.html
方法二: PyRemedy
from __future__ import print_function from pyremedy import ARS, ARSError ars = ARS( server='10.16.4.16', port=2722, user='l1', password='aa123') import os, atexit,rlcompleter,readline readline.parse_and_bind('tab: complete') ars.query(schema='Midea_CMDB_Automation',qualifier="",fields=[]) ars.fields(schema='Midea_CMDB_Automation') a={'Chr_CIName':'aaaa', 'Chr_HostName':'bbb'} ars.create(schema='Midea_CMDB_Automation',entry_values=a) ars.get(schema='Midea_CMDB_Automation',entry_id='000000000000017',fields=[])
方法三: 使用WSDL
1.安装
pip install suds or suds-jurko (python3)
2.使用
import suds from suds.client import Client from suds.sudsobject import Property from suds.transport.https import HttpAuthenticated remedy = None def connect(wsdl, username, password): global remedy remedy = Client(wsdl, cache=None) auth = remedy.factory.create("AuthenticationInfo") auth.userName = username auth.password = password remedy.set_options(soapheaders=(auth)) connect("http://10.16.4.16/arsys/WSDL/public/msremedyweb/Midea_CMDB_Automation_OS_WebServer", "l1", "aa123")
更多:
Debug:
import logging logging.basicConfig(level=logging.DEBUG) logging.getLogger('suds.client').setLevel(logging.INFO) logging.getLogger('suds.transport').setLevel(logging.INFO) logging.getLogger('suds.xsd.schema').setLevel(logging.INFO) logging.getLogger('suds.wsdl').setLevel(logging.INFO) logging.getLogger('suds.resolver').setLevel(logging.INFO) logging.getLogger('suds.xsd.query').setLevel(logging.INFO) logging.getLogger('suds.xsd.sxbasic').setLevel(logging.INFO) logging.getLogger('suds.xsd.sxbase').setLevel(logging.INFO) logging.getLogger('suds.metrics').setLevel(logging.INFO) logging.getLogger('suds.binding.marshaller').setLevel(logging.INFO)
suds 手册: https://fedorahosted.org/suds/wiki/Documentation
WSDL webservice 调用可以通过 soap ui 测试,在这里不做讲解~
参考资料: