fix bugs
This commit is contained in:
@@ -60,6 +60,7 @@ Find the best status and log it into the job's C<status> and C<log> slots.
|
||||
sub finalise_status {
|
||||
my $job = shift;
|
||||
my $max_level = Status->error()->level;
|
||||
# use DDP; p $job->_statuslist;
|
||||
|
||||
# fallback
|
||||
$job->status('error');
|
||||
@@ -85,6 +86,8 @@ C<done>.
|
||||
|
||||
sub check_passed {
|
||||
my $job = shift;
|
||||
return true if 0 == scalar @{ $job->_statuslist };
|
||||
|
||||
foreach my $status (@{ $job->_statuslist }) {
|
||||
next unless $status->phase and $status->phase eq 'check';
|
||||
return true if $status->is_ok;
|
||||
|
||||
@@ -3,8 +3,10 @@ package App::Netdisco::Worker::Plugin;
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin;
|
||||
|
||||
use Scope::Guard 'guard';
|
||||
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 {
|
||||
my ($self, $first, $second) = plugin_args(@_);
|
||||
@@ -25,7 +27,7 @@ register 'register_worker' => sub {
|
||||
$workerconf->{phase} ||= 'user';
|
||||
$workerconf->{namespace} ||= '_base_';
|
||||
$workerconf->{priority} ||= (exists $workerconf->{driver}
|
||||
? setting('driver_priority')->{$workerconf->{driver}} : 0);
|
||||
? (setting('driver_priority')->{$workerconf->{driver}} || 0) : 0);
|
||||
|
||||
my $worker = sub {
|
||||
my $job = shift or die 'missing job param';
|
||||
@@ -66,6 +68,7 @@ register 'register_worker' => sub {
|
||||
# back up and restore device_auth
|
||||
my $guard = guard { set(device_auth => \@userconf) };
|
||||
set(device_auth => \@newuserconf);
|
||||
# use DDP; p @newuserconf;
|
||||
|
||||
# run worker
|
||||
$code->($job, $workerconf);
|
||||
|
||||
@@ -3,8 +3,8 @@ package App::Netdisco::Worker::Runner;
|
||||
use Dancer qw/:moose :syntax/;
|
||||
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::Permission qw/check_acl_no check_acl_only/;
|
||||
use aliased 'App::Netdisco::Worker::Status';
|
||||
|
||||
use Try::Tiny;
|
||||
|
||||
Reference in New Issue
Block a user