change noop to info, and some fixes
This commit is contained in:
@@ -49,13 +49,13 @@ sub BUILD {
|
|||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
=head2 summary
|
=head2 display_name
|
||||||
|
|
||||||
An attempt to make a meaningful written statement about the job.
|
An attempt to make a meaningful written statement about the job.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub summary {
|
sub display_name {
|
||||||
my $job = shift;
|
my $job = shift;
|
||||||
return join ' ',
|
return join ' ',
|
||||||
$job->action,
|
$job->action,
|
||||||
@@ -87,8 +87,8 @@ sub finalise_status {
|
|||||||
next if $status->phase
|
next if $status->phase
|
||||||
and $status->phase !~ m/^(?:check|early|main)$/;
|
and $status->phase !~ m/^(?:check|early|main)$/;
|
||||||
|
|
||||||
next if $status->phase eq 'check'
|
# done() from check phase should not be the action's done()
|
||||||
and $status->level eq Status->done()->level;
|
next if $status->phase eq 'check' and $status->is_ok;
|
||||||
|
|
||||||
if ($status->level >= $max_level) {
|
if ($status->level >= $max_level) {
|
||||||
$job->status( $status->status );
|
$job->status( $status->status );
|
||||||
@@ -110,8 +110,8 @@ sub check_passed {
|
|||||||
return true if 0 == scalar @{ $job->_statuslist };
|
return true if 0 == scalar @{ $job->_statuslist };
|
||||||
|
|
||||||
foreach my $status (@{ $job->_statuslist }) {
|
foreach my $status (@{ $job->_statuslist }) {
|
||||||
next unless $status->phase and $status->phase eq 'check';
|
return true if
|
||||||
return true if $status->is_ok;
|
(($status->phase eq 'check') and $status->is_ok);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ sub namespace_passed {
|
|||||||
|
|
||||||
if ($job->_last_namespace) {
|
if ($job->_last_namespace) {
|
||||||
foreach my $status (@{ $job->_statuslist }) {
|
foreach my $status (@{ $job->_statuslist }) {
|
||||||
next unless ($status->phase and $status->phase eq $workerconf->{phase})
|
next unless ($status->phase eq $workerconf->{phase})
|
||||||
and ($workerconf->{namespace} eq $job->_last_namespace)
|
and ($workerconf->{namespace} eq $job->_last_namespace)
|
||||||
and ($workerconf->{priority} < $job->_last_priority);
|
and ($workerconf->{priority} < $job->_last_priority);
|
||||||
return true if $status->is_ok;
|
return true if $status->is_ok;
|
||||||
@@ -169,8 +169,7 @@ sub add_status {
|
|||||||
$status->phase( $job->_current_phase || '' );
|
$status->phase( $job->_current_phase || '' );
|
||||||
push @{ $job->_statuslist }, $status;
|
push @{ $job->_statuslist }, $status;
|
||||||
debug $status->log if $status->log
|
debug $status->log if $status->log
|
||||||
and (($status->phase eq 'check')
|
and (($status->phase eq 'check') or $status->not_ok);
|
||||||
or ($status->level ne Status->done()->level));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
=head1 ADDITIONAL COLUMNS
|
=head1 ADDITIONAL COLUMNS
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ sub worker_body {
|
|||||||
try {
|
try {
|
||||||
$job->started(scalar localtime);
|
$job->started(scalar localtime);
|
||||||
prctl sprintf 'nd2: #%s poll: #%s: %s',
|
prctl sprintf 'nd2: #%s poll: #%s: %s',
|
||||||
$wid, $job->id, $job->summary;
|
$wid, $job->id, $job->display_name;
|
||||||
info sprintf "pol (%s): starting %s job(%s) at %s",
|
info sprintf "pol (%s): starting %s job(%s) at %s",
|
||||||
$wid, $job->action, $job->id, $job->started;
|
$wid, $job->action, $job->id, $job->started;
|
||||||
$self->run($job);
|
$self->run($job);
|
||||||
|
|||||||
@@ -105,13 +105,13 @@ __PACKAGE__->belongs_to( target => 'App::Netdisco::DB::Result::Device',
|
|||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
=head2 summary
|
=head2 display_name
|
||||||
|
|
||||||
An attempt to make a meaningful statement about the job.
|
An attempt to make a meaningful statement about the job.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub summary {
|
sub display_name {
|
||||||
my $job = shift;
|
my $job = shift;
|
||||||
return join ' ',
|
return join ' ',
|
||||||
$job->action,
|
$job->action,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ register 'register_worker' => sub {
|
|||||||
my $no = (exists $workerconf->{no} ? $workerconf->{no} : undef);
|
my $no = (exists $workerconf->{no} ? $workerconf->{no} : undef);
|
||||||
my $only = (exists $workerconf->{only} ? $workerconf->{only} : undef);
|
my $only = (exists $workerconf->{only} ? $workerconf->{only} : undef);
|
||||||
|
|
||||||
return $job->add_status( Status->noop('worker not applicable to this device') )
|
return $job->add_status( Status->info('worker not applicable to this device') )
|
||||||
if ($no and check_acl_no($job->device, $no))
|
if ($no and check_acl_no($job->device, $no))
|
||||||
or ($only and not check_acl_only($job->device, $only));
|
or ($only and not check_acl_only($job->device, $only));
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ register 'register_worker' => sub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# per-device action but no device creds available
|
# per-device action but no device creds available
|
||||||
return $job->add_status( Status->noop('worker driver or action not applicable') )
|
return $job->add_status( Status->info('worker driver or action not applicable') )
|
||||||
if 0 == scalar @newuserconf;
|
if 0 == scalar @newuserconf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
|
my $now = 'to_timestamp('. (join '.', gettimeofday) .')';
|
||||||
store_subnet($_, $now) for @subnets;
|
store_subnet($_, $now) for @subnets;
|
||||||
|
|
||||||
return Status->noop(sprintf ' [%s] arpnip - processed %s Subnet entries',
|
return Status->info(sprintf ' [%s] arpnip - processed %s Subnet entries',
|
||||||
$device->ip, scalar @subnets);
|
$device->ip, scalar @subnets);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
schema('netdisco')->resultset('Admin')
|
schema('netdisco')->resultset('Admin')
|
||||||
->find({job => $job->id})->update({device => $new_ip});
|
->find({job => $job->id})->update({device => $new_ip});
|
||||||
|
|
||||||
return Status->noop(sprintf ' [%s] device - changed IP to %s (%s)',
|
return Status->info(sprintf ' [%s] device - changed IP to %s (%s)',
|
||||||
$old_ip, $device->ip, ($device->dns || ''));
|
$old_ip, $device->ip, ($device->dns || ''));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return Status->noop(
|
return Status->info(
|
||||||
sprintf ' [%s] modules - 0 chassis components (added one pseudo for chassis)',
|
sprintf ' [%s] modules - 0 chassis components (added one pseudo for chassis)',
|
||||||
$device->ip);
|
$device->ip);
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
$device->ip, $gone;
|
$device->ip, $gone;
|
||||||
$device->modules->populate(\@modules);
|
$device->modules->populate(\@modules);
|
||||||
|
|
||||||
return Status->noop(sprintf ' [%s] modules - added %d new chassis modules',
|
return Status->info(sprintf ' [%s] modules - added %d new chassis modules',
|
||||||
$device->ip, scalar @modules);
|
$device->ip, scalar @modules);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
($remote_id ? (device_key => $remote_id) : ()),
|
($remote_id ? (device_key => $remote_id) : ()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Status->info(sprintf ' [%s] neigh - processed %s neighbors',
|
||||||
|
$device->ip, scalar @to_discover);
|
||||||
});
|
});
|
||||||
|
|
||||||
=head2 store_neighbors( $device )
|
=head2 store_neighbors( $device )
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
my $p_status = $snmp->peth_power_status;
|
my $p_status = $snmp->peth_power_status;
|
||||||
|
|
||||||
if (!defined $p_watts) {
|
if (!defined $p_watts) {
|
||||||
return Status->noop(sprintf ' [%s] power - 0 power modules', $device->ip);
|
return Status->info(sprintf ' [%s] power - 0 power modules', $device->ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
# build device module power info suitable for DBIC
|
# build device module power info suitable for DBIC
|
||||||
@@ -73,7 +73,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
$device->ip, $gone;
|
$device->ip, $gone;
|
||||||
$device->powered_ports->populate(\@portpower);
|
$device->powered_ports->populate(\@portpower);
|
||||||
|
|
||||||
return Status->noop(sprintf ' [%s] power - added %d new PoE capable ports',
|
return Status->info(sprintf ' [%s] power - added %d new PoE capable ports',
|
||||||
$device->ip, scalar @portpower);
|
$device->ip, scalar @portpower);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
|
|||||||
$device->update_or_insert(undef, {for => 'update'});
|
$device->update_or_insert(undef, {for => 'update'});
|
||||||
$device->ports->populate([values %interfaces]);
|
$device->ports->populate([values %interfaces]);
|
||||||
|
|
||||||
return Status->noop(sprintf ' [%s] interfaces - added %d new interfaces',
|
return Status->info(sprintf ' [%s] interfaces - added %d new interfaces',
|
||||||
$device->ip, scalar values %interfaces);
|
$device->ip, scalar values %interfaces);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
$device->ip, $gone;
|
$device->ip, $gone;
|
||||||
$device->port_vlans->populate(\@portvlans);
|
$device->port_vlans->populate(\@portvlans);
|
||||||
|
|
||||||
return Status->noop(sprintf ' [%s] vlans - added %d new port VLANs',
|
return Status->info(sprintf ' [%s] vlans - added %d new port VLANs',
|
||||||
$device->ip, scalar @portvlans);
|
$device->ip, scalar @portvlans);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
$device->ip, $gone;
|
$device->ip, $gone;
|
||||||
$device->wireless_ports->populate(\@channels);
|
$device->wireless_ports->populate(\@channels);
|
||||||
|
|
||||||
return Status->noop(sprintf ' [%s] wireless - added %d new wireless channels',
|
return Status->info(sprintf ' [%s] wireless - added %d new wireless channels',
|
||||||
$device->ip, scalar @channels);
|
$device->ip, scalar @channels);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ register_worker({ phase => 'main' }, sub {
|
|||||||
userip => $job->userip,
|
userip => $job->userip,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Status->info("Queued macsuck and arpnip for $device.");
|
||||||
});
|
});
|
||||||
|
|
||||||
true;
|
true;
|
||||||
|
|||||||
@@ -20,14 +20,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
my $cd11_txrate = $snmp->cd11_txrate;
|
my $cd11_txrate = $snmp->cd11_txrate;
|
||||||
return unless $cd11_txrate and scalar keys %$cd11_txrate;
|
return unless $cd11_txrate and scalar keys %$cd11_txrate;
|
||||||
|
|
||||||
if (setting('store_wireless_clients')) {
|
return Status->info(sprintf ' [%s] macsuck - dot11 info available but skipped due to config',
|
||||||
debug sprintf ' [%s] macsuck - gathering wireless client info',
|
$device->ip) unless setting('store_wireless_clients');
|
||||||
$device->ip;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Status->noop(sprintf ' [%s] macsuck - dot11 info available but skipped due to config',
|
|
||||||
$device->ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $cd11_rateset = $snmp->cd11_rateset();
|
my $cd11_rateset = $snmp->cd11_rateset();
|
||||||
my $cd11_uptime = $snmp->cd11_uptime();
|
my $cd11_uptime = $snmp->cd11_uptime();
|
||||||
@@ -77,6 +71,9 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Status->info(sprintf ' [%s] macsuck - processed %s wireless nodes',
|
||||||
|
$device->ip, scalar keys %{ $cd11_txrate });
|
||||||
});
|
});
|
||||||
|
|
||||||
true;
|
true;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package App::Netdisco::Worker::Plugin::Vlan::Native;
|
package App::Netdisco::Worker::Plugin::Vlan::Core;
|
||||||
|
|
||||||
use Dancer ':syntax';
|
use Dancer ':syntax';
|
||||||
use App::Netdisco::Worker::Plugin;
|
use App::Netdisco::Worker::Plugin;
|
||||||
@@ -18,7 +18,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
|
|||||||
vars->{'iid'} = get_iid($snmp, vars->{'port'})
|
vars->{'iid'} = get_iid($snmp, vars->{'port'})
|
||||||
or return Status->error("Failed to get port ID for [$pn] from $device");
|
or return Status->error("Failed to get port ID for [$pn] from $device");
|
||||||
|
|
||||||
return Status->noop("Vlan set can continue.");
|
return Status->info("Vlan set can continue.");
|
||||||
});
|
});
|
||||||
|
|
||||||
register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package App::Netdisco::Worker::Status;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Dancer qw/:moose :syntax !error/;
|
use Dancer qw/:moose :syntax !error !info/;
|
||||||
|
|
||||||
use Moo;
|
use Moo;
|
||||||
use namespace::clean;
|
use namespace::clean;
|
||||||
@@ -26,24 +26,29 @@ The status can be:
|
|||||||
|
|
||||||
=item * C<done>
|
=item * C<done>
|
||||||
|
|
||||||
At C<check> phase, indicates the action may continue. At other phases,
|
success and this could be the outcome of the action
|
||||||
indicates the worker has completed without error or has no work to do.
|
|
||||||
|
|
||||||
=item * C<error>
|
=item * C<info>
|
||||||
|
|
||||||
Indicates that there is an error condition. Also used to quit a worker without
|
success and notable but not the main goal of the action
|
||||||
side effects that C<done> and C<defer> have.
|
|
||||||
|
|
||||||
=item * C<defer>
|
=item * C<defer>
|
||||||
|
|
||||||
Quits a worker. If the final recorded outcome for a device is C<defer> several
|
failed to connect, should increment defer counters
|
||||||
times in a row, then it may be skipped from further jobs.
|
|
||||||
|
=item * C<error>
|
||||||
|
|
||||||
|
had a problem and was unsuccessful
|
||||||
|
|
||||||
|
=item * C<()>
|
||||||
|
|
||||||
|
skipped the worker for some reason but not fatal
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
=head2 done, error, defer
|
=head2 done, info, defer, error
|
||||||
|
|
||||||
Shorthand for new() with setting param, accepts log as arg.
|
Shorthand for new() with setting param, accepts log as arg.
|
||||||
|
|
||||||
@@ -58,21 +63,10 @@ sub _make_new {
|
|||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub error { shift->_make_new('error', @_) }
|
|
||||||
sub done { shift->_make_new('done', @_) }
|
sub done { shift->_make_new('done', @_) }
|
||||||
|
sub info { shift->_make_new('info', @_) }
|
||||||
sub defer { shift->_make_new('defer', @_) }
|
sub defer { shift->_make_new('defer', @_) }
|
||||||
|
sub error { shift->_make_new('error', @_) }
|
||||||
=head2 noop
|
|
||||||
|
|
||||||
Simply logs a message at debug level if passed, and returns true. Used for
|
|
||||||
consistency with other Status class methods but really does nothing.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub noop {
|
|
||||||
debug $_[1] if $_[1];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
=head2 is_ok
|
=head2 is_ok
|
||||||
|
|
||||||
@@ -84,7 +78,7 @@ sub is_ok { return $_[0]->status eq 'done' }
|
|||||||
|
|
||||||
=head2 not_ok
|
=head2 not_ok
|
||||||
|
|
||||||
Returns true if status is C<error> or C<defer>.
|
Returns true if status is C<error>, C<defer>, or C<info>.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
@@ -98,8 +92,9 @@ A numeric constant for the status, to allow comparison.
|
|||||||
|
|
||||||
sub level {
|
sub level {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return (($self->status eq 'done') ? 3
|
return (($self->status eq 'done') ? 4
|
||||||
: ($self->status eq 'defer') ? 2 : 1);
|
: ($self->status eq 'info') ? 3
|
||||||
|
: ($self->status eq 'defer') ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
Reference in New Issue
Block a user