hack the status class to regen if needed
This commit is contained in:
@@ -63,7 +63,7 @@ sub run {
|
|||||||
|
|
||||||
# run 00init primary
|
# run 00init primary
|
||||||
$self->run_workers("nd2worker_${action}_00init_primary");
|
$self->run_workers("nd2worker_${action}_00init_primary");
|
||||||
return $self->jobstat if $self->jobstat->not_ok;
|
return if $self->jobstat->not_ok;
|
||||||
|
|
||||||
# run each 00init worker
|
# run each 00init worker
|
||||||
$self->run_workers("nd2worker_${action}_00init");
|
$self->run_workers("nd2worker_${action}_00init");
|
||||||
@@ -73,8 +73,6 @@ sub run {
|
|||||||
|
|
||||||
# run each worker
|
# run each worker
|
||||||
$self->run_workers($_) for (@phase_hooks);
|
$self->run_workers($_) for (@phase_hooks);
|
||||||
|
|
||||||
return $self->jobstat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_workers {
|
sub run_workers {
|
||||||
@@ -83,7 +81,7 @@ sub run_workers {
|
|||||||
|
|
||||||
my $store = Dancer::Factory::Hook->instance();
|
my $store = Dancer::Factory::Hook->instance();
|
||||||
$store->hook_is_registered($hook)
|
$store->hook_is_registered($hook)
|
||||||
or return Status->error("no such hook: $hook");
|
or return $self->jobstat->error("no such hook: $hook");
|
||||||
|
|
||||||
foreach my $worker (@{ $store->get_hooks_for($hook) }) {
|
foreach my $worker (@{ $store->get_hooks_for($hook) }) {
|
||||||
try {
|
try {
|
||||||
@@ -91,7 +89,7 @@ sub run_workers {
|
|||||||
# could die or return undef or a scalar or Status or another class
|
# could die or return undef or a scalar or Status or another class
|
||||||
$self->jobstat($retval) if ref $retval eq 'App::Netdisco::Worker::Status';
|
$self->jobstat($retval) if ref $retval eq 'App::Netdisco::Worker::Status';
|
||||||
}
|
}
|
||||||
catch { $self->jobstat->log($_) };
|
catch { $self->jobstat->error($_) };
|
||||||
|
|
||||||
last if $hook =~ m/_primary$/ and $self->jobstat->is_ok;
|
last if $hook =~ m/_primary$/ and $self->jobstat->is_ok;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,18 @@ Shorthand for new() with setting param, accepts log as arg.
|
|||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub done { return (shift)->new({done_slot => 1, log => shift}) }
|
sub _make_new {
|
||||||
sub error { return (shift)->new({error_slot => 1, log => shift}) }
|
my ($self, $log, $slot) = @_;
|
||||||
sub defer { return (shift)->new({defer_slot => 1, log => shift}) }
|
my $new = (ref $self ? $self : $self->new());
|
||||||
|
$new->log($log);
|
||||||
|
$new->$_(0) for (qw/done_slot error_slot defer_slot/);
|
||||||
|
$new->$slot(1);
|
||||||
|
return $new;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub error { (shift)->_make_new(@_, 'error_slot') }
|
||||||
|
sub done { (shift)->_make_new(@_, 'done_slot') }
|
||||||
|
sub defer { (shift)->_make_new(@_, 'defer_slot') }
|
||||||
|
|
||||||
=head2 is_ok
|
=head2 is_ok
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user