brennerm / check-mk-web-api

Python library to talk to the Check_Mk Web API
https://brennerm.github.io/check-mk-web-api/
MIT License
53 stars 26 forks source link

Check_MK exception: Unknown tag group snmp_community #40

Open cboseck opened 3 years ago

cboseck commented 3 years ago

Hello,

I am facing the issue that you can't create a host with snmp-host. The response from the exeption message says: "Check_MK exception: Unknown tag group snmp_community".

To reproduce this I created this test:

def test_add_host_with_attributes():
    api.add_host('host00', tags={'snmp_community': 'public', 'tag_snmp_ds': 'snmp-v2'})
    assert api.get_host('host00')['attributes']['snmp_community'] == 'public'
    assert api.get_host('host00')['attributes']['tag_snmp_ds'] == 'snmp-v2'

The problem is that always the 'tag_' prefix gets added so 'snmp_community' can't be found.

Removing this solved my problem. I guess I could use the 'customattrs' param, but then I would need to build a special-case. Is there a reason the the tag prefix gets added?

Have a nice day

brennerm commented 3 years ago

Hey @cboseck, thanks for reporting this issue. Which version of CheckMK are you using?

cboseck commented 3 years ago

check-mk-raw:1.6.0p18

brennerm commented 3 years ago

Just did some research and read through the docs of the Web API add_host function. If I understand that section correctly tags are just special attributes identified by the _tag__ prefix. According to that the implementation seems correct. Let me know if you see that differently.