1 Reply Latest reply on Feb 13, 2020 2:49 PM by Lisa Keeler

    Sync mapping assist

    Ryan Nicosia
      Share This:

      Working on a sync mapping to set a primary key of vCenterHost + InstanceID of the Discovered virtual machine.  I thought I had it licked but getting a "disco_machine" not set error in Sync logs so I'm sure I've fouled it up.

       

      mapping from VirtualMachine_VirtualSystemEnabler.vm_node as vm_node

            traverse InferredElement:Inference:Contributor:DiscoveredVirtualMachine as disco_machine

         traverse RunningSoftware:HostedSoftware:Host:Host as esx_host

          traverse ManagedElement:Management:Manager:SoftwareInstance as vcenter_si

      traverse RunningSoftware:HostedSoftware:Host:Host as vcenter_host

      end traverse;

      end traverse;

         end traverse;

        end traverse;

      end mapping;

       

          body

       

      vm_vse := VirtualMachine_VirtualSystemEnabler.vse;

       

      if (vm_vse = void) or (not vm_vse) then

                   stop;

          end if;

       

       

      for each disco_machine do

        for each esx_host do

         for each vcenter_si do

          for each vcenter_host do

       

             if vcenter_host.name then

          if disco_machine.instance_id then

      vm_vse.VMUUID := vcenter_host.name+disco_machine.instance_id;

      end if;

         end if;

         end for;

        end for;

        end for;

      end for;

        

      end body;

       

       

      end syncmapping;

        • 1. Re: Sync mapping assist
          Lisa Keeler

          Hi Ryan,

           

          Your pattern is not completely shown ...

           

          The base pattern is like this below, with the important line in bold.  And, the vm_node value you are trying to reference in red:

           

          syncmapping VirtualMachine_VirtualSystemEnabler 1.3

              """

              VirtualMachine mapped to VirtualSystemEnabler and related to

              contained ComputerSystems.

              """

              overview

                  tags CMDB, Core_Mapping;

                  datamodel 0, 1, 2, 3, 4, 5, 6;

              end overview;

           

              mapping from Host_ComputerSystem.host

                      from MFPart_ComputerSystem.mfpart

                      from CloudService_CloudInstance.cloud_svc

                      from NetworkDevice_ComputerSystem.device

                  as host

           

                traverse Host:HostedSoftware::VirtualMachine as vm_rel, vm_node

           

                      traverse Element:Maintainer:Pattern:Pattern as vm_pattern

                      end traverse;

           

                      vse -> BMC_VirtualSystemEnabler;

           

                      traverse HostContainer:HostContainment:ContainedHost: as contained_host

                          contained_cs -> BMC_ComputerSystem;

                      end traverse;

                  end traverse;

              end mapping;

           

          =================

          The traverse line containing 2 values after the "a" seems to be some newer syntax which I can't find to be documented:

          Syncmapping block - Documentation for BMC Discovery 11.3 - BMC Documentation

          "

          Mapping traversals

          The source subgraph is declared using traverse clauses inside the mapping with a syntax similar to traversals in search expressions:

          traverse traversal_specification as name traversal contents... end traverse 

          The name defined by the traversal can only be used in a for each expression; it cannot be used in any other context.

          "

          But, the syntax is discussed here:  Dual-named traversal in syncmapping pattern

          That posting tells me that vm_rel is a relationship and vm_node is the node ... obvious from the naming, I guess.

           

          I suppose you should be able to perform this traversal.

          =====================================

          Do you have results from this query?

          Search VirtualMachine traverse InferredElement:Inference:Contributor:DiscoveredVirtualMachine show summary

          I see we have results for that query on our internal test system.

          ===================================

          I would add some log.info or log.debug statements to show the value of vm_node, etc.

          And, then grep the transformer logs for your statements.

          Something like this:

          mapping from VirtualMachine_VirtualSystemEnabler.vm_node as vm_node

                traverse InferredElement:Inference:Contributor:DiscoveredVirtualMachine as disco_machine

                     traverse RunningSoftware:HostedSoftware:Host:Host as esx_host

                        traverse ManagedElement:Management:Manager:SoftwareInstance as vcenter_si

                            traverse RunningSoftware:HostedSoftware:Host:Host as vcenter_host

                            end traverse;

                        end traverse;

                     end traverse;

            end traverse;

          end mapping;

           

              body

           

                  vm_vse := VirtualMachine_VirtualSystemEnabler.vse;

                  log.info("RYAN 1: in the body.  vm_node = %vm_node% vm_vse = %vm_vse%");

           

           

                  if (vm_vse = void) or (not vm_vse) then

                      log.info("RYAN 2: Stopping.  vm_node = %vm_node% vm_vse = %vm_vse%");

                      stop;

                  end if;

           

                  log.info("RYAN 3: continuing in the body.  vm_node = %vm_node% vm_vse = %vm_vse%");

                  log.info("RYAN 4: disco_machine = %disco_machine%");

           

                  for each disco_machine do

                      log.info("RYAN 5: in the disco_machine loop  vm_node = %vm_node% vm_vse = %vm_vse%");

           

                      for each esx_host do

                          for each vcenter_si do

                              for each vcenter_host do

           

                                  if vcenter_host.name then

                                      if disco_machine.instance_id then

                                          vm_vse.VMUUID := "%vcenter_host.name%%disco_machine.instance_id%";

                                      end if;

             end if;

             end for;

            end for;

            end for;

          end for;

           

          end body;

          ====================================================

           

          Then, grep for your statements like this:

          grep "RYAN" /usr/tideway/log/*transformer*.log