Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-12943

Host API inconsistency for inventory_mode attribute

XMLWordPrintable

    • Sprint 20, Sprint 21, Sprint 22, Sprint 23, Sprint 56 (Sep 2019), Sprint 55 (Aug 2019), Sprint 54 (Jul 2019), Sprint 57 (Oct 2019)
    • 3

      Attribute inventory_mode can be used directly with API host.create and host.update, also described as direct attribute in Host object documentation, but it is not present if using host.get

      The attribute is a part of the host inventory sub-object, if selectInventory is part of a host.get request, but that appears differently for different inventory_mode values.

      Inventory modes:

      • disabled - inventory attribute is empty array, inventory_mode is not present.
      • manual - inventory attribute is object, inventory_mode is nested on contrary to documentation.
      • automatic - inventory attribute is object, inventory_mode is nested on contrary to documentation.

      As an API user I'd like to get inventory_mode attribute along with other host attributes when using host.get the same way I use it for host.create and host.update. Also if disabled, empty inventory object is more expected than current empty array.

      Detailed examples follows.

      Inventory mode disabled

      Steps to reproduce:

      1. api call host.create providing inventory_mode parameter
        host.create
        {
        "host": "host01",
        "groups": {"hostgroupid":"1"},
        "interfaces":             {
                        "type": 1,
                        "main": 1,
                        "useip": 1,
                        "ip": "192.168.3.1",
                        "dns": "",
                        "port": "10050"
                    },
        "inventory_mode": "-1"
        }
        
      2. api call host.get don't give parameter back at all not even in inventory sub object
        host.get
        {
        "filter": {"host": "host01"},
        "selectInventory": true
        }
        

      Result:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "hostid": "10314",
                  "proxy_hostid": "0",
                  "host": "host01",
                  "status": "0",
                  ...
                  "inventory": []
              }
          ],
          "id": 2
      }
      

      Expected:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "hostid": "10314",
                  "proxy_hostid": "0",
                  "host": "host01",
                  "status": "0",
                  ...
                  "inventory_mode": "-1",
                  "inventory": []
              }
          ],
          "id": 2
      }
      

      Inventory mode manual

      Steps to reproduce:

      1. api call host.create providing inventory_mode parameter
        host.create
        {
        "host": "host01",
        "groups": {"hostgroupid":"1"},
        "interfaces":             {
                        "type": 1,
                        "main": 1,
                        "useip": 1,
                        "ip": "192.168.3.1",
                        "dns": "",
                        "port": "10050"
                    },
        "inventory_mode": "0"
        }
        
      2. api call host.get don't give parameter back directly, it's in inventory sub object
        host.get
        {
        "filter": {"host": "host01"},
        "selectInventory": true
        }
        

      Result:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "hostid": "10314",
                  "proxy_hostid": "0",
                  "host": "host01",
                  "status": "0",
                  ...
                  "inventory": {
                      "hostid": "10314",
                      "inventory_mode": "0",
                      "type": "",
                      "type_full": "",
                      "name": "",
                      "alias": "",
                      "os": "",
                      ...
                  }
              }
          ],
          "id": 2
      }
      

      Expected:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "hostid": "10314",
                  "proxy_hostid": "0",
                  "host": "host01",
                  "status": "0",
                  ... 
                  "inventory_mode": "0",
                  "inventory": {
                      "hostid": "10314",
                      "type": "",
                      "type_full": "",
                      "name": "",
                      "alias": "",
                      "os": "",
                      ...
                  }
              }
          ],
          "id": 3
      }
      

      Inventory mode automatic

      Steps to reproduce:

      1. api call host.create providing inventory_mode parameter
        host.create
        {
        "host": "host01",
        "groups": {"hostgroupid":"1"},
        "interfaces":             {
                        "type": 1,
                        "main": 1,
                        "useip": 1,
                        "ip": "192.168.3.1",
                        "dns": "",
                        "port": "10050"
                    },
        "inventory_mode": "1"
        }
        
      2. api call host.get don't give parameter back directly, it's in inventory sub object
        host.get
        {
        "filter": {"host": "host01"},
        "selectInventory": true
        }
        

      Result:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "hostid": "10314",
                  "proxy_hostid": "0",
                  "host": "host01",
                  "status": "0",
                  ...
                  "inventory": {
                      "hostid": "10314",
                      "inventory_mode": "1",
                      "type": "",
                      "type_full": "",
                      "name": "",
                      "alias": "",
                      "os": "",
                      ...
                  }
              }
          ],
          "id": 2
      }
      

      Expected:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "hostid": "10314",
                  "proxy_hostid": "0",
                  "host": "host01",
                  "status": "0",
                  ... 
                  "inventory_mode": "1",
                  "inventory": {
                      "hostid": "10314",
                      "type": "",
                      "type_full": "",
                      "name": "",
                      "alias": "",
                      "os": "",
                      ...
                  }
              }
          ],
          "id": 3
      }
      

            talbergs Mārtiņš Tālbergs (Inactive)
            vasekch Vašek Chalupníček
            Team B
            Votes:
            7 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: