This commit is contained in:
Oliver Gorwits
2017-11-08 20:29:33 +00:00
parent 1eeaba441d
commit e0c6615c87
3 changed files with 9 additions and 3 deletions

View File

@@ -60,6 +60,7 @@ Find the best status and log it into the job's C<status> and C<log> slots.
sub finalise_status { sub finalise_status {
my $job = shift; my $job = shift;
my $max_level = Status->error()->level; my $max_level = Status->error()->level;
# use DDP; p $job->_statuslist;
# fallback # fallback
$job->status('error'); $job->status('error');
@@ -85,6 +86,8 @@ C<done>.
sub check_passed { sub check_passed {
my $job = shift; my $job = shift;
return true if 0 == scalar @{ $job->_statuslist };
foreach my $status (@{ $job->_statuslist }) { foreach my $status (@{ $job->_statuslist }) {
next unless $status->phase and $status->phase eq 'check'; next unless $status->phase and $status->phase eq 'check';
return true if $status->is_ok; return true if $status->is_ok;

View File

@@ -3,8 +3,10 @@ package App::Netdisco::Worker::Plugin;
use Dancer ':syntax'; use Dancer ':syntax';
use Dancer::Plugin; use Dancer::Plugin;
use Scope::Guard 'guard';
use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/; use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/;
use aliased 'App::Netdisco::Worker::Status';
use Scope::Guard 'guard';
register 'register_worker' => sub { register 'register_worker' => sub {
my ($self, $first, $second) = plugin_args(@_); my ($self, $first, $second) = plugin_args(@_);
@@ -25,7 +27,7 @@ register 'register_worker' => sub {
$workerconf->{phase} ||= 'user'; $workerconf->{phase} ||= 'user';
$workerconf->{namespace} ||= '_base_'; $workerconf->{namespace} ||= '_base_';
$workerconf->{priority} ||= (exists $workerconf->{driver} $workerconf->{priority} ||= (exists $workerconf->{driver}
? setting('driver_priority')->{$workerconf->{driver}} : 0); ? (setting('driver_priority')->{$workerconf->{driver}} || 0) : 0);
my $worker = sub { my $worker = sub {
my $job = shift or die 'missing job param'; my $job = shift or die 'missing job param';
@@ -66,6 +68,7 @@ register 'register_worker' => sub {
# back up and restore device_auth # back up and restore device_auth
my $guard = guard { set(device_auth => \@userconf) }; my $guard = guard { set(device_auth => \@userconf) };
set(device_auth => \@newuserconf); set(device_auth => \@newuserconf);
# use DDP; p @newuserconf;
# run worker # run worker
$code->($job, $workerconf); $code->($job, $workerconf);

View File

@@ -3,8 +3,8 @@ package App::Netdisco::Worker::Runner;
use Dancer qw/:moose :syntax/; use Dancer qw/:moose :syntax/;
use Dancer::Factory::Hook; use Dancer::Factory::Hook;
use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/;
use App::Netdisco::Util::Device 'get_device'; use App::Netdisco::Util::Device 'get_device';
use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/;
use aliased 'App::Netdisco::Worker::Status'; use aliased 'App::Netdisco::Worker::Status';
use Try::Tiny; use Try::Tiny;