I am using the Subnet_To_Location tpl as seen here in this forum. I am running into an interesting and probably easy to solve issue. We have hosts with multiple IPs assigned to each and the hosts wont map unless ALL Subnets on the hosts are added to the relation table. This creates yet another interesting issue because our heartbeat networks (virtual – 192.168.WHATEVER) may be the same at two different locations making my mapping near impossible to complete.
EXAMPLE:
Host X has two interfaces 10.9.0.5 - belonging to subnet 10.9.0.0/20
10.10.0.5 - belonging to subnet 10.10.0.0/20
Location wont map unless BOTH subnets are in the table.
Excerpt from tpl:
450 subnet_list := search(in host traverse DeviceWithInterface:DeviceInterface:InterfaceOfDevice:NetworkInterface
451 traverse DeviceOnSubnet:DeviceSubnet:Subnet:Subnet);
452 location_id := ‘’;
453 list_size := size(subnet_list);
454 log.debug(“Subnet_2_Locations: subnet_list size is %list_size%”);
455
456 for subnet_node in subnet_list do
457 log.debug(“Subnet_2_Locations: Current subnet_node is %subnet_node.ip_address_range%”);
458
459 // if subnet_node is “None” get next node otherwise we can use this one
460 if ‘%subnet_node.ip_address_range%’ <> “None” then
461 location_id:= ‘%subnet_node.ip_address_range%’;
462 break;
463 end if;
464 end for;
465
466 log.debug(“Subnet_2_Locations: location ID is %location_id%”);
467
468
469 // Look up the location name from the table
470 location_name := Subnet2Location[location_id];
471 log.debug(“Subnet_2_Locations: location is %location_name%”);
472
473 if not location_name then
474 // Unknown location
475 log.info(“Subnet_2_Locations: Unknown location”);
476 stop;
477 end if;
478
479 // Find the Location node(s) for the location
480 location := search(Location where name = ‘%location_name%’);
481 if not location then
482 // No node for this location?
483 // We create the Location node at this point as an alternative to stopping
484 loc := model.Location(name := location_name, key := location_name);
485 log.info(“Subnet_2_Locations: Location node created for %location_name%”);
486 else
487 log.debug(“Subnet_2_Locations: Location is found”);
488 end if;
489
490 // Relate host to location. Using “uniquerel” rather than “rel” means that
491 // any existing Location relationships between this Host (the first
492 // parameter) and any Location nodes other than the one given (the second
493 // parameter) are removed. If a host has changed location, this keeps the
494 // model up-to-date.
495 log.info(“Subnet_2_Locations: model.uniquerel.Location %host% %location%”);
496 model.uniquerel.Location(
497 ElementInLocation := host,
498 Location := location
499 );
500 end body;
Is there a way to change the code in the tpl to say when ANY of the interfaces have this subnet, it will be set to X location?
Thanks
