blib/lib/App/Netdisco/Worker/Plugin/Arpnip.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 44 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package App::Netdisco::Worker::Plugin::Arpnip;
2  
3 use Dancer ':syntax';
4 use App::Netdisco::Worker::Plugin;
5 use aliased 'App::Netdisco::Worker::Status';
6  
7 use App::Netdisco::Util::Device 'is_arpnipable_now';
8  
9 register_worker({ phase => 'check' }, sub {
10 my ($job, $workerconf) = @_;
11 my $device = $job->device;
12  
13 return Status->error('arpnip failed: unable to interpret device param')
14 unless defined $device;
15  
16 return Status->error("arpnip skipped: $device not yet discovered")
17 unless $device->in_storage;
18  
19 if ($job->port or $job->extra) {
20 $job->is_offline(true);
21 debug 'arpnip offline: will update from CLI or API';
22 }
23 else {
24 return Status->info("arpnip skipped: $device is not arpnipable")
25 unless is_arpnipable_now($device);
26 }
27  
28 # support for Hooks
29 vars->{'hook_data'} = { $device->get_columns };
30 delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
31  
32 return Status->done('arpnip is able to run');
33 });
34  
35 true;