Hi,
I am trying to create hosts and assign multiple templates. But it is taking only one template name instead of 2,
def hostcreate(hostname,dnsname,ipaddress,groupname,*t emplatename):
zapi=zabbix.authenticate('http://10.21.1.239/zabbix','Admin', 'Vivox12!')
group_id=zapi.hostgroup.get(search={"name":groupna me},output="extend")[0]['groupid']
print(group_id)
for id in templatename:
template_id=zapi.template.get(filter={"host": id})[0]['templateid']
print(template_id)
print zapi.host.create({"host":hostname,"name":dnsname," status": 0,"interfaces":[{"type":1,"main":1,"useip":1,"ip":ipaddress,"dns": "","port":"10050"}],'groups' : [{"groupid":group_id}],'templates' : [{"templateid": template_id}]})
return(hostcreate)
hostcreate("test1","test1","50.1.1.11","Internal Development/Plab5 machines (plab5)","mph Servers","Vivox OS Linux")
It is only creating hosts with mph template, but I am getting ids for both mph servers and Vivox OS Linux servers.
Can anyone help me?
I am trying to create hosts and assign multiple templates. But it is taking only one template name instead of 2,
def hostcreate(hostname,dnsname,ipaddress,groupname,*t emplatename):
zapi=zabbix.authenticate('http://10.21.1.239/zabbix','Admin', 'Vivox12!')
group_id=zapi.hostgroup.get(search={"name":groupna me},output="extend")[0]['groupid']
print(group_id)
for id in templatename:
template_id=zapi.template.get(filter={"host": id})[0]['templateid']
print(template_id)
print zapi.host.create({"host":hostname,"name":dnsname," status": 0,"interfaces":[{"type":1,"main":1,"useip":1,"ip":ipaddress,"dns": "","port":"10050"}],'groups' : [{"groupid":group_id}],'templates' : [{"templateid": template_id}]})
return(hostcreate)
hostcreate("test1","test1","50.1.1.11","Internal Development/Plab5 machines (plab5)","mph Servers","Vivox OS Linux")
It is only creating hosts with mph template, but I am getting ids for both mph servers and Vivox OS Linux servers.
Can anyone help me?