community.zabbix icon indicating copy to clipboard operation
community.zabbix copied to clipboard

API configuration.import behavior changed in 5.4

Open D3DeFi opened this issue 3 years ago • 1 comments

Seems that Zabbix 5.4 has made something different as our CI is failing even after implementing #407.

Also read https://github.com/ansible-collections/community.zabbix/pull/407#issuecomment-869747870

Referenced template is https://github.com/ansible-collections/community.zabbix/blob/main/tests/integration/targets/test_zabbix_template/files/template1_52_higher.json

Now this is very interesting. If I FIRST upload template manually via Import button in Zabbix GUI and then try to print template diff I get:

[]

Buut, if I run ansible-test integration test_zabbix_template and then try to print template diff:

{
  "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:

import json

zbx = ZabbixAPI('http://localhost:8080')
zbx.login('Admin', 'zabbix')


update_rules = {
    'discoveryRules': {
        'createMissing': True,
        'updateExisting': True,
        'deleteMissing': True
    },
    'graphs': {
        'createMissing': True,
        'updateExisting': True,
        'deleteMissing': True
    },
    'groups': {
        'createMissing': True
    },
    'httptests': {
        'createMissing': True,
        'updateExisting': True,
        'deleteMissing': True
    },
    'items': {
        'createMissing': True,
        'updateExisting': True,
        'deleteMissing': True
    },
    'templates': {
        'createMissing': True,
        'updateExisting': True
    },
    'templateLinkage': {
        'createMissing': True,
        'deleteMissing': True
    },
    'templateDashboards': {
        'createMissing': True,
        'updateExisting': True,
        'deleteMissing': True
    },
    'triggers': {
        'createMissing': True,
        'updateExisting': True,
        'deleteMissing': True
    },
    'valueMaps': {
        'createMissing': True,
        'updateExisting': True
    }
}

with open('tests/integration/targets/test_zabbix_template/files/template1_52_higher.json', 'r') as f:
    source_json = json.load(f)

x = zbx.configuration.importcompare(dict(format='json', source=json.dumps(source_json), rules=update_rules))
print(json.dumps(x, indent=2))

zbx.logout()

Now I am lost :)

Originally posted by @D3DeFi in https://github.com/ansible-collections/community.zabbix/issues/407#issuecomment-869767750

D3DeFi avatar Jun 28 '21 15:06 D3DeFi

Oh my, they have switched from using IDs to UUIDs! See #451

D3DeFi avatar Sep 12 '21 14:09 D3DeFi

@D3DeFi I am assuming that this is no longer an issue?

pyrodie18 avatar Aug 31 '22 22:08 pyrodie18

Honestly I have no idea. But CI for zabbix_template is no longer failing and we are preparing to drop 5.4 as well, so lets ignore this and whoever finds this and disagrees can reopen :)

D3DeFi avatar Sep 06 '22 08:09 D3DeFi