1385 views

Description

When Discovery device identification runs, the identity sensor needs to determine if the CI already exists by calling the identifyCI method in the identification engine. If identifyCI returns a sys_id, meaning that a matching CI is found, Discovery uses that sys_id when calling createOrUpdateCI. By doing so, Discovery bypasses the identifiers and updates the record directly.

In this issue, if identifyCI returns the sys_id of an identified CI that is not of the same class, createOrUpdateCI cannot find the CI where it expects to find it and identification fails.

For example, identifyCI finds a match on a cmdb_ci_hardware record, but Discovery classifies it as a cmdb_ci_linux_server. When Discovery calls createOrUpdateCI, the identification engine looks for the sys_id in the table that Discovery passes into the payload, in this case the cmdb_ci_linux_server table. The sys_id does not exist in the cmdb_ci_linux_server table, causing the identification engine to display the following error:

Error CMDB Identification Error: Record referenced from payload doesn't exist: 838144144f6d2200567add211310c721

Steps to Reproduce

  1. Create a cmdb_ci_hardware record with the name of an actual device.
    Ensure that the device does not exist in the CMDB yet.
  2. Run Discovery on another device that shares the same name.
    Note that the CI is not matched and updated.
  3. Check the Discovery log and note the following error: 

    Error CMDB Identification Error: Record referenced from payload doesn't exist: <sys_id of cmdb_ci_hardware record>

    The cmdb_ci_hardware record's class should be updated to the class Discovery found and the configuration item's data should be populated.

 

Workaround

Edit the CMDBIdentifiy function in both DiscoveryIDSensor and DiscoveryJSONIDSensor by performing the following three steps:

 

1.

Replace:

     CMDBIdentify: function() {

        var idResult;

        var logger = new DiscoveryLogger();

        logger.setSource(this.type);

        logger.setSensor(this.getEccQueueId());

 

With:

     CMDBIdentify: function() {

        var idResult;

      var loggedAttempts = false;

         var logger = new DiscoveryLogger();

         logger.setSource(this.type);

         logger.setSensor(this.getEccQueueId());

 

2.

Replace:

        // We'll only get a sysId if the result of the check was a match/update

        // otherwise the API will return 'undefined'

       if (JSUtil.notNil(idResult.sysId)) {

             // Log the attempts here because the later commit API call will not use matching

             DiscoveryCMDBUtil.logIDAttempts(idResult.attempts, logger);

             this.getAndSetCi(idResult.className, idResult.sysId);

        this.preventCiDataFlipping();

With:

       // Also make sure class name of match and ciData are the same so

     // that we don't prevent reclassification by passing in sys_id

     if (idResult.sysId && idResult.className === this.ciData.getData().sys_class_name) {

             // Log the attempts here because the later commit API call will not use matching

        DiscoveryCMDBUtil.logIDAttempts(idResult.attempts, logger);

        loggedAttempts = true;

        this.getAndSetCi(idResult.className, idResult.sysId);

        this.preventCiDataFlipping();

 

3. 

Replace:

        if (idResult.insert) {

             // Log attempts if we insert (update case was handled previously)

            DiscoveryCMDBUtil.logIDAttempts(idResult.attempts, logger);

            this._isNewCI = true;

         }

With:

        if (!loggedAttempts) {

             DiscoveryCMDBUtil.logIDAttempts(idResult.attempts, logger);

             loggedAttempts = true;

        }

 

        if (idResult.insert)

            this._isNewCI = true;


Related Problem: PRB709625

Seen In

Helsinki Patch 3
Helsinki Patch 7

Fixed In

Istanbul

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-02-28 01:20:38
Published:2016-10-03