merge in og-get_external_credentials
Squashed commit of the following: commit3fe8f383a7Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Mar 11 17:07:42 2019 +0000 add debug lines and tested commit3249739e42Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Mar 11 16:54:11 2019 +0000 change config name to get_credentials commite78558397aAuthor: Oliver Gorwits <oliver@cpan.org> Date: Mon Mar 11 16:51:11 2019 +0000 separate out generic device auth to DeviceAuth module commit249f05165fAuthor: Oliver Gorwits <oliver@cpan.org> Date: Wed Mar 6 18:43:31 2019 +0000 release 2.040007 commite3af64df77Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Mar 6 18:42:47 2019 +0000 #521-redux fix wifi date search commit48857ae300Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Mar 4 12:03:31 2019 +0000 release 2.040006 commite09dab5362Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Mar 4 11:39:12 2019 +0000 #527 update List::MoreUtils version requirement commit6e7de3fff3Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Mar 4 09:59:41 2019 +0000 release 2.040005 commit0c98318a45Author: Oliver Gorwits <oliver@spike.local> Date: Mon Mar 4 09:57:18 2019 +0000 #526 fix discover syntax bug commite9efc45182Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 14:56:48 2019 +0000 release 2.040004 commit6cdfd80d10Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 14:34:00 2019 +0000 allow undiscovered neighbors report to use discover_{waps,phones} setting commitac381e0802Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 14:13:20 2019 +0000 #506 was a red herring commitb83e614c85Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 13:00:36 2019 +0000 make discover_{phones,waps} work with LLDP capabilities as well commit189d234b55Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 12:47:38 2019 +0000 check discover_no_type and friends earlier on in neighbors list build commit9c956466f3Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 12:32:07 2019 +0000 also update default config for new discover_phones and discover_waps settings commit09d29954d2Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 12:26:50 2019 +0000 #512 fix regression in phone/wap discovery exclusion commit2bae91f1b6Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 12:01:34 2019 +0000 rename match_devicetype() to match_to_setting() commit57cb6ddb70Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Mar 3 09:19:39 2019 +0000 fix for over-eager fix to #506 commitef560fb59aAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 22:41:40 2019 +0000 #506 relax device renumber so it works for an alias commit7a8bcb094eAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 22:23:39 2019 +0000 #521 Search Node Date Range not working commita643820a62Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 21:54:27 2019 +0000 #428 Port-Channels not showing in netmap commit5ba5bcd295Merge:e7aacddba1f95028Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 20:04:11 2019 +0000 Merge branch 'master' of github.com:netdisco/netdisco commite7aacddbc6Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 20:01:05 2019 +0000 #498 Map with VLAN filter omits unconnected devices commita1f95028caAuthor: nick n <39005454+inphobia@users.noreply.github.com> Date: Sat Mar 2 19:54:22 2019 +0100 catch up with changes noticed that rc-sshcollector-core received updates to changes, add them here as well. didn't mention #499 & #522 commitce1b847ceaAuthor: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 18:47:44 2019 +0000 fix bug showing no nodes when only one matches in netmap commit78e30a7926Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 16:28:15 2019 +0000 #500 filtering in device/ports on native vlan duplicates entries commit9952f0c6c7Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 15:02:12 2019 +0000 #499 netdisco-do renumber reports wrong ip (inphobia) commitca3fd8f466Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 15:00:18 2019 +0000 #505 device renumber should update device port properties and device skips commit1265bc8470Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 14:52:21 2019 +0000 #520 catch slave ports defined without a master commitd4c7579c10Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 14:47:49 2019 +0000 #522 TypeAhead.pm can reference empty data (inphobia) commit77decc23b7Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Mar 2 14:45:37 2019 +0000 #514 inconsistent results in ip inventory (inphobia) commit3f211650b8Author: nick n <39005454+inphobia@users.noreply.github.com> Date: Fri Mar 1 12:34:42 2019 +0100 last pieces for db schema upgrade last piece of #510
This commit is contained in:
@@ -7,7 +7,7 @@ use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use URI ();
|
||||
use URL::Encode 'url_params_mixed';
|
||||
use App::Netdisco::Util::Device 'match_devicetype';
|
||||
use App::Netdisco::Util::Device 'match_to_setting';
|
||||
|
||||
# build view settings for port connected nodes and devices
|
||||
set('connected_properties' => [
|
||||
@@ -20,7 +20,7 @@ hook 'before_template' => sub {
|
||||
my $tokens = shift;
|
||||
|
||||
# allow checking of discoverability of remote connected device
|
||||
$tokens->{has_snmp} = sub { not match_devicetype(shift, 'discover_no_type') };
|
||||
$tokens->{has_snmp} = sub { not match_to_setting(shift, 'discover_no_type') };
|
||||
|
||||
my $defaults = var('sidebar_defaults')->{'device_ports'}
|
||||
or return;
|
||||
|
||||
@@ -27,6 +27,8 @@ get '/ajax/content/admin/undiscoveredneighbors' => require_role admin => sub {
|
||||
# create a new row object to avoid hitting the DB in get_device()
|
||||
my $dev = schema('netdisco')->resultset('Device')->new({ip => $r->{remote_ip}});
|
||||
next unless is_discoverable( $dev, $r->{remote_type} );
|
||||
next if (not setting('discover_waps')) and $r->{remote_is_wap};
|
||||
next if (not setting('discover_phones')) and $r->{remote_is_phone};
|
||||
push @discoverable_results, $r;
|
||||
}
|
||||
return unless scalar @discoverable_results;
|
||||
|
||||
@@ -125,18 +125,13 @@ sub make_link_infostring {
|
||||
(my $left_name = lc($link->{left_dns} || $link->{left_name} || $link->{left_ip})) =~ s/$domain$//;
|
||||
(my $right_name = lc($link->{right_dns} || $link->{right_name} || $link->{right_ip})) =~ s/$domain$//;
|
||||
|
||||
if ($link->{aggports} == 1) {
|
||||
return sprintf '<b>%s:%s</b> (%s)<br><b>%s:%s</b> (%s)',
|
||||
$left_name, $link->{left_port}->[0],
|
||||
($link->{left_descr}->[0] || 'no description'),
|
||||
$right_name, $link->{right_port}->[0],
|
||||
($link->{right_descr}->[0] || 'no description');
|
||||
}
|
||||
else {
|
||||
return sprintf '<b>%s:(%s)</b><br><b>%s:(%s)</b>',
|
||||
$left_name, join(',', @{$link->{left_port}}),
|
||||
$right_name, join(',', @{$link->{right_port}});
|
||||
}
|
||||
my @zipped = List::MoreUtils::zip6
|
||||
@{$link->{left_port}}, @{$link->{left_descr}},
|
||||
@{$link->{right_port}}, @{$link->{right_descr}};
|
||||
|
||||
return join '<br><br>', map { sprintf '<b>%s:%s</b> (%s)<br><b>%s:%s</b> (%s)',
|
||||
$left_name, $_->[0], ($_->[1] || 'no description'),
|
||||
$right_name, $_->[2], ($_->[3] || 'no description') } @zipped;
|
||||
}
|
||||
|
||||
ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
@@ -179,17 +174,6 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
]) : ())
|
||||
}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' });
|
||||
|
||||
if ($vlan) {
|
||||
$links = $links->search({
|
||||
-or => [
|
||||
{ 'left_vlans.vlan' => $vlan },
|
||||
{ 'right_vlans.vlan' => $vlan },
|
||||
],
|
||||
}, {
|
||||
join => [qw/left_vlans right_vlans/],
|
||||
});
|
||||
}
|
||||
|
||||
while (my $link = $links->next) {
|
||||
push @{$data{'links'}}, {
|
||||
FROMID => $link->{left_ip},
|
||||
@@ -217,10 +201,19 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
join => 'throughput',
|
||||
})->with_times;
|
||||
|
||||
# filter by vlan for all or neighbors only
|
||||
if ($vlan) {
|
||||
$devices = $devices->search(
|
||||
{ 'vlans.vlan' => $vlan },
|
||||
{ join => 'vlans' }
|
||||
);
|
||||
}
|
||||
|
||||
DEVICE: while (my $device = $devices->next) {
|
||||
# if in neighbors or vlan mode then use %ok_dev to filter
|
||||
next DEVICE if (($mapshow eq 'neighbors') or $vlan)
|
||||
and (not $ok_dev{$device->ip});
|
||||
# if in neighbors mode then use %ok_dev to filter
|
||||
next DEVICE if ($device->ip ne $qdev->ip)
|
||||
and ($mapshow eq 'neighbors')
|
||||
and (not $ok_dev{$device->ip}); # showing only neighbors but no link
|
||||
|
||||
# if location picked then filter
|
||||
next DEVICE if ((scalar @lgrplist) and ((!defined $device->location)
|
||||
|
||||
@@ -25,25 +25,6 @@ get '/ajax/content/device/ports' => require_login sub {
|
||||
if ($f) {
|
||||
if (($prefer eq 'vlan') or (not $prefer and $f =~ m/^\d+$/)) {
|
||||
return unless $f =~ m/^\d+$/;
|
||||
|
||||
if (param('invert')) {
|
||||
$set = $set->search({
|
||||
'me.vlan' => { '!=' => $f },
|
||||
'port_vlans.vlan' => [
|
||||
'-or' => { '!=' => $f }, { '=' => undef }
|
||||
],
|
||||
}, { join => 'port_vlans' });
|
||||
}
|
||||
else {
|
||||
$set = $set->search({
|
||||
-or => {
|
||||
'me.vlan' => $f,
|
||||
'port_vlans.vlan' => $f,
|
||||
},
|
||||
}, { join => 'port_vlans' });
|
||||
}
|
||||
|
||||
return unless $set->count;
|
||||
}
|
||||
else {
|
||||
if (param('partial')) {
|
||||
@@ -120,7 +101,7 @@ get '/ajax/content/device/ports' => require_login sub {
|
||||
# now begin to join tables depending on the selected columns/options
|
||||
|
||||
# get vlans on the port
|
||||
# leave this query dormant (lazy) unless c_vmember is set
|
||||
# leave this query dormant (lazy) unless c_vmember is set or vlan filtering
|
||||
my $vlans = $set->search({}, {
|
||||
select => [
|
||||
'port',
|
||||
@@ -131,7 +112,7 @@ get '/ajax/content/device/ports' => require_login sub {
|
||||
group_by => 'me.port',
|
||||
});
|
||||
|
||||
if (param('c_vmember')) {
|
||||
if (param('c_vmember') or ($prefer eq 'vlan') or (not $prefer and $f =~ m/^\d+$/)) {
|
||||
$vlans = { map {(
|
||||
$_->port => {
|
||||
# DBIC smart enough to work out this should be an arrayref :)
|
||||
@@ -194,13 +175,37 @@ get '/ajax/content/device/ports' => require_login sub {
|
||||
# also get remote LLDP inventory if asked for
|
||||
$set = $set->with_remote_inventory if param('n_inventory');
|
||||
|
||||
# sort ports (empty set would be a 'no records' msg)
|
||||
my $results = [ sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } $set->all ];
|
||||
return unless scalar @$results;
|
||||
# run query
|
||||
my @results = $set->all;
|
||||
|
||||
# filter for tagged vlan using existing agg query,
|
||||
# which is better than join inflation
|
||||
if (($prefer eq 'vlan') or (not $prefer and $f =~ m/^\d+$/)) {
|
||||
if (param('invert')) {
|
||||
@results = grep {
|
||||
(!defined $_->vlan or $_->vlan ne $f)
|
||||
and
|
||||
(0 == scalar grep {defined and $_ ne $f} @{ $vlans->{$_->port}->{vlan_set} })
|
||||
} @results;
|
||||
}
|
||||
else {
|
||||
@results = grep {
|
||||
($_->vlan eq $f)
|
||||
or
|
||||
(scalar grep {defined and $_ eq $f} @{ $vlans->{$_->port}->{vlan_set} })
|
||||
} @results;
|
||||
}
|
||||
}
|
||||
|
||||
# sort ports
|
||||
@results = sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } @results;
|
||||
|
||||
# empty set would be a 'no records' msg
|
||||
return unless scalar @results;
|
||||
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/device/ports.tt', {
|
||||
results => $results,
|
||||
results => \@results,
|
||||
nodes => $nodes_name,
|
||||
ips => $ips_name,
|
||||
device => $device,
|
||||
@@ -210,7 +215,7 @@ get '/ajax/content/device/ports' => require_login sub {
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/device/ports_csv.tt', {
|
||||
results => $results,
|
||||
results => \@results,
|
||||
nodes => $nodes_name,
|
||||
ips => $ips_name,
|
||||
device => $device,
|
||||
|
||||
@@ -110,12 +110,12 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
||||
'ip', 'mac', 'dns', 'time_last', 'time_first',
|
||||
'active', 'node', 'age'
|
||||
],
|
||||
order_by => [{-asc => 'ip'}, {-desc => 'active'}],
|
||||
order_by => [{-asc => 'ip'}, {-desc => 'active'}, {-asc => 'node'}],
|
||||
}
|
||||
)->as_query;
|
||||
|
||||
my $rs;
|
||||
if ( $start && $end ) {
|
||||
if ( $start and $end ) {
|
||||
$start = $start . ' 00:00:00';
|
||||
$end = $end . ' 23:59:59';
|
||||
|
||||
|
||||
@@ -27,35 +27,48 @@ ajax '/ajax/content/search/node' => require_login sub {
|
||||
my @active = (param('archived') ? () : (-bool => 'active'));
|
||||
|
||||
my (@times, @wifitimes, @porttimes);
|
||||
if ($start and $end) {
|
||||
if ( $start and $end ) {
|
||||
$start = $start . ' 00:00:00';
|
||||
$end = $end . ' 23:59:59';
|
||||
|
||||
if ($agenot) {
|
||||
@times = (-or => [
|
||||
time_first => [ { '<', $start }, undef ],
|
||||
time_last => { '>', $end },
|
||||
time_first => [ undef ],
|
||||
time_last => [ { '<', $start }, { '>', $end } ]
|
||||
]);
|
||||
@wifitimes = (-or => [
|
||||
time_last => { '<', $start },
|
||||
time_last => { '>', $end },
|
||||
time_last => [ undef ],
|
||||
time_last => [ { '<', $start }, { '>', $end } ],
|
||||
]);
|
||||
@porttimes = (-or => [
|
||||
creation => { '<', $start },
|
||||
creation => { '>', $end },
|
||||
creation => [ undef ],
|
||||
creation => [ { '<', $start }, { '>', $end } ]
|
||||
]);
|
||||
}
|
||||
else {
|
||||
@times = (-and => [
|
||||
time_first => { '>=', $start },
|
||||
time_last => { '<=', $end },
|
||||
@times = (-or => [
|
||||
-and => [
|
||||
time_first => undef,
|
||||
time_last => undef,
|
||||
],
|
||||
-and => [
|
||||
time_last => { '>=', $start },
|
||||
time_last => { '<=', $end },
|
||||
],
|
||||
]);
|
||||
@wifitimes = (-and => [
|
||||
time_last => { '>=', $start },
|
||||
time_last => { '<=', $end },
|
||||
@wifitimes = (-or => [
|
||||
time_last => undef,
|
||||
-and => [
|
||||
time_last => { '>=', $start },
|
||||
time_last => { '<=', $end },
|
||||
],
|
||||
]);
|
||||
@porttimes = (-and => [
|
||||
creation => { '>=', $start },
|
||||
creation => { '<=', $end },
|
||||
@porttimes = (-or => [
|
||||
creation => undef,
|
||||
-and => [
|
||||
creation => { '>=', $start },
|
||||
creation => { '<=', $end },
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ ajax '/ajax/data/port/typeahead' => require_login sub {
|
||||
if $port;
|
||||
|
||||
my $results = [
|
||||
map {{ label => (sprintf "%s (%s)", $_->port, $_->name), value => $_->port }}
|
||||
map {{ label => (sprintf "%s (%s)", $_->port, ($_->name || '')), value => $_->port }}
|
||||
sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } $set->all
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user