diff --git a/lib/App/Netdisco/Backend/Runner.pm b/lib/App/Netdisco/Backend/Runner.pm new file mode 100644 index 00000000..42443947 --- /dev/null +++ b/lib/App/Netdisco/Backend/Runner.pm @@ -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; diff --git a/lib/App/Netdisco/Manual/WritingWorkers.pod b/lib/App/Netdisco/Manual/WritingWorkers.pod index 89f9471d..02a32c37 100644 --- a/lib/App/Netdisco/Manual/WritingWorkers.pod +++ b/lib/App/Netdisco/Manual/WritingWorkers.pod @@ -119,7 +119,7 @@ namespace and set C to be C. =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 and C (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 user's configuration. This filtering takes place before inspecting C. -=head2 Accessing Transports +=head1 Accessing Transports 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 @@ -154,7 +154,7 @@ L =back -=head2 Review of Terminology +=head1 Review of Terminology In summary, Worker code is defined in a package namespace specifying the 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 -=head2 Database Connections +=head1 Database Connections The Netdisco database is available via the C schema key, as below. You can also use the C configuration item to set up diff --git a/lib/App/Netdisco/Worker/Status.pm b/lib/App/Netdisco/Worker/Status.pm index cfed571c..495bf900 100644 --- a/lib/App/Netdisco/Worker/Status.pm +++ b/lib/App/Netdisco/Worker/Status.pm @@ -10,14 +10,19 @@ foreach my $slot (qw/ done error defer - message /) { has $slot => ( is => 'rw', + default => 0, ); } +has 'log' => ( + is => 'rw', + default => '', +); + =head1 METHODS =head2 ok @@ -53,7 +58,7 @@ sub status { =head2 update_job -Updates an L with status and message. +Updates an L with status and log. =cut @@ -61,7 +66,7 @@ sub update_job { my $self = shift; my $job = shift or return; $job->status( $self->status ); - $job->log( $self->message ); + $job->log( $self->log ); } 1;