use bulk insert for bulk enqueue jobs
This commit is contained in:
6
Changes
6
Changes
@@ -1,3 +1,9 @@
|
||||
2.039011 - 2018-02-23
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
* use PG COPY for bulk insert of jobs with prefix
|
||||
|
||||
2.039010 - 2018-02-22
|
||||
|
||||
[NEW FEATURES]
|
||||
|
||||
@@ -110,6 +110,7 @@ if ($device and (!$net or $net->num == 0 or $net->addr eq '0.0.0.0')) {
|
||||
}
|
||||
|
||||
my @hostlist = defined $device ? ($net->hostenum) : (undef);
|
||||
my @job_specs = ();
|
||||
my $exitstatus = 0;
|
||||
|
||||
foreach my $host (@hostlist) {
|
||||
@@ -120,20 +121,23 @@ foreach my $host (@hostlist) {
|
||||
}
|
||||
|
||||
# what job are we asked to do?
|
||||
my %job_spec = (
|
||||
push @job_specs, {
|
||||
action => $action,
|
||||
device => $dev,
|
||||
port => $port,
|
||||
subaction => $extra,
|
||||
);
|
||||
|
||||
if ($queue_only) {
|
||||
jq_insert({ username => ($ENV{USER} || 'netdisco-do'), %job_spec });
|
||||
info sprintf '%s: queued at %s', $action, scalar localtime;
|
||||
next;
|
||||
username => ($ENV{USER} || 'netdisco-do'),
|
||||
};
|
||||
}
|
||||
|
||||
my $job = App::Netdisco::Backend::Job->new({ job => 0, %job_spec });
|
||||
if ($queue_only) {
|
||||
jq_insert( \@job_specs );
|
||||
info sprintf '%s: queued %s jobs at %s',
|
||||
$action, (scalar @job_specs), scalar localtime;
|
||||
}
|
||||
else {
|
||||
foreach my $spec (@job_specs) {
|
||||
my $job = App::Netdisco::Backend::Job->new({ job => 0, %$spec });
|
||||
|
||||
my $actiontext = (
|
||||
($job->device ? ('['.$job->device->ip.']') : '') .
|
||||
@@ -163,6 +167,7 @@ foreach my $host (@hostlist) {
|
||||
info sprintf '%s: status %s: %s', $action, $job->status, $job->log;
|
||||
$exitstatus = 1 if !$exitstatus and $job->status ne 'done';
|
||||
}
|
||||
}
|
||||
|
||||
exit $exitstatus;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user