1 2 Previous Next 16 Replies Latest reply on Oct 11, 2017 11:11 AM by Young So

    SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL

    Greg Nevel

      Working on my first override mapping TPL to allow better viewing of SoftwareComponents mapped to the CMDB.

      Things work as expected with the exception of Microsoft IIS Web Applications and Microsoft IIS FTP Applications.

       

      Discovery 11.0.0.1

      My TPL:

       

      tpl 1.11 module CMDB.Extension.SoftwareComponent_ApplicationService_Name_Override;
      metadata
          origin := "TYS Custom Mapping";
          tree_path := "BMC Discovery Operation", "TYS Custom CMDB Override", "BMC_ApplicationService", "SoftwareComponent -> ApplicationService";
      end metadata;
      from CMDB.Host_ComputerSystem                  import Host_ComputerSystem 2.0;
      from CMDB.MFPart_ComputerSystem                import MFPart_ComputerSystem 2.0;
      from CMDB.SoftwareInstance_SoftwareServer      import SoftwareInstance_SoftwareServer 4.0;
      from CMDB.SoftwareInstance_ApplicationSystem   import SoftwareInstance_ApplicationSystem 1.0;
      from CMDB.SoftwareCluster_Cluster              import SoftwareCluster_Cluster 1.0;
      from CMDB.SoftwareComponent_ApplicationService import SoftwareComponent_ApplicationService 3.1;
      syncmapping SoftwareComponent_ApplicationService_Name_Override 1.00
          """
          Override the default ShortDescription values for BMC_ApplicationService CIs.
          """
      
          overview
              tags CMDB, Extension;
        overrides SoftwareComponent_ApplicationService;
          end overview;
      
          mapping from SoftwareInstance_SoftwareServer.softwareinstance
                  from SoftwareInstance_ApplicationSystem.softwareinstance
                  from SoftwareCluster_Cluster.softwarecluster
              as softwareinstance
              traverse SoftwareContainer:SoftwareContainment:ContainedSoftware:SoftwareComponent as component
                  appservice -> BMC_ApplicationService;
              end traverse;
          end mapping;
          body
              computersystem := Host_ComputerSystem.computersystem or
                                MFPart_ComputerSystem.computersystem;
              sw_ci := SoftwareCluster_Cluster.cluster_ci or
                       SoftwareInstance_ApplicationSystem.applicationsystem or
                       SoftwareInstance_SoftwareServer.softwareserver;
              is_cluster := SoftwareCluster_Cluster.cluster_ci or none;
              for each component do
                  // ApplicationServiceType can come from the component or
                  // defaults to Unknown.
                  as_type := component.cdm_application_service_type or 1;
                  hashed_key := text.hash(component.key);
                  appservice := sync.shared.BMC_ApplicationService(
                      key                    := component.key,
                      TokenId                := "ADDM:%hashed_key%",
                      Name                   := component.name,
                     //Out of the box TPL is ShortDescription := component.name
                      ShortDescription       := component.instance,
                      Description            := component.name,
                      Model                  := component.type,
                      VersionNumber          := component.version,
                      ApplicationServiceType := as_type,
                      Company                := computersystem.Company,
                      Category               := "Software",
                      Type                   := "Application Service",
                      Item                   := "BMC Discovered"
                  );
                  // BMC_ApplicationSystemServices is used between
                  // BMC_SoftwareServer or BMC_ApplicationSystem and the
                  // BMC_ApplicationService; it is not valid with BMC_Cluster,
                  // so in that case we use the more general BMC_Component
                  // relationship.
                  if is_cluster then
                      sync.rel.BMC_Component(
                          Source          := sw_ci,
                          Destination     := appservice,
                          Impacted        := appservice,
                          Name            := "CLUSTERSERVICES"
                      );
                  else
                      sync.rel.BMC_ApplicationSystemServices(
                          Source          := sw_ci,
                          Destination     := appservice,
                          Impacted        := appservice,
                          Name            := "APPLICATIONSYSTEMSERVICES"
                      );
                  end if;
              end for;
          end body;
      end syncmapping;
      

       

      CMDB sync error message:

       

       

      Failed update of BMC_ApplicationService:Microsoft IIS Web Application / on Default Web Site : ERROR (326): Required field cannot be blank.; BMC.CORE:BMC_ApplicationService : ShortDescription,

      BMC_ApplicationService:Microsoft IIS FTP Application / on hostname : ERROR (326): Required field cannot be blank.; BMC.CORE:BMC_ApplicationService : ShortDescription

       

      I believe the issue is that the patterns: "IISWebserver_WebApp_SCs" and "IISFTPserver_WebApp_SCs" doesn't use 'instance' as part of the model

        • 1. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
          Duncan Grisby

          That is an extremely over-complicated way to achieve what you want. There is no need to replicate all the content of the base mapping just to change a single attribute. You can do it with an extension mapping, rather than overriding the base mapping and providing your own copy. Overrides are only required if you want to fundamentally change the shape of the mapped data.

           

          As you say, the cause of the error is that some SoftwareComponent nodes don't have an instance attribute. There's no promise that they will have that attribute.

           

          This much simpler extension mapping sets the ShortDescription as you want, but only if instance is set:

           

          tpl 1.11 module CMDB.Extension.SoftwareComponent_ApplicationService_Name_Override;

           

          metadata 

              origin := "TYS Custom Mapping"; 

              tree_path := "BMC Discovery Operation", "TYS Custom CMDB Override", "BMC_ApplicationService", "SoftwareComponent -> ApplicationService"; 

          end metadata;

           

          from CMDB.SoftwareComponent_ApplicationService import SoftwareComponent_ApplicationService 3.1;

           

          syncmapping SoftwareComponent_ApplicationService_Name_Override 1.00 

              """

              Override the default ShortDescription values for

              BMC_ApplicationService CIs.

              """ 

              overview 

                  tags CMDB, Extension; 

              end overview;

           

              mapping from SoftwareComponent_ApplicationService.component as component

              end mapping;

           

              body

                  appservice := SoftwareComponent_ApplicationService.appservice;

           

                  if component.instance then

                      appservice.ShortDescription := component.instance;

                  end if;

           

              end body;

           

          end syncmapping;

          2 of 2 people found this helpful
          • 2. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
            Greg Nevel

            Thanks Duncan. Much easier!!

            Misinterpretation of the documentation on my part.

            • 3. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
              Greg Nevel

              I want to be able to utilize either the discovered instance OR the discovered short_name.

              Is this the best way to accomplish this?

              tpl 1.11 module CMDB.Extension.SoftwareComponent_ApplicationService_ShortDescription;
               
              metadata  
                  origin := "TYS Custom CMDB Extension Mapping";  
                  tree_path := "BMC Discovery Operation", "TYS Custom CMDB Extension", "BMC_ApplicationService.ShortDescription", "SoftwareComponent -> ApplicationService";  
              end metadata;
               
              from CMDB.SoftwareComponent_ApplicationService import SoftwareComponent_ApplicationService 3.1;
               
              syncmapping SoftwareComponent_ApplicationService_Name_Extension 1.00
                  """ 
                  Extend the default BMC_ApplicationService.ShortDescription value to
                  the discovered software components instance or short_name as opposed 
               to the SC name.
                  """  
                  overview  
                      tags CMDB, Extension; 
                  end overview;
               
                  mapping from SoftwareComponent_ApplicationService.component as component
                  end mapping;
               
                  body
                      appservice := SoftwareComponent_ApplicationService.appservice;
                
                if component.instance then
                 appservice.ShortDescription := component.instance;
                
                elif component.short_name then
                 appservice.ShortDescription := component.short_name;
                end if;
                  end body;
               
              end syncmapping;
              
              • 4. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                Duncan Grisby

                Yes, that's the right way to do it.

                 

                An alternative that avoids the cascade of if expressions would be to use an "or" expression to pick the first value that is set:

                 

                appservice.ShortDescription := component.instance or component.short_name or component.name;

                2 of 2 people found this helpful
                • 6. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                  ROMULO SUBTIL

                  Hi Duncan,

                   

                  I'm in the same situation that Greg, but I'm trying to concatenate the computersystem.Name with the appservice.Name and appservice.Description, just to all SoftwareComponent that doesn't have the computersystem.Name in it name. This will help me to solve some kind os issues on CMDB, where I have more than one Microsoft IIS component with the same name in different hosts on my environment. In this case, all that CIs with the same name in different hosts never can be reconciliated to my gold dataset on CMDB.

                   

                  To solve this issue I perform a customized pattern, as you show us in previously post, but after a discovery run on ADDM tool, no one field was updated on CMDB during the syncmapping. In some cases, the CI was marked to be deleted on CMDB and no one field was updated.

                   

                  Do you know what is happening?

                   

                  Capture.PNG

                   

                  Regards,

                  • 7. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                    Brice-Emmanuel Loiseaux

                    I can't see an obvious problem in this syncmapping. You might want to add some logs here and check attribute values you use

                    • 8. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                      ROMULO SUBTIL

                      Hi Brice,

                       

                      I'm sory my question, but what kind of logs that I have to add?

                      • 9. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                        Brice-Emmanuel Loiseaux

                        Some Log functions - BMC Discovery 11.0 - BMC Documentation like

                         

                        log.info("Processing SoftwareComponent %component.name%");

                         

                        or

                         

                        log.debug("CS name: %computersystem.Name%");

                        log.debug("extracted hostname: %hostName%");

                         

                        in various places in your tpl, to understand what's going on.

                        • 10. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                          Andrew Waters

                          Your regex is wrong. You have told regex.extract to get the first group but your regex has no groups. You would need regex '(\w+)' to get a group.

                          2 of 2 people found this helpful
                          • 11. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                            Duncan Grisby

                            As a general piece of advice, don't use log.debug if you are trying to diagnose a problem!  Messages with log.debug only appear if you put the logging into debug mode, and then you drown in all the standard debug logging. If you are developing patterns or syncmappings and you want to find your log messages easily, use log.error. That means they stand out clearly. Just remember to change the messages to log.info or log.debug once you've finished debugging.

                            • 12. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                              ROMULO SUBTIL

                              Hi Andrew,

                               

                              Thanks for the tip, I had success with the syncmapping to CMDB according the adjustment that you proposed on my TPL.

                               

                              Capture.PNG

                              • 13. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                                George Klarmann

                                Hi Greg,

                                 

                                Just did something like this. Here's another way to get the instances and a little extra by stripping the type off of the name.

                                 

                                body

                                        appservice := SoftwareComponent_ApplicationService.appservice;

                                      

                                        if component.name then

                                                 componentType := component.type;

                                                 newName := regex.extract(component.name, expand(regex '%componentType% (.*$)', componentType), raw '\1');

                                                 appservice.ShortDescription := newName;

                                        end if;

                                end body;

                                • 14. Re: SoftwareComponent_ApplicationService ShortDescription override sync mapping TPL
                                  Young So
                                  tpl 1.6 module CMDB.Extension.SoftwareComponent_ApplicationService_attribute_Override;
                                  
                                  metadata 
                                      origin := "CMDB Extension Mapping";
                                      tree_path := "eBay", "eBay Discovery Operation", "CMDB Extension", "BMC_ApplicationService -> Attribute";
                                      //origin := "eBay Custom Mapping"; 
                                      //tree_path := "BMC Discovery Operation", "eBay Custom CMDB Override", "BMC_ApplicationService", "SoftwareComponent -> ApplicationService"; 
                                  end metadata;
                                  
                                   from CMDB.Host_ComputerSystem import Host_ComputerSystem 1.2;
                                   from CMDB.SoftwareComponent_ApplicationService import SoftwareComponent_ApplicationService 3.1;
                                  
                                  
                                  
                                  syncmapping SoftwareComponent_ApplicationService_Attribute_Extension 1.00  
                                      """  
                                      Extend the default BMC_ApplicationService.Attribute value to 
                                      the discovered software components instance or short_name as opposed  
                                   to the SC name. 
                                      """      
                                     
                                      mapping from SoftwareComponent_ApplicationService.component as component  
                                      end mapping;  
                                     
                                      body  
                                          appservice := SoftwareComponent_ApplicationService.appservice;
                                          computersystem := Host_ComputerSystem.computersystem
                                  
                                  
                                              hostName := "";
                                              hostName := regex.extract (computersystem.name, regex '(\w+)', raw '\1');
                                      
                                            if component.instance matches hostName then  
                                              stop;  
                                              
                                            else    
                                             appservice.Name := "%component.name% on %hostName%";
                                             appservice.Description := "%component.name%" running on %hostName%";
                                            end if;  
                                      end body;  
                                     
                                  end syncmapping;
                                  

                                   

                                  Copy and paste version of ROMULO SUBTIL's code.

                                  1 2 Previous Next