Reputation: 4533
I am getting the following errors while using the Zabbix Python API for host creation,
Traceback (most recent call last):
File "test.py", line 57, in <module>
zapi.host.create({ 'name':'testname', 'host' : '192.168.1.1','ip' :
'192.178.1.2','port' : 10050,'useip' : 0,'groups' : [{
"groupid":gid}],'templates' : [{ "templateid":tid}]})
File "/home/zhiguo/zabbix/zabbix_api.py", line 346, in method
return self.universal("%s.%s" % (self.data["prefix"], name), opts[0])
File "/home/zhiguo/zabbix/zabbix_api.py", line 80, in wrapper
return self.do_request(self.json_obj(method, opts))['result']
File "/home/zhiguo/zabbix/zabbix_api.py", line 353, in do_request
return self.parent.do_request(req)
File "/home/zhiguo/zabbix/zabbix_api.py", line 307, in do_request
raise ZabbixAPIException(msg, jobj['error']['code'])
zabbix_api.ZabbixAPIException: (u'Error -32602: Invalid params., No
interfaces for host "192.168.1.1". while sending {"params": {"templates": {"templateid": "10085"}], "name": "testname", "ip": "192.178.1.2", "useip": 0,
"host": "192.168.1.1", "groups": [{"groupid": "6"}], "port": 10050},
"jsonrpc": "2.0", "method": "host.create", "auth":
"7894f7d64a3f30e1754dd9d2eeb5a493", "id": 4}', -32602)
my python code is:
zapi.host.create({ 'name':'testname', 'host' : '192.168.1.1','ip' :
'192.178.1.2', 'port' : 10050,'useip' : 0,'groups' : [{ "groupid":gid}],
'templates' : [{ "templateid":tid}]})
Upvotes: 0
Views: 4599
Reputation: 3188
I still haven't tried the Zabbix 2.0 API, but this was how I did it in 1.8.x
I'm quite sure dns field is mandatory,
hostid = zapi.host.create({ 'host': host_name, 'dns' : host_name,'ip' : host_ip,
'groups': [{"groupid":hostgroup_id}]})['hostids'][0]
Also, from the docs ,
"interfaces":[
{
"type":1,
"main":1,
"useip":1,
"ip":"192.168.3.1",
"dns":"",
"port":10050
}
it does seem "Invalid params., No interfaces for host" is complaining about a missing "interfaces" parameter,
Upvotes: 1