In CMDB r12, how can we add Audit Logging to a custom Extension table?

Document ID : KB000053491
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

This document provides an example of how to do this in CMDB r12.
Later releases should have this documented in the product documentation.

Solution:

Implementation of Audit Logging on a Custom Extension Table:

  • Start CA Service Desk

  • Open WSP

  • Start the Web Schema Designer Tool

  • Click on "New Extension Table" button and add your new table

    • You MUST set a Function Group at this time
    • You MUST add the trigger below in the TRIGGERS section of the Advanced tab for Audit Logging

      POST_CI cmdb_write_audit_log @"@|spelsrvr|Interp_Obj|0"(
      "zcncx", id, last_mod_by, mdr_name, mdr_class, CHANGED_ONLY,
      "UI_INFO_ATTRS AUDITLOG") 99
      FILTER ( EVENT("INSERT UPDATE")
      );


  • Add your new columns to the new table

    • You MUST add the word AUDITLOG to the Site Defined UI_INFO field for auditing the attribute as auditing is required for versioning to work in CA CMDB.

  • Save and Publish the schema if you are sure that everything is complete.

  • Close and exit WSP

  • Shutdown CA CMDB Services/ServiceDesk services

  • Open a command prompt and run pdm_publish

  • Go to the new $NX_ROOT/site/mods/majic directory and open wsp.mods

  • In the ATTRIBUTES section of each new extension object definition you need to add the following two attributes which are not able to be defined through web screen painter:

    • LOCAL STRING;
    • LOCAL STRING;

  • Save and close the wsp.mods file

  • Start CA CMDB Services/ServiceDesk services

  • At the command prompt run bop_sinfo -df [FACTORY] where [FACTORY] = the name of the new table you just added. It should come back listing all of your new attributes including the mdr_class and mdr_name attributes.

  • Start WSP

  • Using the form cmdb_metadata_docx.htmpl as a template, open the file, and then do a "Save As" cmdb_metatdata_[FACTORY].htmpl. Again, substituting [FACTORY] with the name of your new table/factory that you created. So if I added a new extension FACTORY/Table of zcncx, the file would be named cmdb_metadata_zcncx.htmpl.

  • Do a global replace of docx with [FACTORY] in the newly saved htmpl file.

  • Replace any existing instances of attributes with the new attributes you added, where applicable.

  • Save and exit the form.

  • Using the form detail_docx.htmpl as a template, open the file, and then do a "Save As" detail_[FACTORY].htmpl. Again this would be detail_zcncx.htmpl to continue my example.

  • Do a global replacement of docx with [FACTORY] (I believe there will be fewer than 5 replacements on this form.

  • Near the last replacement done in step 18 there is a statement that looks similar to family.sym="Document", replace the word Document with the Family name you believe will reference this extension object. In the case of my example the family I plan to create to use this extension object is "CNC Machine".

  • Save and exit the form.

  • Using the form nr_cmdb_docx_tab.htmpl as a template, open the file and save the file as nr_cmdb_[FACTORY]_tab.htmpl.

  • Do a global replace of docx with your new [FACTORY] in the newly saved htmpl file.

  • Replace any existing instances of attributes with the new attributes you added, where applicable.

  • Save and Exit the form.

  • Publish the 3 new forms to the system, by select File|Publish in the WSP.

Validation Steps:

  • Log onto the CMDB using a CMDBAdmin level account

  • Go to the Administration Tab and open the CI Family leaf

  • Create a New Family giving it the sym value that you use in Implementation Step 22 above.

  • Create a New Class that uses the New Family you made in Testing Step 3.

  • Create a New CI that is based on the Class created in Testing Step 4.

  • Select the Attributes tab and see that your new attributes from the extension appear.

  • Populate the attributes and confirm that they save as expected.

  • Select the Versioning tab and see if the attributes appear in the list (will only happen if you populated the attributes), and make sure that the correct information.
    Create a Milestone and call it Baseline.

  • Go back and change some of the extension attributes and save the CI Detail form.

  • Select the Versioning Tab and see if the attributes appear in the list of changed attributes. Compare both the baseline and the new snapshot and confirm that all values are displaying properly.

Example final wsp.mods file based on the addition zcncx extension object.

////////////////////////////////////////////////////////////////////////
// File:      wsp.mods
// Publish Date: 01/12/2009 10:31 am
// Publish User: CMDBAdmin
// Description:
//   CA SD schema modifications maintained by Web Screen Painter.
////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////
// Factory:   zcncx
// Description: CNC Machine
////////////////////////////////////////////////////////////////////////
 
OBJECT zcncx {
  DISPLAY_NAME "zcncx";
  DISPLAY_GROUP "assetx";
  EXTENSION_OF nr;
  ATTRIBUTES zcncx {
    max_stock_len STRING 8 {UI_INFO "AUDITLOG";}; // Maximum Stock Length
    max_stock_rad STRING 8 {UI_INFO "AUDITLOG";}; // Maximum Stock Radius
    min_stock_len STRING 8 {UI_INFO "AUDITLOG";}; // Minimum Stock Length
    min_stock_rad STRING 8 {UI_INFO "AUDITLOG";}; // Minimum Stock Radius
    id              SREL nr;
    delete_flag del SREL actbool REQUIRED { ON_NEW DEFAULT 0; } ;
    creation_date   DATE { ON_NEW SET NOW; } ;
    creation_user   STRING { ON_NEW DEFAULT USER; } ;
    last_mod_dt creation_date   DATE { ON_NEW SET NOW; } ;
    last_mod_by creation_user   STRING { ON_NEW DEFAULT USER; } ;
    version_number  INTEGER { ON_CI INCREMENT 1; } ;
    mdr_class  LOCAL STRING ;
    mdr_name   LOCAL STRING ;
  };
 
  FACTORY zcncx {
    STANDARD_LISTS {
      MLIST OFF;
      RLIST OFF;
    };
    FUNCTION_GROUP "inventory";
    REL_ATTR id;
    COMMON_NAME max_stock_len;
  };
  METHODS {
    create_extension_copy( object, uuid, int );
  };
  TRIGGERS {
    POST_CI  cmdb_write_audit_log @"@|spelsrvr|Interp_Obj|0"( 
               "zcncx", id, last_mod_by, mdr_name, mdr_class, CHANGED_ONLY, 
                  "UI_INFO_ATTRS AUDITLOG") 99  
                  FILTER ( EVENT("INSERT UPDATE") 
                  );
  };
};
 
OBJECT nr {
  ATTRIBUTES usp_owned_resource SECONDARY {
      assoc_zcncx BREL zcncx id DYNAMIC { UI_INFO "dtlTextbox"; };
  };
};