change community_rw to be array ref
This commit is contained in:
@@ -18,15 +18,8 @@ newdaemon(
|
|||||||
logpriority => 'daemon.info',
|
logpriority => 'daemon.info',
|
||||||
);
|
);
|
||||||
|
|
||||||
sub gd_preconfig {
|
# do not remove - must be redefined
|
||||||
my $self = shift;
|
sub gd_preconfig { return () }
|
||||||
|
|
||||||
# FIXME: only for Actions should this be checked
|
|
||||||
$self->gd_error("No read-write community string has been set.")
|
|
||||||
unless length setting('community_rw');
|
|
||||||
|
|
||||||
return (); # important
|
|
||||||
}
|
|
||||||
|
|
||||||
sub gd_run_body {
|
sub gd_run_body {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
@@ -48,7 +41,11 @@ sub gd_run_body {
|
|||||||
next unless $self->lock_job($job);
|
next unless $self->lock_job($job);
|
||||||
|
|
||||||
# do job
|
# do job
|
||||||
my ($status, $log) = $self->$target($job);
|
my ($status, $log);
|
||||||
|
try {
|
||||||
|
($status, $log) = $self->$target($job);
|
||||||
|
}
|
||||||
|
catch { warn "error running job: $_\n" };
|
||||||
|
|
||||||
# revert to queued status if we failed to action the job
|
# revert to queued status if we failed to action the job
|
||||||
if (not $status) {
|
if (not $status) {
|
||||||
|
|||||||
@@ -39,11 +39,8 @@ sub _set_device_generic {
|
|||||||
return error("Verify of $slot update failed on [$ip]: $new_data");
|
return error("Verify of $slot update failed on [$ip]: $new_data");
|
||||||
}
|
}
|
||||||
|
|
||||||
# get device details from db
|
|
||||||
my $device = get_device($ip)
|
|
||||||
or return error("Updated $slot on [$ip] to [$data] but failed to update DB");
|
|
||||||
|
|
||||||
# update netdisco DB
|
# update netdisco DB
|
||||||
|
my $device = get_device($ip);
|
||||||
$device->update({$slot => $data});
|
$device->update({$slot => $data});
|
||||||
|
|
||||||
return done("Updated $slot on [$ip] to [$data]");
|
return done("Updated $slot on [$ip] to [$data]");
|
||||||
|
|||||||
@@ -40,12 +40,8 @@ sub portcontrol {
|
|||||||
return error("Verify of [$pn] port status failed on [$ip]: $state");
|
return error("Verify of [$pn] port status failed on [$ip]: $state");
|
||||||
}
|
}
|
||||||
|
|
||||||
# get device details from db
|
|
||||||
my $device = $port->device
|
|
||||||
or return error("Updated [$pn] port status on [$ip] but failed to update DB");
|
|
||||||
|
|
||||||
# update netdisco DB
|
# update netdisco DB
|
||||||
$device->update({up_admin => $state});
|
$port->device->update({up_admin => $state});
|
||||||
|
|
||||||
return done("Updated [$pn] port status on [$ip] to [$state]");
|
return done("Updated [$pn] port status on [$ip] to [$state]");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,11 +107,8 @@ sub snmp_connect {
|
|||||||
Debug => ($ENV{INFO_TRACE} || 0),
|
Debug => ($ENV{INFO_TRACE} || 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
(my $comm = setting('community_rw')) =~ s/\s+//g;
|
|
||||||
my @communities = split /,/, $comm;
|
|
||||||
|
|
||||||
my $info = undef;
|
my $info = undef;
|
||||||
COMMUNITY: foreach my $c (@communities) {
|
COMMUNITY: foreach my $c (@{ setting('community_rw') || []}) {
|
||||||
try {
|
try {
|
||||||
$info = SNMP::Info->new(%snmp_args, Community => $c);
|
$info = SNMP::Info->new(%snmp_args, Community => $c);
|
||||||
last COMMUNITY if (
|
last COMMUNITY if (
|
||||||
|
|||||||
Reference in New Issue
Block a user