#332 Autodiscovery via BGP and OSPF peers [skip ci]

This commit is contained in:
Oliver Gorwits
2018-02-01 11:24:40 +00:00
parent 9a3792595b
commit dec681a2d5
3 changed files with 48 additions and 0 deletions

View File

@@ -1,3 +1,9 @@
2.038035 - 2018-02-??
[NEW FEATURES]
* #332 Autodiscovery via BGP and OSPF peers
2.038034 - 2018-01-31
[NEW FEATURES]

View File

@@ -0,0 +1,41 @@
package App::Netdisco::Worker::Plugin::Discover::Neighbors::Routed;
use Dancer ':syntax';
use App::Netdisco::Worker::Plugin;
use App::Netdisco::Transport::SNMP;
use aliased 'App::Netdisco::Worker::Status';
use App::Netdisco::Util::Device qw/get_device is_discoverable/;
use App::Netdisco::JobQueue 'jq_insert';
register_worker({ phase => 'main', driver => 'snmp' }, sub {
my ($job, $workerconf) = @_;
my $device = $job->device;
return unless $device->in_storage and $device->has_layer(3);
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
or return Status->defer("discover failed: could not SNMP connect to $device");
my $ospf_peers = $snmp->ospf_peers || {};
my $bgp_peers = $snmp->bgp_peer_addr || {};
return Status->info("device $device has no BGP or OSPF peers")
unless ((scalar values %$ospf_peers) or (scalar values %$bgp_peers));
foreach my $ip ((values %$ospf_peers), (values %$bgp_peers)) {
my $peer = get_device($ip);
next if $peer->in_storage or not is_discoverable($peer);
jq_insert({
device => $ip,
action => 'discover',
subaction => 'with-nodes',
});
debug sprintf ' [%s] queued discovery of routing peer %s', $device, $ip;
}
return Status->info(" [$device] Routing peers added to discover queue.");
});
true;

View File

@@ -338,6 +338,7 @@ worker_plugins:
- 'Discover::CanonicalIP'
- 'Discover::Entities'
- 'Discover::Neighbors'
- 'Discover::Neighbors::Routed'
- 'Discover::PortPower'
- 'Discover::Properties'
- 'Discover::VLANs'