2 Replies Latest reply on Feb 26, 2018 10:36 AM by Jeremy Schlosky

    Syncmapping hostcontainer pattern problem

    Jeremy Schlosky

      I built a pattern that relates the location of contained hosts to the hostcontainer. Now I'm trying to get that relationship pushed into the Remedy CMDB which I have successfully done.

       

      My problem is that for items that don't have HostContainers, I am see the following error caused by my syncmapping pattern in CMDB Sync page in Discovery :

       

      EventTimeMessage
      2b650e531351246183f3ea696e486f7374 (webserver01): Error occurred during transformation2018-02-23 14:15:14User error in extension 'CMDB.Extension.HostContainer_Location.HostContainer_Location': CMDB.Extension.HostContainer_Location.HostContainer_Location:33: CMDB.HostContainer_ComputerSystem.HostContainer_ComputerSystem.container_cs not found

       

       

      Here's the pattern code and as you can see, line 33 is the culprit. I know there has to be a way to test of check before running but I'm finding syncmapping patterns more challenging to debug than other patterns where you can run them against a group and watch log.debug messages.

       

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

      2 // that creates BMC_PhysicalLocation CIs and relates them to

      3 // BMC_ComputerSystem CIs.

      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.HostContainer_Location;

      11

      12 from CMDB.HostContainer_ComputerSystem import HostContainer_ComputerSystem 2.0;

      13

      14 syncmapping HostContainer_Location 1.0

      15    """

      16   Populate BMC_PhysicalLocation and relate to BMC_ComputerSystem.

      17   """

      18    overview

      19    tags CMDB, Extension;

      20    end overview;

      21

      22    mapping from HostContainer_ComputerSystem.host as host

      23    traverse ElementInLocation:Location:Location:Location as location

      24  

      25 phys_loc -> BMC_PhysicalLocation;

      26

      27    end traverse;

      28

      29    end mapping;

      30

      31    body

      32

      33   computersystem := HostContainer_ComputerSystem.container_cs;

      34

      35    for each location do

      36   

      37    // BMC Discovery Location nodes created by patterns have a key

      38    // attribute, but those created in the UI do not. We use

      39    // the name attribute if the key is not present.

      40    if location.key then

      41   key := location.key;

      42    else

      43   key := location.name;

      44    end if;

      45

      46    // Specify the BMC_PhysicalLocation CI. You may wish to

      47    // add more attributes to the BMC Discovery Location node and copy

      48    // them across here.

      49   phys_loc := sync.shared.BMC_PhysicalLocation(

      50   key := key,

      51   Name := location.name,

      52   ShortDescription := location.name,

      53   Description := location.description,

      54   Address := location.address,

      55   Category := "Reference Configuration",

      56   Type := "Facilities",

      57   Item := "Space Management"

      58   );

      59   

      60    // Relate the BMC_ComputerSystem to the new BMC_PhysicalLocation

      61   sync.rel.BMC_ElementLocation(

      62   Source := computersystem,

      63   Destination := phys_loc,

      64   Name := "ELEMENTLOCATION"

      65   );

      66   

      67    end for;

      68

      69    end body;

      70

      71 end syncmapping;