6 Replies Latest reply on Apr 18, 2017 2:12 AM by Andrew Waters

    pattern fails to create/update location.

    Mohmmad Meftahi

      I created this pattern using one that was posted here, modifying to use first 3 character of host name. after importing and activation, ran this manually against a group in debug mode. there is no change to location filed and do not get any details/error.

      // This is a template pattern module containing a pattern for relating Hosts

      // to Locations based on hostname.


      // Names surrounded by double dollar signs like $$pattern_name$$ should all be

      // replaced with values suitable for the pattern.


      // 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 HostLocationSHCorpDC;



      // This table is used to find location names (i.e. the "name" attribute on

      // Location nodes) by looking up a location id extracted from host names

      // (e.g. "lon"). Of course, this approach relies on your organisation using

      // a scheme like this.


      table LocationIdToNameHofTr 1.0


        "ent" -> "CorpDC";

        "hfd" -> "Hoffman";

        "hfp" -> "Hoffman";

        "hof" -> "Hoffman";

        "try" -> "Troy";

        "trd" -> "Troy";

        "trp" -> "Troy";

        "ust" -> "Troy";


        // Arrange that any value that is lookup up for which there isn't an entry

        // is given as the none value.

        default -> none;


      end table;



      pattern HostToLocationHofTr 2.0


        This is a template pattern for linking Hosts to Locations based on hostname.

        Supported Platforms:

        Windows ,Linux ,AIX ,SUN ,UNIX

        Change History:

        2017-02-06 -



        // Required overview section. Some tags must be defined.


          tags DC,Location;

        end overview;


        // We trigger whenever a Host is created for the first time, or confirmed on

        // a subsequent discovery run.



          on host := Host created, confirmed;

        end triggers;



          // Extract location id from the host name. e.g. to extract the first two

          // characters, use a regular expression of "^(..)".


          location_id := host.name[:3];


          // Look up the location name from the table

          location_name := LocationIdToNameHofTr[location_id];


          if not location_name then


          end if;



          // Find the Location node(s) for the location

          location := search(Location where name = %location_name%);


          if not location then

            // No node for this location?


          end if;


          // Relate host to location. Using "uniquerel" rather than "rel" means that

          // any existing Location relationships between this Host (the first

          // parameter) and any Location nodes other than the one given (the second

          // parameter) are removed. If a host has changed location, this keeps the

          // model up-to-date.



            ElementInLocation := host,

            Location := location



        end body;


      end pattern;