From: Eric M. <er...@je...> - 2007-06-27 02:58:31
|
Sam Stickland wrote: > OK, the problem is related to SNMP::Info::root_ip. The device in > question is running EIGRP so there is no router-id to speak of, but it > has a loopback address. root_ip doesn't seem to be returning the > Loopback address. It's probably returning undef causing the code to > stick to the original IP address. You are correct, SNMP::Info::root_ip will determine a consistent IP to use. The problem in these discussions in the past is trying to determine a consistent address to pick which will not change over time due to reboots or device configuration changes. If we can determine a user defined loopback address this is a good option. In fact both the Passport and BayRS classes look for these interfaces and will use it as the root_ip if found. The Passport class probably has the most extensive check for root_ip using an algorithm which returns the first found: CLIP (CircuitLess IP or loopback), Management Virtual IP, OSPF Router ID, SONMP Advertised IP Address, or undefined if nothing else found. There will still be devices which have multiple IP addresses for which we won't be able to pick a consistent IP address. > Currently store_device uses root_ip to determine which IP address to use > for the device table entry. This works when root_ip works. If root_ip is > giving up then we end up with multiple entries in the device table for > the same device, depending on which IP address was discovered. The IP is the primary key for the device table which makes sense since it is what we want to use to connect with SNMP to the device. However, an IP address is not guaranteed to be unique within a network or stay static over time representing the same device. We may have instances where the same IP's are aliases within multiple devices on the network. An example would be devices which ship with a default IP on CPU ports so that they can be configured via IP before deployment. These default IP's may not interfere with normal operation and SNMP may pick them up if they aren't removed. There are too many of these conditions to try and code for all of them in SNMP::Info. Another concern would be a network reconfiguration where an IP is moved from one device to another. So, if we wanted to compare the given connect IP to all device IP's and aliases and use an existing device in the database if one exists, I think it may require a more complex algorithm than may be apparent. Before we changed the IP from an alias IP to a device IP we would need some validation that we are really talking to the same device. > If we switch IP at the point when we detect an alias we ensure there's > only ever one entry in the database even if root_ip isn't working > correctly. This means replacing this code in get_device: > > # Check to see if device is in database > my $ip = &getip($hostname); > my $dev_ip = &root_device($ip); > > # Warn if we are usiutng an alias > if (defined $dev_ip and $dev_ip ne $ip){ > print "! $ip is an alias of $dev_ip.\n"; > $dev_ip = undef; > } > > With this code: > > # Check to see if device is in database > my $ip = &getip($hostname); > my $dev_ip = &root_device($ip); > > # Warn if we are using an alias > if (defined $dev_ip and $dev_ip ne $ip){ > print "! $ip is an alias of $dev_ip.\n"; > $ip = $dev_ip; > } > Not sure how this change will help. If we don't try to use cached credentials the connect uses the passed argument $hostname, $ip is not used later in the subroutine. Eric |