Avoid displaying all VLANs on device ports when there are 1000's

This commit is contained in:
Oliver Gorwits
2015-02-15 15:36:17 +00:00
parent 3cc3f873d8
commit 0993af18e4
5 changed files with 63 additions and 37 deletions

View File

@@ -36,6 +36,15 @@ but they are backwards compatible.
=back
=head1 2.031006
=head2 General Notices
When displaying device ports, Netdisco will now avoid showing VLAN Membership
if it looks like there are a large number of VLANs on many ports. This is an
average of the VLANs per port, configurable in
<deviceport_vlan_membership_threshold>. The default is 150.
=head1 2.031005
=head2 General Notices

View File

@@ -123,9 +123,16 @@ get '/ajax/content/device/ports' => require_login sub {
# make sure query asks for formatted timestamps when needed
$set = $set->with_times if param('c_lastchange');
# get vlans on the port
$set = $set->search_rs({}, { prefetch => 'all_port_vlans' })->with_vlan_count
if param('c_vmember');
# get vlans on the port, if there aren't too many
my $port_cnt = $device->ports->count() || 1;
my $vlan_cnt = $device->port_vlans->count() || 1;
my $vmember_ok =
(($vlan_cnt / $port_cnt) <= setting('deviceport_vlan_membership_threshold'));
if ($vmember_ok) {
$set = $set->search_rs({}, { prefetch => 'all_port_vlans' })->with_vlan_count
if param('c_vmember');
}
# what kind of nodes are we interested in?
my $nodes_name = (param('n_archived') ? 'nodes' : 'active_nodes');
@@ -165,6 +172,7 @@ get '/ajax/content/device/ports' => require_login sub {
results => $results,
nodes => $nodes_name,
device => $device,
vmember_ok => $vmember_ok,
}, { layout => undef };
}
else {