8 Replies Latest reply on Jul 9, 2020 3:26 AM by Bernard Stern

    Automation of application mapping

    Ankush Deshmukh
      Share This:

      Hi Experts,


      Is there way to automate application map through TPL scripting instead of manual intervention.


      Requirement: Customer's application deployment team will set an APP ID in to registry for windows server and for linux server they will put at file at a certain location.

      So discovery need to read file from servers and should put values of APP ID into a custom attribute then by targeting APP ID values, BAI should create automatically.

      Basically customer is only targeting for servers and not focusing on software instance related to application. So please guide on  TPL scripting approach and is it possible via scripts and if yes, then will it be a dynamic or static model.


      Thank you

        • 1. Re: Automation of application mapping
          Ankush Deshmukh

          Andrew Waters could you please guide me on my requirement.

          • 2. Re: Automation of application mapping
            Lisa Keeler

            It is possible to create a BusinessApplicationInstance (BAI) node for a model using TPL discovery patterns, yes. (And, your pattern could trigger on finding a host with the APP ID that they are setting).


            However, I'm not sure if you can create a model without software.  Of course, you can try ... and test.  (Models were designed to have software).


            I don't think I have a sample TPL for creating a BAI.  But, some of BMC's consultants / professional services folks might have such a sample.

            Or, you might find one on this community somewhere.


            Someone such as Bob Anderson (BMC Consultant) might be able to help with a sample.

            And, of course, hiring a BMC consultant or professional services person would be helpful.

            1 of 1 people found this helpful
            • 3. Re: Automation of application mapping
              Ankush Deshmukh

              Thank you Lisa for the response....definitely I will test creating model without software instance.

              @Bob Anderson it will be really helpful for me if you provide sample TPL to map model.

              • 4. Re: Automation of application mapping
                Lisa Keeler

                Hi Ankush,




                You can test creating a CAM model, and then "Generate TPL" (using the button in the UI for the CAM model).

                Then, look at the generated pattern as a guideline for the pattern you would want to write.


                The generated TPL should be calling model.BusinessApplicationInstance() to create the BAI.

                And, it will call model.rel.* to create relationships.

                A CAM model always has a FunctionalComponent, but you probably don't have to have a FunctionalComponent in your model.


                Also, you can play with SAAM models just to see the kinds of relationships that exist between the BAI and the child nodes.

                A SAAM model can contain only Host nodes... so it can be very simple.  Play with that.

                You could probably replicate the essence of a SAAM model using the TPL.

                Of course, the nodes are the BAI and the Hosts.  But, what kind of relationship does Discovery create from the BAI to the Host?


                I created a quick SAAM model with only hosts, and I see that there is a "Software Containment" relationship between the BAI (saam_only_hosts_3) and the 3 Host nodes.

                So, that is how it is done in SAAM.

                1 of 1 people found this helpful
                • 5. Re: Automation of application mapping
                  Ankush Deshmukh

                  Thank you Lisa for the inputs it help me to visualise the solution I will try to create TPL.

                  • 6. Re: Automation of application mapping
                    Ankush Deshmukh

                    Hi Lisa


                    I am trying to map application via CAM including servers only but getting below error not able to generate TPL.


                    • 7. Re: Automation of application mapping
                      Lisa Keeler

                      CAM-created models must have software.  Hosts are part of the model only as a side-effect of having the software in the model.


                      So, if you start from a (host) Detail, you must traverse to some software, basically.

                      1 of 1 people found this helpful
                      • 8. Re: Automation of application mapping
                        Bernard Stern

                        We are mapping applications using CAM, most of the time we find running software.

                        Sometimes there is no running software (e.g. batch servers, servers used for script

                        trigger, etc). For these servers, we are creating a pseudo SI, since CAM requires

                        software instances. Here is the example pattern for windows servers, it can easily

                        be extended to other OSes.


                        pattern FlagFile 1.0


                          Map pseudo SI based on flag file Software Instance, e.g.



                          Supported Platforms:




                            publishers := 'Customer';

                            urls := 'https://www.customer.com';

                          end metadata;




                            tags Software_Instance_Model;

                          end overview;




                            flagdir := 'C:\\ProgramData\\AppMapping';

                          end constants;




                            on host := Host created, confirmed where type matches "Windows Server";

                          end triggers;




                           // Host and cluster information.

                            hosting_node := related.hostingNode(fallback_kind := "Cluster");

                            log.debug("Hostname: " + hosting_node.name);


                            si_key := '';

                            si_name := '';

                            si_type := 'Pseudo SI based on flag file';

                            si_short_type := 'PSEUDO-SI FLAGFILE';

                            si_short_name := si_short_type;


                            flagFileIDs := GenericFunctions.GetFlagFileIDs (host, flagdir);


                            // There are as many pseudo SIs based on a flag file as there are

                            // flag files found in the flagdir.

                            for flagFileID in flagFileIDs do


                              log.debug("FlagFile: flagFileID (instance) = %flagFileID%");

                              si_instance := flagFileID;


                              si_key  := "%si_instance%/%si_type%/%host.key%";

                              si_name := "%si_type% called %si_instance% on %host.name%";




                                key := si_key,

                                short_name := si_short_name,

                                name := si_name,

                                type := si_type,

                                instance := si_instance,



                            end for;


                          end body;


                        end pattern;


                        And here is the required function from the GenericFunctions module


                          define GetFlagFileIDs (host, flagdir) -> flagFileIDs


                            Purpose:    This function returns a list of all Flag File IDs in the flagdir

                                        directory matching the regex ^(?i)\d+\.txt, eg 889.txt or 889.TXT.

                            Parameters: - the host, which usually is the model.host(process). Mandatory.

                                        - flagdir, which is the directory containing the flag files. Mandatory.


                            Supported Platforms: Windows



                            // Initialise the list to empty list - no flagFileIDs found.

                            flagFileIDs := []; // list


                            filelist := discovery.listDirectory(host, flagdir);

                            if filelist then

                              log.debug("GetFlagFileIDs: discovery.listDirectory of %flagdir% succeeded");

                              for file in filelist do

                                log.debug("  discovered file name = %file.name%");

                                if file.name matches regex '^(?i)\d+\.txt$' then

                                  log.debug ("  file name (%file.name%) matches regex");

                                  flagFileID := regex.extract(file.name, regex '^(\d+)', raw '\1');

                                  log.debug("  extracted ID = %flagFileID%");

                                  flagFileIDs := flagFileIDs + ["%flagFileID%"];

                                  log.debug ("GetFlagFileIDs: stored flag file ID %flagFileID%");

                                end if;

                              end for;


                              log.debug("GetFlagFileIDs: FLAGDIR %flagdir% not found, not readable or empty, stop pattern run");


                            end if;

                            return flagFileIDs;


                          end define;

                        2 of 2 people found this helpful