NAME
App::Netdisco::Util::Node
DESCRIPTION
A set of helper subroutines to support parts of the Netdisco application.
There are no default exports, however the :all tag will export all subroutines.
EXPORT_OK
check_mac( $node, $device?, $port_macs? )
Given a MAC address, perform various sanity checks which need to be done before writing an ARP/Neighbor entry to the database storage.
Returns false, and might log a debug level message, if the checks fail.
Returns a true value (the MAC address in IEEE format) if these checks pass:
MAC address is well-formed (according to common formats)
MAC address is not all-zero, broadcast, CLIP, VRRP or HSRP
Optionally pass a Device instance or IP to use in logging.
Optionally pass a cached set of Device port MAC addresses as the third argument, in which case an additional check is added:
MAC address does not belong to an interface on any known Device
is_nbtstatable( $ip )
Given an IP address, returns true if Netdisco on this host is permitted by the local configuration to nbtstat the node.
The configuration items nbtstat_no and nbtstat_only are checked against the given IP.
Returns false if the host is not permitted to nbtstat the target node.
memoize_arp ( \%host )
Returns a unique string to memoize the arp entry, using node or mac keys, the ip key and the VRF (an absent VRF reads as the empty string).
store_arp( \%host, $now?, $device_ip )
Stores a new entry to the node_ip table with the given MAC, IP (v4 or v6) and DNS host name. Host details are provided in a Hash ref:
{
ip => '192.0.2.1',
node => '00:11:22:33:44:55',
dns => 'myhost.example.com',
}
The dns entry is optional. The update will mark other active entries for this IP in the same VRF as no longer active.
Optionally a literal string can be passed in the second argument for the time_last timestamp, otherwise the current timestamp (LOCALTIMESTAMP) is used.
On which L3 devices an arp entry was found is tracked in the seen_on_router_first and seen_on_router_last fields of the node_ip. They contain a timestamp for the time window each router this entry was ever found on.
record_cli_vrfs( $device, \%vrf_read, $list_complete, $now )
Records in device_vrf each named VRF a CLI collector read (the keys of \%vrf_read, netdisco names, '' skipped), so that it gets an L3 domain when SNMP::Info does not list it. Rows are listed_by cli and written only when new, so a row discover wrote keeps its facts. When the collector's list was whole, the device's cli rows for VRFs it no longer read are deleted; other rows never are. Domains are recomputed when anything changed. Returns the number of rows inserted or deleted.
retire_unvouched_arps( $device, $now, \%vrf_read?, $vrf_list_complete? )
After a complete arpnip of $device, deactivates the active node_ip rows this router was the last to report (router_last) and did not report in this run (time_last before $now, the timestamp given to store_arp). Rows another router reported since name that router and stay; rows with no router_last are never matched.
With VRF collection off for the device (vrf_collection_enabled in App::Netdisco::Util::VRF), only rows in named VRFs are retired, never the default table. With it on and %vrf_read (VRF name to 1 for a complete read, 0 for an incomplete one), the VRFs retired are those read whole, those skipped (vrf_no_devicevrfs), and, only when $vrf_list_complete is 1, those the run did not read at all; a VRF read short is never retired. With it on but no %vrf_read (an SSH or offline job, or a class without VRF support) nothing is retired.
Returns the number of rows deactivated.