Page 1 of 1

CMDB Synch Pattern for 3 DB's

Posted: Thu Oct 15, 2020 11:27 am
by hudatolah

Code: Select all

tpl 1.5 module CMDB.Extension.Database_Augment_CTI;

metadata
    origin := 'bhs';
    tree_path := 'bhs','CMDB Sync','Database';
end metadata;

from CMDB.SoftwareInstance_SoftwareServer import SoftwareInstance_SoftwareServer 4.2;// edit  
from CMDB.Database import Database 2.3;

syncmapping Database_Augment 2.0
    """
    Update/Modify values for BMC_Database class
    This pattern has a dependency on:
    tpl 1.14 module AssetInfoFromSQL_Oracle
    tpl 1.14 module AssetInfoFromSQL_MSSQL 
    Please make sure to update versions and mappings should they change
    in relation to pattern DBSerialNumber 1.5
    """
    overview
        tags CMDB, Extension;
    end overview;

    mapping from Database.database_node as database_node
    end mapping;

    body
        database_ci := Database.database_ci;                           //Edit
        hosting_node := SoftwareInstance_SoftwareServer.hosting_node;  //Edit: Assign value to hosting_node

        //if database_node.type = "Oracle Database" or database_node.type = "SQL Server Database" then
		//Added teradata to if statement
		if database_node.type = "Oracle Database" or database_node.type = "SQL Server Database" or database_node.type = "Teradata Database" then		  
                   if database_node.serial then
			database_ci.SerialNumber := "%database_node.serial%";
                   end if;
	  end if;

sn := none;

         if database_node.type = "MongoDB Database" then
                        database_ci.ParentCITag := "%hosting_node.local_fqdn%";
			if database_node.name has substring '-MNG' then
				sn := regex.extract(database_node.name, regex'^(.*)-MNG(.*)$', raw'\2');
				database_ci.SerialNumber := "%sn%";
                        end if;
         end if;
    end body;
end syncmapping;