14 Replies Latest reply on Jul 31, 2017 5:22 AM by Rajat Jain

    Dual Location Value Required

    Rajat Jain
      Share This:

      Hello Everyone,

       

      I am able to successfully map location to every host on basis of subnet. But I want to map 2 different values (one for DataCenter and another for Building Location) in ADDM. I tried to modify the pattern but I am not able to activate it as it is giving error (Location1 is not a function). Please suggest.

       

      The patterns used by me are as follows:

       

      OLD PATTERN (Successfully able to discover single location value):

      ----------------------------------------------------------------------------------------------

       

      // Pattern to build model in ADDM.

      tpl 1.5 module HostToLocation;

      // Map subnet to location

      table SubnetToLocation 1.0

      '10.x.x.x./25' -> 'BLDG No ABC';

      '10.x.x.x./24' -> 'BLDG No ABC1';

      '10.x.x.x./24' -> 'BLDG No ABC2';

      .

      .

      .

      end table;

      pattern HostLocation 1.0

           '''Pattern to determine and record location of a host.'''

      overview

           tags Extension;

      end overview;

      triggers

           on host := Host created, confirmed;

      end triggers;

      body

              // Get the list of subnets.

       

              subnets := search(in host traverse DeviceWithAddress:DeviceAddress:IPv4Address:IPAddress

                                        traverse DeviceOnSubnet:DeviceSubnet:Subnet:Subnet

                                        show ip_address_range);

       

              for subnet in subnets do

                  if subnet in SubnetToLocation then

                      // Found a location. Ensure we have a Location node.

       

                      location      := SubnetToLocation[subnet];

                      location_node := model.Location(key  := text.hash(location),

                                                      name := location);

       

                      // Relation host to location using uniquerel to ensure single location.

       

                      model.uniquerel.Location(ElementInLocation := host,

        Location := location_node); 5346

                      stop;

                  end if;

              end for;

       

          end body;

       

      end pattern;

       

       

       

       

      NEW PATTERN (Not able to activate):

      ----------------------------------------------------------------------------------------------

       

      // Pattern to build model in ADDM.

      tpl 1.5 module HostToLocation;

      // Map subnet to location

      table SubnetToLocation 1.0

      '10.x.x.x./25' -> 'BLDG No ABC';

      '10.x.x.x./24' -> 'BLDG No ABC1';

      '10.x.x.x./24' -> 'BLDG No ABC2';

      .

      .

      .

      end table;

       

      table SubnetToLocation1 1.0

      '10.x.x.x./25' -> 'BLDG No ABC';

      '10.x.x.x./24' -> 'BLDG No ABC1';

      '10.x.x.x./24' -> 'BLDG No ABC2';

      .

      .

      .

      end table;

       

      pattern HostLocation 1.0

           '''Pattern to determine and record location of a host.'''

      overview

           tags Extension;

      end overview;

      triggers

           on host := Host created, confirmed;

      end triggers;

      body

              // Get the list of subnets.

       

              subnets := search(in host traverse DeviceWithAddress:DeviceAddress:IPv4Address:IPAddress

                                        traverse DeviceOnSubnet:DeviceSubnet:Subnet:Subnet

                                        show ip_address_range);

       

              for subnet in subnets do

                  if subnet in SubnetToLocation then

                      // Found a location. Ensure we have a Location node.

       

                      location      := SubnetToLocation[subnet];

                      location_node := model.Location(key  := text.hash(location),

                                                      name := location);

       

      location1      := SubnetToLocation1[subnet];

                      location1_node := model.Location1(key  := text.hash(location),

                                                      name := location1);

       

                      // Relation host to location using uniquerel to ensure single location.

       

                      model.uniquerel.Location(ElementInLocation := host,

        Location := location_node); 5346

                      stop;

                  end if;

              end for;

          end body;

      end pattern;

       

       

      Please suggest.

       

       

      Regards,

      Rajat Jain

       

        • 1. Re: Dual Location Value Required
          Andrew Waters

          The name are model is a node kind, so model.Location is building a Location node. You cannot just invent new node kinds.

           

          Would you not be better served to have a single Location node with includes both data centre and building?

          • 2. Re: Dual Location Value Required
            Rajat Jain

            I have already tested that. But, in our CMDB, there are 2 fields for Location and the management wants it to be in same way. To push the location in same format, we have to create 2 values for location in ADDM.

             

            Any suggestions....

            • 3. Re: Dual Location Value Required
              Andrew Waters

              I don't see how that follows. You have a Location node with both values not two Location nodes.

              1 of 1 people found this helpful
              • 4. Re: Dual Location Value Required
                Rajat Jain

                Hmmm.. let me take this with my Management. If, there is no option available, I can't do much with it

                 

                Thanks for your prompt response Andrew !!!

                • 5. Re: Dual Location Value Required
                  Shane Smith

                  Couldn't you do this by having the Building Location be the parent of the Datacenter Location?

                  • 6. Re: Dual Location Value Required
                    Rajat Jain

                    If that can be done, it is very helpful for me. Please let me know how to do that.

                    • 7. Re: Dual Location Value Required
                      Andrew Waters

                      If you feel you have to but it adds another level of complication. Though I would have thought it would normally be the other way around. Having multiple building in a datacenter.

                       

                      You just have to add a relationship between Location nodes rather than having both in related to the Host.

                      building := SubnetToBuilding[subnet];

                      building_node := model.Location(key := text.hash(building),

                                                                           name := building);

                      model.uniquerel.Location(ElementInLocation := host,

                                                               Location := building_node);

                       

                      datacenter := SubnetToDatacenter[subnet];

                      datacenter_node := model.Location(key := text.hash(datacenter),

                                                                               name := datacenter);

                      model.uniquerel.Location(ElementInLocation := building_node,

                                                                Location := datacenter_node);

                      Plus whatever handling you need when building or datacenter is not found. You would obviously need to extend the syncmappings to handle the nested locations.

                      1 of 1 people found this helpful
                      • 8. Re: Dual Location Value Required
                        Rajat Jain

                        I am getting following error for all the nodes when tried the above mentioned script:

                         

                        4985): 193220ms: RuleError on rule tpl_HostLocation_body_0 due to: Error in action tpl.model.ensure_unique_related_nodes -- AttributeError: 'str' object has no attribute 'getKind'

                        https://10.134.169.8/ui/NodeView?nodeID=21af5d59e1428231058651ec6e486f7374

                        • 9. Re: Dual Location Value Required
                          Andrew Waters

                          Sorry - it should be building_node and datacenter_node in both model.uniquerel.Location calls, so comes from just trying stuff directly in the forum. Updated.

                          • 10. Re: Dual Location Value Required
                            Rajat Jain

                            Tried following code, but same error:

                             

                             

                            building := SubnetToBuilding[subnet];

                             

                            building_node := model.Location(key := text.hash(building),

                             

                                                                                 name := building);

                             

                            model.uniquerel.Location(ElementInLocation := host,

                             

                                                                     Location := building_node);

                             

                            datacenter := SubnetToDatacenter[subnet];

                             

                            datacenter_node := model.Location(key := text.hash(datacenter),

                             

                                                                                     name := datacenter);

                            model.uniquerel.Location(ElementInLocation := building,

                             

                                                                     Location := datacenter_node);

                            • 11. Re: Dual Location Value Required
                              Andrew Waters

                              You did not update building to building_node in the final model.uniquerel.Location

                              • 12. Re: Dual Location Value Required
                                Rajat Jain

                                The value is still not reflecting anywhere... Please let me know if I am not able to see it at correct place or TPL is not working

                                • 13. Re: Dual Location Value Required
                                  Andrew Waters

                                  Sorry - wrong relationship for it to be shown. The taxonomy says you would need

                                  model.uniquerel.LocationContainment(ContainedLocation := building_node,

                                                                                                LocationContainer := datacenter_node);

                                  then you should be able to see the datacenter Location on the building Location node.

                                  2 of 2 people found this helpful
                                  • 14. Re: Dual Location Value Required
                                    Rajat Jain

                                    Great!!! It worked...

                                     

                                    I just make

                                    model.uniquerel.LocationContainment(ContainedLocation := building_node,

                                                                                                  LocationContainer := datacenter_node);

                                     

                                    and it is working.

                                     

                                    Thanks Andrew....