use i_subinterfaces to group vlan subinterfaces like link aggregates in device ports view

This commit is contained in:
Oliver Gorwits
2022-08-02 17:42:58 +01:00
parent 7ac5b6c4b7
commit a1aac2777d
8 changed files with 37 additions and 9 deletions

View File

@@ -87,7 +87,7 @@ Module::Build->new(
'Starman' => '0.4008',
'Storable' => '0',
'Sys::SigAction' => '0',
'SNMP::Info' => '3.84',
'SNMP::Info' => '3.85',
'SQL::Abstract' => '1.85',
'SQL::Translator' => '0.11024',
'Sub::Util' => '1.40',

View File

@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
);
our # try to hide from kwalitee
$VERSION = 71; # schema version used for upgrades, keep as integer
$VERSION = 72; # schema version used for upgrades, keep as integer
use Path::Class;
use File::ShareDir 'dist_dir';

View File

@@ -55,6 +55,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"remote_id",
{ data_type => "text", is_nullable => 1 },
"has_subinterfaces",
{ data_type => "boolean", is_nullable => 0, default_value => \"false" },
"is_master",
{ data_type => "boolean", is_nullable => 0, default_value => \"false" },
"slave_of",

View File

@@ -197,6 +197,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
my $i_vlan = $snmp->i_vlan;
my $i_lastchange = $snmp->i_lastchange;
my $agg_ports = $snmp->agg_ports;
my $i_subs = $snmp->i_subinterfaces;
# clear the cached uptime and get a new one
my $dev_uptime = ($device->is_pseudo ? $snmp->uptime : $snmp->load_uptime);
@@ -300,6 +301,7 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
type => $i_type->{$entry},
vlan => $i_vlan->{$entry},
pvid => $i_vlan->{$entry},
has_subinterfaces => 'false',
is_master => 'false',
slave_of => undef,
lastchange => $lc,
@@ -317,6 +319,21 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
$interfaces{$master}->{is_master} = 'true';
}
# also for VLAN subinterfaces
foreach my $pidx (keys %$i_subs) {
my $parent = $interfaces->{$pidx} or next;
# parent without subinterfaces?
next unless defined $i_subs->{$pidx}
and ref [] eq ref $i_subs->{$pidx}
and scalar @{ $i_subs->{$pidx} };
$interfaces{$parent}->{has_subinterfaces} = 'true';
foreach my $sidx (@{ $i_subs->{$pidx} }) {
my $sub = $interfaces->{$sidx} or next;
$interfaces{$sub}->{slave_of} = $parent;
}
}
# support for Hooks
vars->{'hook_data'}->{'ports'} = [values %interfaces];

View File

@@ -443,8 +443,12 @@ sub walk_fwtable {
# possibly move node to lag master
if (defined $device_port->slave_of
and exists $device_ports->{$device_port->slave_of}) {
$port = $device_port->slave_of;
$device_ports->{$port}->update({is_uplink => \'true'});
$parent = $device_port->slave_of;
$device_ports->{$parent}->update({is_uplink => \'true'});
# VLAN subinterfaces can be set uplink,
# but we don't want to move nodes there (so check is_master).
$port = $parent if $device_ports->{$parent}->is_master;
}
++$cache->{$vlan}->{$port}->{$mac};

View File

@@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE device_port ADD COLUMN "has_subinterfaces" bool DEFAULT false NOT NULL;
COMMIT;

View File

@@ -111,7 +111,7 @@
[% END %]
[% END %]
<a class="nd_this-port-only nd_port-only-first" href="[% device_ports | none %]&q=[% params.q | uri %]&f=[% row.port | uri %]&prefer=port">
[% IF row.is_master %]
[% IF row.is_master OR row.has_subinterfaces %]
<small><i class="icon-group muted"></i></small>&nbsp;
[% END %]
[% row.port | html_entity %]</a>

View File

@@ -48,7 +48,7 @@
<li><i class="icon-li icon-signal"></i>&nbsp; Wireless Client</li>
<li><i class="icon-li icon-rss"></i>&nbsp; Wireless Access Point</li>
<li><i class="icon-li icon-book"></i>&nbsp; Archived Data</li>
<li><i class="icon-li icon-group"></i>&nbsp; Link Aggregate</li>
<li><i class="icon-li icon-group"></i>&nbsp; Interface Group</li>
[% IF user_has_role('port_control') %]
<li><i class="icon-li icon-refresh icon-spin"></i>&nbsp; Click "Update View"</li>
[% END %]