zabbix / python-zabbix-utils

Python library "zabbix-utils"
MIT License
114 stars 16 forks source link

API host.create() interface should not require a blank IP if DNS provided. #9

Closed matthewsht closed 3 months ago

matthewsht commented 9 months ago

for the host.create() call, at least one interface is required.

At the moment, all of our interfaces are DNS base - but the IP address must still be passed along. Example:

interface = [ { "type": 1, # 1 is 'agent', 2 is 'SNMP', 3 is 'IPMI', 4 is 'JMX' "main": 1, # 0 is 'not default', 1 is 'default' "useip": 0, # 0 is 'use DNS', 1 is 'use IP' "ip": "", # doc says can be blank but not _undefined_ if using DNS "dns": f"{host['name']}.{hg_config['dns_domain']}", "port": "10050", # default port for zabbix agent # BUG: this is wrong for other template types } ]

The documentation (IMHO) implies that this is true - at: https://www.zabbix.com/documentation/6.4/en/manual/api/reference/hostinterface/object We get

Can be empty if the connection is made via DNS.

But the API would make more sense if this field could be left blank.

aiantsen commented 3 months ago

@matthewsht, thank you for your issue. I couldn't reproduce the problem. I used the following interface dict in the request and the host was added successfully without an IP:

interface = [
    {
        "type": 1,  # 1 is 'agent', 2 is 'SNMP', 3 is 'IPMI', 4 is 'JMX'
        "main": 1,  # 0 is 'not default', 1 is 'default'
        "useip": 0,  # 0 is 'use DNS', 1 is 'use IP'
        "ip": "",  # doc says can be blank but not _undefined_ if using DNS
        "dns": "host_domain",
        "port": "10050",  # default port for zabbix agent 
        # BUG: this is wrong for other template types
    }
]

In general, the library just provide literally the same functionality as API does behaving as a wrapper. Thus, it's supposed to support all fields and their values those are supported by API.

Please let us know if the problem still be relevant. And in such a case please advise us of more details or examples of the issue to help us reproduce it.

aiantsen commented 3 months ago

Issue closed due to no feedback from the author.

matthewsht commented 3 months ago

I'm sorry- there was feedback on Aug 29 but I attempted to reply to the github email and our corp email blocked it. The email said "Understood, this can be closed" and I've now learned to only use the web interface.