早先有同事通过直接修改iTop数据库实现集成,由于这种方式略感粗暴(一旦类对象变化或版本升级等原因导致数据库表结构变化,比较容易出现问题),所以测试了iTop官方安装文档推荐的REST/JSON集成方式,这里使用python实现。
POST参数
要调用对应的action,通过下面几个参数给
Argument | Description | Defaut value |
---|---|---|
version | Version of the API. It is a way to make sure that the targetted iTop server can deliver some functionality, and it ensures stability for your scripts: as long as a version is available, the operations will remain unchanged, with the exception of the following cases: bug fixes, modification in the returned messages, new elements into the returned JSON structure. | - |
auth_user | User login | - |
auth_pwd | User password | - |
json_data | Structure containing all the information required to process your request. In particular, the requested operation is given here. | |
callback | If set, then JSON-P (JSON with padding) is used |
在实际使用参数时,须要注意:
传递auth_user和auth_pwd须要在配置文件
/conf/production/config-itop.php开启url 1'allowed_login_types' => 'form|basic|external|url',所有参数整体作为dictionary传递(并做urlencode),在整个dictionary中的json_data须要事先指定为JSON类型
具体操作都是由json_data参数内完成,可以使用”operation”: “list_operations”列出所有支持的operation
python实现
这里测试实现了直接脚本里写了一个参数列表,POST到iTop实现ticket创建。生产环境可以通过传递相应参数来实现不通内容的传递。
|
|