release 2.012005
Squashed commit of the following: commit a031e3f388af144cb6d729e4b16b174a7caf6de9 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:50:55 2013 +0100 new version - 2.012005 commit a0215a83fb2cd9f3040cfd04e239a1a40367e056 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:47:28 2013 +0100 set last arpnip timestamp commit 824d311a2503cc91a117d4cc5949b0aca0cabdc9 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:28:14 2013 +0100 test release - 2.012003_001 commit d06316eb1ae6a035a2fefd1edd06bfa6ffe38fa8 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 17:26:44 2013 +0100 Improved handling of automatic macsuck/arpnip after initial discover commit d7c1e7948f22487c0564a884ce94d109a2cdc13c Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 13:21:51 2013 +0100 add rev. proxy timeout to suggested config commit 040065a50fec4669740ae48ff18352ef7ff3fde1 Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 13:14:15 2013 +0100 remove done job from local queue regardless of exit status commit d0f1d105459c047cc7156d1b4ef897ad27f965bb Author: Oliver Gorwits <oliver@cpan.org> Date: Fri Aug 16 13:12:45 2013 +0100 fix no_auth to work with new Auth::Extensible plugin
This commit is contained in:
@@ -5,7 +5,7 @@ use Dancer::Plugin::DBIC 'schema';
|
||||
|
||||
use base 'Exporter';
|
||||
our @EXPORT = ();
|
||||
our @EXPORT_OK = qw/ add_jobs capacity_for take_jobs reset_jobs /;
|
||||
our @EXPORT_OK = qw/ add_jobs capacity_for take_jobs reset_jobs scrub_jobs /;
|
||||
our %EXPORT_TAGS = ( all => \@EXPORT_OK );
|
||||
|
||||
schema('daemon')->deploy;
|
||||
@@ -69,10 +69,17 @@ sub take_jobs {
|
||||
|
||||
sub reset_jobs {
|
||||
my ($wid) = @_;
|
||||
debug "resetting jobs owned by worked $wid to be available";
|
||||
debug "resetting jobs owned by worker $wid to be available";
|
||||
return unless $wid > 1;
|
||||
$queue->search({wid => $wid})
|
||||
->update({wid => 0});
|
||||
}
|
||||
|
||||
sub scrub_jobs {
|
||||
my ($wid) = @_;
|
||||
debug "deleting jobs owned by worker $wid";
|
||||
return unless $wid > 1;
|
||||
$queue->search({wid => $wid})->delete;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -79,6 +79,9 @@ sub close_job {
|
||||
finished => $now,
|
||||
});
|
||||
}
|
||||
|
||||
# remove job from local queue
|
||||
$self->do('scrub_jobs', $self->wid);
|
||||
}
|
||||
catch { $self->sendto('stderr', "error closing job: $_\n") };
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ sub discoverall {
|
||||
device => $_,
|
||||
action => 'discover',
|
||||
status => 'queued',
|
||||
username => $job->username,
|
||||
userip => $job->userip,
|
||||
}} ($devices->all)
|
||||
]);
|
||||
});
|
||||
@@ -43,12 +45,13 @@ sub discoverall {
|
||||
return job_done("Queued discover job for all devices");
|
||||
}
|
||||
|
||||
# queue a discover job for one device, and its *new* neighbors
|
||||
# run a discover job for one device, and its *new* neighbors
|
||||
sub discover {
|
||||
my ($self, $job) = @_;
|
||||
|
||||
my $host = NetAddr::IP::Lite->new($job->device);
|
||||
my $device = get_device($host->addr);
|
||||
my $jobqueue = schema('netdisco')->resultset('Admin');
|
||||
|
||||
if ($device->ip eq '0.0.0.0') {
|
||||
return job_error("discover failed: no device param (need -d ?)");
|
||||
@@ -72,6 +75,33 @@ sub discover {
|
||||
store_modules($device, $snmp);
|
||||
discover_new_neighbors($device, $snmp);
|
||||
|
||||
# if requested, and the device has not yet been arpniped/macsucked, queue now
|
||||
if ($device->in_storage and $job->subaction and $job->subaction eq 'with-nodes') {
|
||||
if (!defined $device->last_macsuck) {
|
||||
schema('netdisco')->txn_do(sub {
|
||||
$jobqueue->create({
|
||||
device => $device->ip,
|
||||
action => 'macsuck',
|
||||
status => 'queued',
|
||||
username => $job->username,
|
||||
userip => $job->userip,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (!defined $device->last_arpnip) {
|
||||
schema('netdisco')->txn_do(sub {
|
||||
$jobqueue->create({
|
||||
device => $device->ip,
|
||||
action => 'arpnip',
|
||||
status => 'queued',
|
||||
username => $job->username,
|
||||
userip => $job->userip,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return job_done("Ended discover for ". $host->addr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user