Keep a hint to SNMP community if new style snmp_auth config is in use
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
* Require SNMP::Info 3.10+, use new c_cap method to tag device remote_type
|
* Require SNMP::Info 3.10+, use new c_cap method to tag device remote_type
|
||||||
as 'IP Phone:' or 'AP:' when those capabilities are advertised by LLDP
|
as 'IP Phone:' or 'AP:' when those capabilities are advertised by LLDP
|
||||||
or CDP
|
or CDP
|
||||||
* Port MAC query now only returns distinct MAC's
|
* Port MAC query now only returns distinct MAC's
|
||||||
|
* Keep a hint to SNMP community if new style snmp_auth config is in use
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
entries (Robert Kerr)
|
entries (Robert Kerr)
|
||||||
* [#60] Incorrect format string in store_vlans (Robert Kerr)
|
* [#60] Incorrect format string in store_vlans (Robert Kerr)
|
||||||
* Fix form reset icon on ports tab when using custom path (Daniel Tuecks)
|
* Fix form reset icon on ports tab when using custom path (Daniel Tuecks)
|
||||||
|
* Don't store failed SNMP community in the database
|
||||||
|
|
||||||
2.020002 - 2013-12-11
|
2.020002 - 2013-12-11
|
||||||
|
|
||||||
|
|||||||
@@ -544,7 +544,6 @@ sub delete {
|
|||||||
my $devices = $self->search(undef, { columns => 'ip' });
|
my $devices = $self->search(undef, { columns => 'ip' });
|
||||||
|
|
||||||
foreach my $set (qw/
|
foreach my $set (qw/
|
||||||
Community
|
|
||||||
DeviceIp
|
DeviceIp
|
||||||
DeviceVlan
|
DeviceVlan
|
||||||
DevicePower
|
DevicePower
|
||||||
@@ -555,6 +554,15 @@ sub delete {
|
|||||||
)->delete;
|
)->delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$schema->resultset('Community')->search({
|
||||||
|
ip => { '-in' => $devices->as_query },
|
||||||
|
snmp_auth_tag => undef,
|
||||||
|
})->delete;
|
||||||
|
|
||||||
|
$schema->resultset('Community')->search(
|
||||||
|
{ ip => { '-in' => $devices->as_query } },
|
||||||
|
)->update({snmp_comm_rw => undef});
|
||||||
|
|
||||||
$schema->resultset('Admin')->search({
|
$schema->resultset('Admin')->search({
|
||||||
device => { '-in' => $devices->as_query },
|
device => { '-in' => $devices->as_query },
|
||||||
action => { '-like' => 'queued%' },
|
action => { '-like' => 'queued%' },
|
||||||
|
|||||||
@@ -162,47 +162,38 @@ sub _try_connect {
|
|||||||
sub _try_read {
|
sub _try_read {
|
||||||
my ($info, $device, $comm) = @_;
|
my ($info, $device, $comm) = @_;
|
||||||
|
|
||||||
undef $info unless (
|
return undef unless (
|
||||||
(not defined $info->error)
|
(not defined $info->error)
|
||||||
and defined $info->uptime
|
and defined $info->uptime
|
||||||
and ($info->layers or $info->description)
|
and ($info->layers or $info->description)
|
||||||
and $info->class
|
and $info->class
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($device->in_storage) {
|
if ($comm->{community}) {
|
||||||
# read strings are tried before writes, so this should not accidentally
|
$device->in_storage
|
||||||
# store a write string if there's a good read string also in config.
|
? $device->update({snmp_comm => $comm->{community}})
|
||||||
$device->update({snmp_comm => $comm->{community}})
|
: $device->set_column(snmp_comm => $comm->{community});
|
||||||
if exists $comm->{community};
|
|
||||||
$device->update_or_create_related('community',
|
|
||||||
{snmp_auth_tag => $comm->{tag}}) if $comm->{tag};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$device->set_column(snmp_comm => $comm->{community})
|
|
||||||
if exists $comm->{community};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# regardless of device in storage, save the hint
|
||||||
|
$device->update_or_create_related('community',
|
||||||
|
{snmp_auth_tag => $comm->{tag}}) if $comm->{tag};
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _try_write {
|
sub _try_write {
|
||||||
my ($info, $device, $comm) = @_;
|
my ($info, $device, $comm) = @_;
|
||||||
|
|
||||||
# SNMP v1/2 R/W must be able to read as well (?)
|
my $loc = $info->load_location;
|
||||||
$info = _try_read($info, $device, $comm)
|
$info->set_location($loc) or return undef;
|
||||||
if exists $comm->{community};
|
return undef unless ($loc eq $info->load_location);
|
||||||
return unless $info;
|
|
||||||
|
|
||||||
$info->set_location( $info->load_location )
|
# one of these two cols must be set
|
||||||
or return undef;
|
$device->update_or_create_related('community', {
|
||||||
|
($comm->{tag} ? (snmp_auth_tag => $comm->{tag}) : ()),
|
||||||
if ($device->in_storage) {
|
($comm->{community} ? (snmp_comm_rw => $comm->{community}) : ()),
|
||||||
# one of these two cols must be set
|
});
|
||||||
$device->update_or_create_related('community', {
|
|
||||||
($comm->{tag} ? (snmp_auth_tag => $comm->{tag}) : ()),
|
|
||||||
(exists $comm->{community} ? (snmp_comm_rw => $comm->{community}) : ()),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
@@ -255,7 +246,7 @@ sub _build_communities {
|
|||||||
if defined $device->snmp_comm and $mode eq 'read';
|
if defined $device->snmp_comm and $mode eq 'read';
|
||||||
|
|
||||||
# first try last-known-good
|
# first try last-known-good
|
||||||
push @communities, {read => 1, write => 1, community => $snmp_comm_rw}
|
push @communities, {write => 1, community => $snmp_comm_rw}
|
||||||
if $snmp_comm_rw and $mode eq 'write';
|
if $snmp_comm_rw and $mode eq 'write';
|
||||||
|
|
||||||
# new style snmp config
|
# new style snmp config
|
||||||
@@ -303,7 +294,6 @@ sub _build_communities {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
push @communities, map {{
|
push @communities, map {{
|
||||||
read => 1,
|
|
||||||
write => 1,
|
write => 1,
|
||||||
community => $_,
|
community => $_,
|
||||||
}} @{setting('community_rw') || []};
|
}} @{setting('community_rw') || []};
|
||||||
|
|||||||
Reference in New Issue
Block a user