From cd71a0b7a80bd5b7b27f0a95e4ebc1b51277c0b6 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 5 Sep 2017 20:41:05 +0100 Subject: [PATCH] move status update to job class --- lib/App/Netdisco/Backend/Job.pm | 15 +++++++++++++++ lib/App/Netdisco/Worker/Runner.pm | 2 +- lib/App/Netdisco/Worker/Status.pm | 13 ------------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/App/Netdisco/Backend/Job.pm b/lib/App/Netdisco/Backend/Job.pm index 9b09fa2e..d0066a06 100644 --- a/lib/App/Netdisco/Backend/Job.pm +++ b/lib/App/Netdisco/Backend/Job.pm @@ -55,6 +55,21 @@ sub summary { # ($job->subaction ? (q{'}. $job->subaction .q{'}) : ''); } +=head2 update_status + +Passed an L will update this job's C and +C slots. + +=cut + +sub update_status { + my $job = shift; + my $status = shift or return; + $job->status( $status->status ); + $job->log( $status->log ); + return $job; +} + =head1 ADDITIONAL COLUMNS =head2 extra diff --git a/lib/App/Netdisco/Worker/Runner.pm b/lib/App/Netdisco/Worker/Runner.pm index fa78e922..28d2ac84 100644 --- a/lib/App/Netdisco/Worker/Runner.pm +++ b/lib/App/Netdisco/Worker/Runner.pm @@ -22,7 +22,7 @@ has 'jobstat' => ( after 'run', 'run_workers' => sub { my $self = shift; - $self->jobstat->update_job($self->job); + $self->job->update_status($self->jobstat); }; # mixin code to run workers loaded via plugins diff --git a/lib/App/Netdisco/Worker/Status.pm b/lib/App/Netdisco/Worker/Status.pm index c5e1626f..d6efa105 100644 --- a/lib/App/Netdisco/Worker/Status.pm +++ b/lib/App/Netdisco/Worker/Status.pm @@ -67,17 +67,4 @@ sub status { ); } -=head2 update_job - -Updates an L with status and log. - -=cut - -sub update_job { - my $self = shift; - my $job = shift or return; - $job->status( $self->status ); - $job->log( $self->log ); -} - 1;