replace unicode nonbreaking space with ascii space (#794)

This commit is contained in:
nick n
2021-06-23 23:00:33 +02:00
committed by GitHub
parent ec1c0b5f39
commit 83a946d36e
49 changed files with 171 additions and 171 deletions

View File

@@ -23,7 +23,7 @@ sub load_workers {
my @core_plugins = @{ setting('worker_plugins') || [] };
my @user_plugins = @{ setting('extra_worker_plugins') || [] };
# load worker plugins for our action
# load worker plugins for our action
foreach my $plugin (@user_plugins, @core_plugins) {
$plugin =~ s/^X::/+App::NetdiscoX::Worker::Plugin::/;
$plugin = 'App::Netdisco::Worker::Plugin::'. $plugin
@@ -35,7 +35,7 @@ sub load_workers {
Module::Load::load $plugin;
}
# now vars->{workers} is populated, we set the dispatch order
# now vars->{workers} is populated, we set the dispatch order
my $workers = vars->{'workers'}->{$action} || {};
#use DDP; p vars->{'workers'};

View File

@@ -31,15 +31,15 @@ register 'register_worker' => sub {
my $worker = sub {
my $job = shift or die 'missing job param';
# use DDP; p $workerconf;
# use DDP; p $workerconf;
debug sprintf '-> run worker %s/%s/%s',
@$workerconf{qw/phase namespace priority/};
return if $job->is_cancelled;
# check to see if this namespace has already passed at higher priority
# and also update job's record of namespace and priority
# check to see if this namespace has already passed at higher priority
# and also update job's record of namespace and priority
return $job->add_status( Status->info('skip: namespace passed at higher priority') )
if $job->namespace_passed($workerconf);
@@ -53,7 +53,7 @@ register 'register_worker' => sub {
my @newuserconf = ();
my @userconf = @{ dclone (setting('device_auth') || []) };
# worker might be vendor/platform specific
# worker might be vendor/platform specific
if (ref $job->device) {
my $no = (exists $workerconf->{no} ? $workerconf->{no} : undef);
my $only = (exists $workerconf->{only} ? $workerconf->{only} : undef);
@@ -62,33 +62,33 @@ register 'register_worker' => sub {
if ($no and check_acl_no($job->device, $no))
or ($only and not check_acl_only($job->device, $only));
# reduce device_auth by driver and action filters
# reduce device_auth by driver and action filters
foreach my $stanza (@userconf) {
next if exists $stanza->{driver} and exists $workerconf->{driver}
and (($stanza->{driver} || '') ne ($workerconf->{driver} || ''));
# filter here rather than in Runner as runner does not know namespace
# filter here rather than in Runner as runner does not know namespace
next if exists $stanza->{action}
and not _find_matchaction($workerconf, lc($stanza->{action}));
push @newuserconf, dclone $stanza;
}
# per-device action but no device creds available
# per-device action but no device creds available
return $job->add_status( Status->info('skip: driver or action not applicable') )
if 0 == scalar @newuserconf && $job->action ne "delete";
}
# back up and restore device_auth
# back up and restore device_auth
my $guard = guard { set(device_auth => \@userconf) };
set(device_auth => \@newuserconf);
# use DDP; p @newuserconf;
# use DDP; p @newuserconf;
# run worker
# run worker
$code->($job, $workerconf);
};
# store the built worker as Worker.pm will build the dispatch order later on
# store the built worker as Worker.pm will build the dispatch order later on
push @{ vars->{'workers'}->{$workerconf->{action}}
->{$workerconf->{phase}}
->{$workerconf->{namespace}}

View File

@@ -19,9 +19,9 @@ register_worker({ phase => 'check' }, sub {
return Status->info("arpnip skipped: $device is not arpnipable")
unless is_arpnipable_now($device);
# support for Hooks
# support for Hooks
vars->{'hook_data'} = { $device->get_columns };
delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
return Status->done('arpnip is able to run');
});

View File

@@ -34,7 +34,7 @@ sub gather_subnets {
my @subnets = ();
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
or return (); # already checked!
or return (); # already checked!
my $ip_netmask = $snmp->ip_netmask;
foreach my $entry (keys %$ip_netmask) {

View File

@@ -16,7 +16,7 @@ register_worker({ phase => 'check' }, sub {
return Status->error("discover failed: no device param (need -d ?)")
if $device->ip eq '0.0.0.0';
# runner has already called get_device to promote $job->device
# runner has already called get_device to promote $job->device
return $job->cancel("fresh discover cancelled: $device already known")
if $device->in_storage
and ($job->subaction eq 'with-nodes' and not $job->username);

View File

@@ -43,7 +43,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
next unless ref {} eq ref $map;
foreach my $key (sort keys %$map) {
# lhs matches device, rhs matches device_ip
# lhs matches device, rhs matches device_ip
if (check_acl_only($device, $key)
and check_acl_only($alias, $map->{$key})) {
@@ -64,7 +64,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
}
}
}
} # ALIAS
} # ALIAS
}
return if $new_ip eq $old_ip;

View File

@@ -104,7 +104,7 @@ sub store_neighbors {
my @to_discover = ();
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
or return (); # already checked!
or return (); # already checked!
# first allow any manually configured topology to be set
# and do this before we cache the rows in vars->{'device_ports'}
@@ -127,14 +127,14 @@ sub store_neighbors {
{ map {($_->port => $_)} $device->ports->reset->all };
my $device_ports = vars->{'device_ports'};
# v4 and v6 neighbor tables
# v4 and v6 neighbor tables
my $c_ip = ($snmp->c_ip || {});
my %c_ipv6 = %{ ($snmp->can('hasLLDP') and $snmp->hasLLDP)
? ($snmp->lldp_ipv6 || {}) : {} };
# remove keys with undef values, as c_ip does
# remove keys with undef values, as c_ip does
delete @c_ipv6{ grep { not defined $c_ipv6{$_} } keys %c_ipv6 };
# now combine them, v6 wins
# now combine them, v6 wins
$c_ip = { %$c_ip, %c_ipv6 };
foreach my $entry (sort (List::MoreUtils::uniq( keys %$c_ip ))) {

View File

@@ -71,11 +71,11 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
}
}
# support for Hooks
# support for Hooks
vars->{'hook_data'} = { $device->get_columns };
delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
# support for new_device Hook
# support for new_device Hook
vars->{'new_device'} = 1 if not $device->in_storage;
schema('netdisco')->txn_do(sub {
@@ -156,7 +156,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
push @$resolved_aliases, { alias => $device->ip, dns => $device->dns }
if 0 == scalar grep {$_->{alias} eq $device->ip} @aliases;
# support for Hooks
# support for Hooks
vars->{'hook_data'}->{'device_ips'} = $resolved_aliases;
schema('netdisco')->txn_do(sub {
@@ -308,7 +308,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
$interfaces{$master}->{is_master} = 'true';
}
# support for Hooks
# support for Hooks
vars->{'hook_data'}->{'ports'} = [values %interfaces];
schema('netdisco')->resultset('DevicePort')->txn_do_locked(sub {

View File

@@ -124,7 +124,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
};
}
# support for Hooks
# support for Hooks
vars->{'hook_data'}->{'vlans'} = \@devicevlans;
schema('netdisco')->txn_do(sub {

View File

@@ -12,7 +12,7 @@ register_worker({ phase => 'main' }, sub {
my $device = $job->device;
# if requested, and the device has not yet been
# arpniped/macsucked, queue those jobs now
# arpniped/macsucked, queue those jobs now
return unless $device->in_storage and $job->subaction eq 'with-nodes';
if (!defined $device->last_macsuck and $device->has_layer(2)) {

View File

@@ -56,7 +56,7 @@ register_worker({ phase => 'main' }, sub {
});
}
# also have to clean up node_ip that have no correspoding node
# also have to clean up node_ip that have no correspoding node
schema('netdisco')->resultset('NodeIp')->search({
mac => { -in => schema('netdisco')->resultset('NodeIp')->search(
{ port => undef },
@@ -82,7 +82,7 @@ register_worker({ phase => 'main' }, sub {
});
}
# now update stats
# now update stats
update_stats();
return Status->done('Checked expiry and updated stats');

View File

@@ -19,9 +19,9 @@ register_worker({ phase => 'check' }, sub {
return Status->info("macsuck skipped: $device is not macsuckable")
unless is_macsuckable_now($device);
# support for Hooks
# support for Hooks
vars->{'hook_data'} = { $device->get_columns };
delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
delete vars->{'hook_data'}->{'snmp_comm'}; # for privacy
return Status->done('Macsuck is able to run.');
});

View File

@@ -153,7 +153,7 @@ sub get_vlan_list {
my $device = shift;
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
or return (); # already checked!
or return (); # already checked!
return () unless $snmp->cisco_comm_indexing;
@@ -270,7 +270,7 @@ sub walk_fwtable {
my $cache = {};
my $snmp = App::Netdisco::Transport::SNMP->reader_for($device)
or return $cache; # already checked!
or return $cache; # already checked!
my $fw_mac = $snmp->fw_mac || {};
my $fw_port = $snmp->fw_port || {};

View File

@@ -156,8 +156,8 @@ C<rancid>. All keys are optional:
rancid:
rancid_cvsroot: '$ENV{NETDISCO_HOME}/rancid' # default
rancid_conf: '/etc/rancid' # default
down_age: '1 day' # default
delimiter: ';' # default
down_age: '1 day' # default
delimiter: ';' # default
default_group: 'default' # default
groups:
groupname1: 'host_group1_acl'

View File

@@ -19,7 +19,7 @@ use namespace::clean;
with 'App::Netdisco::Worker::Loader';
has 'job' => ( is => 'rw' );
# mixin code to run workers loaded via plugins
# mixin code to run workers loaded via plugins
sub run {
my ($self, $job) = @_;
@@ -31,13 +31,13 @@ sub run {
$job->device( get_device($job->device) );
$self->load_workers();
# finalise job status when we exit
# finalise job status when we exit
my $statusguard = guard { $job->finalise_status };
my @newuserconf = ();
my @userconf = @{ dclone (setting('device_auth') || []) };
# reduce device_auth by only/no
# reduce device_auth by only/no
if (ref $job->device) {
foreach my $stanza (@userconf) {
my $no = (exists $stanza->{no} ? $stanza->{no} : undef);
@@ -49,25 +49,25 @@ sub run {
push @newuserconf, dclone $stanza;
}
# per-device action but no device creds available
# per-device action but no device creds available
return $job->add_status( Status->defer('deferred job with no device creds') )
if 0 == scalar @newuserconf && $job->action ne "delete";
}
# back up and restore device_auth
# back up and restore device_auth
my $configguard = guard { set(device_auth => \@userconf) };
set(device_auth => \@newuserconf);
my $runner = sub {
my ($self, $job) = @_;
# roll everything back if we're testing
# roll everything back if we're testing
my $txn_guard = $ENV{ND2_DB_ROLLBACK}
? schema('netdisco')->storage->txn_scope_guard : undef;
# run check phase and if there are workers then one MUST be successful
# run check phase and if there are workers then one MUST be successful
$self->run_workers('workers_check');
# run other phases
# run other phases
if ($job->check_passed) {
$self->run_workers("workers_${_}") for qw/early main user store late/;
}