2 Replies Latest reply on Feb 9, 2018 9:13 AM by Shane Smith

    CMDB Extentions

    John Adamopoulos

      Hello,

       

      With the template_cmdb_hostname_override.tpl I am trying to uniform the HostName, name, shortdescription, TokenId, in general to alter hosts information within CMDB.

       

      Currently I am able to log.debug my actions within tw_svc_cmdbsync_transformer file (log.debug()), but i am not able to perform any actual changes within CMDB.

       

      Also I am not able to locate the variable that contains "Language_Keyboard" which is a Field in the "Other" section of my Host.

       

      Is there a way to know the actual Discovery and CMDB naming fields in tlp?

       

      Please find below my code.

       

      Can you help me making this work and understand fields naming?

       

      Best Regards.

       

      John Adamopoulos

       

      1 // This is a template pattern module containing a CMDB syncmapping

      2 // that overrides the HostName attribute of BMC_ComputerSystem so it

      3 // never contains a dot.

      4 //

      5 // Text prefixed with // like these lines are comments that extend to

      6 // the end of the line.

      7 //

      8 // This pattern is in the public domain.

      9

      10 tpl 1.5 module CMDB.Extension.Host_Name_Override;

      11

      12 from CMDB.Host_ComputerSystem import Host_ComputerSystem 2.0;

      13

      14 syncmapping Host_Name_Override 1.0

      15    """

      16   Override the default ComputerSystem HostName and TokenId to take

      17   only the first component of compound dot-separated hostnames.

      18   """

      19    overview

      20    tags CMDB, Extension;

      21    end overview;

      22

      23    mapping from Host_ComputerSystem.host as host

      24    // No additional structure -- we are just modifying the

      25    // existing ComputerSystem CI.

      26    end mapping;

      27

      28    body

      29   computersystem := Host_ComputerSystem.computersystem;

      30

      31 name := computersystem.Name;

      32 //Set Language_Keyboard to Description

      33 shortdescription := computersystem.Language_Keyboard;

      34 log.debug("shortdescription is now %computersystem.Language_Keyboard%");

      35   hostname := computersystem.HostName;

      36 log.debug("CI name is %name%");

      37   log.debug("CI hostname is %hostname%");

      38   hostname := hostname + "123";

      39   log.debug("CI New hostname123 is %hostname%");

      40    if name has substring "." then

      41 log.debug("old name is %name%");

      42 name := computersystem.HostName +"123";

      43 log.debug("New name123 is %name%");

      44    // Modify the HostName to only include content up to the first dot

      45  

      46 //computersystem.HostName := text.split(hostname, ".")[0];

      47

      48    // If TokenId is the "standard" HostName:Domain format,

      49    // modify it with the new HostName.

      50    if computersystem.TokenId = "%hostname%:%host.dns_domain%" then

      51   log.debug("The old TokenId is %computersystem.TokenId%");

      52   computersystem.TokenId := "%computersystem.HostName%:%host.dns_domain%";

      53 log.debug("The New TokenId is %computersystem.TokenId%");

      54    end if;

      55

      56    end if;

      57  

      58    end body;

      59

      60 end syncmapping;

      61

        • 1. Re: CMDB Extentions
          Shane Smith

          1. Discovery Field names can be found in the taxonomy for OOB items or you can view the desired node and then hover over the attribute name and it will display the field name. CMDB field names are either in other TPL scripts or you would have to look in the CMDB if example is not available.

          2. If the item in the 'Other' section is a link to something, then it is connected to another node.  So if in the other section (from the Host view), it might say "Details" and then have a link.  In this case, the Language_Keyboard would be a detail node and a relationship exists between the host node and the detail node.  I don't see Language_Keyboard in the OOB taxonomy so that may be a customization added in your system. In this case, you would need to follow the relationship to the detail node.

          2 of 2 people found this helpful
          • 2. Re: CMDB Extentions
            Duncan Grisby

            If you want to change a CI's values, you need to specifically set the values on the CI. That is what the template you have edited does. Notice the line you commented out:

             

                computersystem.HostName := text.split(hostname, ".")[0];

             

            It is setting the HostName attribute inside computersystem (which is the CI). Your code:

             

                shortdescription := computersystem.Language_Keyboard;

             

            That is just setting a local variable called "shortdescription". You have not asked to change a CI at all. computersystem here is the CI -- you are reading a value from the mapped CI data. If you are trying to get an attribute out of the Discovery Host node, you need host.language_keyboard.

             

            Seeing "Language_Keyboard" in he "Other" section on the Discovery Host page means that it has been set by a custom pattern. Exactly what the attribute is really called depends on what the custom pattern did. Hover the mouse over the label and it will give you a tooltip that tells you what the actual attribute name is.

            1 of 1 people found this helpful