BMC Atrium Discovery Community Forum

forgot password?
   
 
Subnet to Location
Posted: 01 February 2012 03:57 PM   [ Ignore ]  
RankRank
Member
Total Posts:  24
Joined:  2011-07-26

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

Profile
 
 
Posted: 01 February 2012 04:36 PM   [ Ignore ]   [ # 1 ]  
BMC ADDM Staff
RankRankRankRank
Administrator
Total Posts:  876
Joined:  2008-02-12

You need something like:

location_name := "";

for 
subnet_node in subnet_list do
    
log.debug("Subnet_2_Locations: Current subnet_node is %subnet_node.ip_address_range%");

    
// Check if an IP address and that have a location.

    
if subnet_node.ip_address_range and
       
subnet_node.ip_address_range in Subnet2Location then
        location_name 
:= Subnet2Location[subnet_node.ip_address_range];
        break;
    
end if;
end for;

if 
not location_name then
    log
.info("Subnet2Locations: Unknown location");
    
stop;
end if;

log.debug("Subnet2Locations: location is %location_name%"); 
Profile
 
 
Posted: 01 February 2012 04:42 PM   [ Ignore ]   [ # 2 ]  
RankRank
Member
Total Posts:  24
Joined:  2011-07-26

Im guessing that reading the table first and matching from the subnets within the host information for each node will either produce (no matter how many addresses there are, even if only one of its subnets are listed) or go unknown.

If it works, this will be a major breakthrough for my environment as I will be able to have a much smaller list of subnets in the table and relate with just 1 IP per system as opposed, in some cases, to 40 IPs on a system.

Thanks

Profile