fix pod; set status defaults; stub runner mixin
This commit is contained in:
15
lib/App/Netdisco/Backend/Runner.pm
Normal file
15
lib/App/Netdisco/Backend/Runner.pm
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package App::Netdisco::Backend::Runner;
|
||||||
|
|
||||||
|
use Dancer ':moose :syntax';
|
||||||
|
use App::Netdisco::Worker::Status;
|
||||||
|
|
||||||
|
use Try::Tiny;
|
||||||
|
use Role::Tiny;
|
||||||
|
use namespace::clean;
|
||||||
|
|
||||||
|
# mixin code to run workers loaded via plugins
|
||||||
|
sub run {
|
||||||
|
return App::Netdisco::Worker::Status->new({done => true, message => 'ok'});
|
||||||
|
}
|
||||||
|
|
||||||
|
true;
|
||||||
@@ -119,7 +119,7 @@ namespace and set C<primary> to be C<true>.
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head2 Worker Execution and Return Code
|
=head1 Worker Execution and Return Code
|
||||||
|
|
||||||
Workers are configured as an ordered list. They are grouped by C<action> and
|
Workers are configured as an ordered list. They are grouped by C<action> and
|
||||||
C<phase> (as in Package Naming Convention, above).
|
C<phase> (as in Package Naming Convention, above).
|
||||||
@@ -137,7 +137,7 @@ Remember that a worker is only run if it matches the hardware platform of the
|
|||||||
target device and the user's configuration, and is not also excluded by the
|
target device and the user's configuration, and is not also excluded by the
|
||||||
user's configuration. This filtering takes place before inspecting C<primary>.
|
user's configuration. This filtering takes place before inspecting C<primary>.
|
||||||
|
|
||||||
=head2 Accessing Transports
|
=head1 Accessing Transports
|
||||||
|
|
||||||
From your worker you will want to connect to a device to gather data. This is
|
From your worker you will want to connect to a device to gather data. This is
|
||||||
done using a transport protocol session (SNMP, SSH, etc). Transports are
|
done using a transport protocol session (SNMP, SSH, etc). Transports are
|
||||||
@@ -154,7 +154,7 @@ L<App::Netdisco::Transport::SNMP>
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head2 Review of Terminology
|
=head1 Review of Terminology
|
||||||
|
|
||||||
In summary, Worker code is defined in a package namespace specifying the
|
In summary, Worker code is defined in a package namespace specifying the
|
||||||
Action and Phase, and registered as a plugin with configuration which may
|
Action and Phase, and registered as a plugin with configuration which may
|
||||||
@@ -197,7 +197,7 @@ by setting this option and returning true from your worker.
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head2 Database Connections
|
=head1 Database Connections
|
||||||
|
|
||||||
The Netdisco database is available via the C<netdisco> schema key, as below.
|
The Netdisco database is available via the C<netdisco> schema key, as below.
|
||||||
You can also use the C<external_databases> configuration item to set up
|
You can also use the C<external_databases> configuration item to set up
|
||||||
|
|||||||
@@ -10,14 +10,19 @@ foreach my $slot (qw/
|
|||||||
done
|
done
|
||||||
error
|
error
|
||||||
defer
|
defer
|
||||||
message
|
|
||||||
/) {
|
/) {
|
||||||
|
|
||||||
has $slot => (
|
has $slot => (
|
||||||
is => 'rw',
|
is => 'rw',
|
||||||
|
default => 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has 'log' => (
|
||||||
|
is => 'rw',
|
||||||
|
default => '',
|
||||||
|
);
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
=head2 ok
|
=head2 ok
|
||||||
@@ -53,7 +58,7 @@ sub status {
|
|||||||
|
|
||||||
=head2 update_job
|
=head2 update_job
|
||||||
|
|
||||||
Updates an L<App::Netdisco::Backend::Job> with status and message.
|
Updates an L<App::Netdisco::Backend::Job> with status and log.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
@@ -61,7 +66,7 @@ sub update_job {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $job = shift or return;
|
my $job = shift or return;
|
||||||
$job->status( $self->status );
|
$job->status( $self->status );
|
||||||
$job->log( $self->message );
|
$job->log( $self->log );
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
Reference in New Issue
Block a user