Skip to content

Commit

Permalink
should defer SNMP against pseudo devices
Browse files Browse the repository at this point in the history
  • Loading branch information
ollyg committed Sep 1, 2019
1 parent 897ba3a commit b108be5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/App/Netdisco/Transport/SNMP.pm
Expand Up @@ -58,8 +58,12 @@ Returns C<undef> if the connection fails.
sub reader_for {
my ($class, $ip, $useclass) = @_;
my $device = get_device($ip) or return undef;
return undef if $device->in_storage
and $device->vendor and $device->vendor eq 'netdisco';

my $readers = $class->instance->readers or return undef;
return $readers->{$device->ip} if exists $readers->{$device->ip};

debug sprintf 'snmp reader cache warm: [%s]', $device->ip;
return ($readers->{$device->ip}
= _snmp_connect_generic('read', $device, $useclass));
Expand Down Expand Up @@ -104,8 +108,12 @@ Returns C<undef> if the connection fails.
sub writer_for {
my ($class, $ip, $useclass) = @_;
my $device = get_device($ip) or return undef;
return undef if $device->in_storage
and $device->vendor and $device->vendor eq 'netdisco';

my $writers = $class->instance->writers or return undef;
return $writers->{$device->ip} if exists $writers->{$device->ip};

debug sprintf 'snmp writer cache warm: [%s]', $device->ip;
return ($writers->{$device->ip}
= _snmp_connect_generic('write', $device, $useclass));
Expand Down

0 comments on commit b108be5

Please sign in to comment.