ZABBIX BUGS AND ISSUES
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-9093

Can't create host with inventory through API

    Details

      Description

      When calling host.create through api_jsonrpc.php with inventory object, inserting fails.

      After investigation, error is the same as ZBX-7561 : Field 'hardware_full' doesn't have a default value .

      The source would be calling DBExecute directly from CHost::insert.

      Not tested, but it seems that the example from the documentation ( https://www.zabbix.com/documentation/2.4/manual/api/reference/host/create ) wouldn't work.

        Issue Links

          Activity

          Hide
          richlv added a comment -

          just in case, could you please add exact request & response json ?

          Show
          richlv added a comment - just in case, could you please add exact request & response json ?
          Hide
          Thomas MEVEL added a comment - - edited

          Sure, here is the request (data content edited) :

          {
            "jsonrpc":"2.0",
            "method":"host.create",
            "params":{ 
                   "host":"srv-backup1",
                   "interfaces" :[
                           {
                                "type" : 1,
                                 "main" : 1, "ip" : "186.154.53.62", 
                                 "port" : "10574",
                                 "useip" : 1,
                                 "dns" : "" 
                           } 
                   ],
                   "proxy_hostid":0,
                   "ipmi_privilege":2,
                   "groups": [  { "groupid":"8"},{ "groupid":"1"} ], 
                   "templates":[ ],
                   "inventory": { "serialno_a": "AA25641", "tag": "1" } 
           },
           "auth":"73704a74c6ca1befde153ba87502fba5",
           "id":1 
          }
          

          Response won't give much help as it fails giving a success result (see ZBX-9094) :

          {
           "jsonrpc":"2.0",
           "result": {"hostids":["10106"]},
           "id":1
          }
          
          Show
          Thomas MEVEL added a comment - - edited Sure, here is the request (data content edited) : { "jsonrpc" : "2.0" , "method" : "host.create" , "params" :{ "host" : "srv-backup1" , "interfaces" :[ { "type" : 1, "main" : 1, "ip" : "186.154.53.62" , "port" : "10574" , "useip" : 1, "dns" : "" } ], "proxy_hostid" :0, "ipmi_privilege" :2, "groups" : [ { "groupid" : "8" },{ "groupid" : "1" } ], "templates" :[ ], "inventory" : { "serialno_a" : "AA25641" , "tag" : "1" } }, "auth" : "73704a74c6ca1befde153ba87502fba5" , "id" :1 } Response won't give much help as it fails giving a success result (see ZBX-9094 ) : { "jsonrpc" : "2.0" , "result" : { "hostids" :[ "10106" ]}, "id" :1 }
          Hide
          Alexander Vladishev added a comment -

          I confirm the issue in 2.0, 2.2 and 2.4 branches r50976.

          Show
          Alexander Vladishev added a comment - I confirm the issue in 2.0, 2.2 and 2.4 branches r50976.
          Hide
          Leif Johnson added a comment - - edited

          It look like the host inventory get's disabled on host.create. Changing the inventory mode via

           "inventory_mode": 1 

          does not appear to work either.

          Using host.update afterwards does appear to work and could be a work around.

              "inventory_mode": 1,
                  "inventory": {
                      "macaddress_a": "01234",
                      "macaddress_b": "56768"
                  }
          
          Show
          Leif Johnson added a comment - - edited It look like the host inventory get's disabled on host.create. Changing the inventory mode via "inventory_mode" : 1 does not appear to work either. Using host.update afterwards does appear to work and could be a work around. "inventory_mode" : 1, "inventory" : { "macaddress_a" : "01234" , "macaddress_b" : "56768" }
          Hide
          Ivo Kurzemnieks added a comment - - edited

          (1) No translation string changes.

          Alexander Vladishev CLOSED

          Show
          Ivo Kurzemnieks added a comment - - edited (1) No translation string changes. Alexander Vladishev CLOSED
          Hide
          Ivo Kurzemnieks added a comment -

          RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-9093

          Show
          Ivo Kurzemnieks added a comment - RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-9093
          Hide
          Alexander Vladishev added a comment - - edited

          (2) Take a look at my changes in r51591.

          Ivo Kurzemnieks Thanks!
          CLOSED.

          Show
          Alexander Vladishev added a comment - - edited (2) Take a look at my changes in r51591. Ivo Kurzemnieks Thanks! CLOSED.
          Hide
          Ivo Kurzemnieks added a comment -
          Show
          Ivo Kurzemnieks added a comment - API documentation updated: https://www.zabbix.com/documentation/2.0/manual/appendix/api/changes_2.0 https://www.zabbix.com/documentation/2.2/manual/api/changes_2.2 https://www.zabbix.com/documentation/2.4/manual/api/changes_2.4 Fixed in: pre-2.0.15rc1 r51620 pre-2.2.9rc1 r51621 pre-2.4.4rc1 r51622 pre-2.5.0 r51624
          Hide
          Oleg Egorov added a comment - - edited

          (3) SQL statement execution has failed \"INSERT INTO host_inventory (macaddress_a,macaddress_b,hostid,inventory_mode,hardware_full,software_full,contact,location,notes,host_networks,site_notes,poc_1_notes,poc_2_notes) VALUES ('01234','56768','1','0','','','','','','','','','')

          host.create
          API request used from documentation:
          https://www.zabbix.com/documentation/3.0/manual/api/reference/host/create

          {
                  "host": "NA1",
                  "interfaces": [
                      {
                          "type": 1,
                          "main": 1,
                          "useip": 1,
                          "ip": "192.168.3.1",
                          "dns": "",
                          "port": "10050"
                      }
                  ],
                  "groups": [
                      {
                          "groupid": "13"
                      }
                  ],
                  "templates": [
                      {
                          "templateid": "10111"
                      }
                  ],
                  "inventory": {
                      "macaddress_a": "01234",
                      "macaddress_b": "56768"
                  }
              }
          

          Clean installation (trunk)

          Alexander Vladishev Thank you for a report! RESOLVED in r51842.

          Ivo Kurzemnieks Good fix! Thanks!
          CLOSED.

          Show
          Oleg Egorov added a comment - - edited (3) SQL statement execution has failed \"INSERT INTO host_inventory (macaddress_a,macaddress_b,hostid,inventory_mode,hardware_full,software_full,contact,location,notes,host_networks,site_notes,poc_1_notes,poc_2_notes) VALUES ('01234','56768','1','0','','','','','','','','','') host.create API request used from documentation: https://www.zabbix.com/documentation/3.0/manual/api/reference/host/create { "host" : "NA1" , "interfaces" : [ { "type" : 1, "main" : 1, "useip" : 1, "ip" : "192.168.3.1" , "dns" : "", "port" : "10050" } ], "groups" : [ { "groupid" : "13" } ], "templates" : [ { "templateid" : "10111" } ], "inventory" : { "macaddress_a" : "01234" , "macaddress_b" : "56768" } } Clean installation (trunk) Alexander Vladishev Thank you for a report! RESOLVED in r51842. Ivo Kurzemnieks Good fix! Thanks! CLOSED.
          Hide
          Ivo Kurzemnieks added a comment -

          TESTED.

          Show
          Ivo Kurzemnieks added a comment - TESTED.
          Hide
          Alexander Vladishev added a comment -

          Fixed in:

          pre-2.0.15 r51855
          pre-2.2.9 r51856
          pre-2.4.4 r51857
          pre-2.5.0 (trunk) r51858

          Show
          Alexander Vladishev added a comment - Fixed in: pre-2.0.15 r51855 pre-2.2.9 r51856 pre-2.4.4 r51857 pre-2.5.0 (trunk) r51858

            People

            • Assignee:
              Unassigned
              Reporter:
              Thomas MEVEL
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: