5 Replies Latest reply on Dec 6, 2019 1:20 AM by Andrew Waters

    Send location as an attribute to the CMDB

    Lucas David Ferreira da Costa
      Share This:

      Hi, is there any way to send the location as an attribute to the CMDB. Our intention is to use the same logic of the template_cmdb_location pattern but not to create a new CI, but to send it as an attribute of the CMDB, for example computersystem.Building. Is this possible?

       

      This is the pattern we are using:

       

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

      // that creates BMC_PhysicalLocation CIs and relates them to

      // BMC_ComputerSystem CIs.

      //

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

      // the end of the line.

      //

      // This pattern is in the public domain.

       

       

      tpl 1.5 module CMDB.Extension.Host_Location;

       

       

      from CMDB.Host_ComputerSystem import Host_ComputerSystem 2.0;

       

       

      syncmapping Host_Location 1.0

          """

          Populate BMC_PhysicalLocation and relate to BMC_ComputerSystem.

          """

          overview

              tags CMDB, Extension;

          end overview;

       

       

          mapping from Host_ComputerSystem.host as host

              traverse ElementInLocation:Location:Location:Location as location

        

              end traverse;

       

       

          end mapping;

       

       

          body

              computersystem := Host_ComputerSystem.computersystem;

       

       

              for each location do

                

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

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

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

                  if location.key then

                      key := location.key;

      computersystem.Building := location.key;

                  else

                      key := location.name;

      computersystem.Building := location.name;

                  end if;

       

       

                

                

              end for;

       

       

          end body;

       

       

      end syncmapping;

       

      Thank you very much in advance.