-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Zabbix 5.4 template imports failing #407
Fix Zabbix 5.4 template imports failing #407
Conversation
Applications are no longer supported, everything is solved through tags now.
Codecov Report
@@ Coverage Diff @@
## main #407 +/- ##
==========================================
- Coverage 78.78% 76.74% -2.05%
==========================================
Files 19 21 +2
Lines 2635 2958 +323
Branches 665 761 +96
==========================================
+ Hits 2076 2270 +194
- Misses 364 452 +88
- Partials 195 236 +41
Continue to review full report at Codecov.
|
Thank you for this patch. However, it seems there is also something else broken as Currently, we don't have CI enabled for 5.4, but if run locally via docker: zabbix_version=5.4 docker-compose up -d
ansible-test integration test_zabbix_template It fails on the following step:
So in order to fix this problem we need to dig even deeper. Anyway, I think we can merge this patch and solve at least 50% of problems with zbx template rather than having it bugged 100%. Do you agree @sky-joker ? |
hmm, this seems to work correctly tho when executed multiple times: from zabbix_api import ZabbixAPI
zbx = ZabbixAPI('http://localhost:8080')
zbx.login('Admin', 'zabbix')
rules = {
'templates': {
'createMissing': True,
'updateExisting': True
}
}
source = '''<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>5.0</version>
<templates>
<template>
<template>ExampleTemplate</template>
<groups>
<group>
<name>Linux servers</name>
</group>
</groups>
</template>
</templates>
</zabbix_export>'''
zbx.configuration.import_(dict(format='xml', source=source, rules=rules))
zbx.logout() |
@@ -622,6 +622,10 @@ def import_template(self, template_content, template_type='json'): | |||
if LooseVersion(self._zbx_api_version) >= LooseVersion('5.2'): | |||
update_rules["templateDashboards"] = update_rules.pop("templateScreens") | |||
|
|||
# Zabbix 5.4 no longer supports applications |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @href for the patch!
Could you please add a changelog?
@D3DeFi |
I was able to verify that attempting to import the same file via Zabbix GUI also results in the same error. I believe there is nothing wrong with such json, or is it? I think this should be open as a bug for Zabbix |
@D3DeFi I wonder that why doesn't the error happen(environment dependent?). |
@sky-joker it must be that we are doing something wrong in the zabbix_template. I am running against 5.4.0 (ubuntu-5.4-latest from our docker-compose) file with the following steps:
Other test is:
I suspect there was a secret change of how API works (again..). I think this is how it works in the second case (thus not failing) in sort-of pseudocode: template = zbx.template.get()
cmpres = zbx.configuration.importcompare() if template
zbx.configuration.import() if cmpres.different |
Now this is very interesting. If I FIRST upload template manually via [] Buut, if I run {
"templates": {
"added": [
{
"after": {
"template": "ExampleHost",
"name": "ExampleHost",
"macros": [
{
"macro": "{$EXAMPLE_MACRO1}",
"value": "1000"
},
{
"macro": "{$EXAMPLE_MACRO2}",
"value": "text"
}
],
"templates": [
{
"name": "FTP Service"
},
{
"name": "Zabbix Proxy"
}
],
"uuid": "c1a80829556941e4a1ff307b39130b5a"
}
}
]
}
}
This is my current test script:
Now I am lost :) |
Anyway, I will open new issue and merge this. Changelog will be added when I will prepare 1.4.0 release |
Thanks, for the details.
ok, thanks in advance. |
Applications are no longer supported, everything is solved through tags now.