diff --git a/Build.PL b/Build.PL index 12b01f19..1b1e7abd 100644 --- a/Build.PL +++ b/Build.PL @@ -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', diff --git a/lib/App/Netdisco/DB.pm b/lib/App/Netdisco/DB.pm index 6848f4d0..84ebd55f 100644 --- a/lib/App/Netdisco/DB.pm +++ b/lib/App/Netdisco/DB.pm @@ -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'; diff --git a/lib/App/Netdisco/DB/Result/DevicePort.pm b/lib/App/Netdisco/DB/Result/DevicePort.pm index 59b528ae..d90b6cd6 100644 --- a/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -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", diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index ad19cda7..04384b40 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -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,9 +301,10 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { type => $i_type->{$entry}, vlan => $i_vlan->{$entry}, pvid => $i_vlan->{$entry}, - is_master => 'false', - slave_of => undef, - lastchange => $lc, + 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]; diff --git a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm index 4b423b05..1ec3af17 100644 --- a/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm +++ b/lib/App/Netdisco/Worker/Plugin/Macsuck/Nodes.pm @@ -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}; diff --git a/share/schema_versions/App-Netdisco-DB-71-72-PostgreSQL.sql b/share/schema_versions/App-Netdisco-DB-71-72-PostgreSQL.sql new file mode 100644 index 00000000..39727b5a --- /dev/null +++ b/share/schema_versions/App-Netdisco-DB-71-72-PostgreSQL.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE device_port ADD COLUMN "has_subinterfaces" bool DEFAULT false NOT NULL; + +COMMIT; diff --git a/share/views/ajax/device/ports.tt b/share/views/ajax/device/ports.tt index 612ee7d1..a0b74655 100644 --- a/share/views/ajax/device/ports.tt +++ b/share/views/ajax/device/ports.tt @@ -111,7 +111,7 @@ [% END %] [% END %] - [% IF row.is_master %] + [% IF row.is_master OR row.has_subinterfaces %]   [% END %] [% row.port | html_entity %] diff --git a/share/views/sidebar/device/ports.tt b/share/views/sidebar/device/ports.tt index 81f1a562..9ca20a0c 100644 --- a/share/views/sidebar/device/ports.tt +++ b/share/views/sidebar/device/ports.tt @@ -48,7 +48,7 @@
  •   Wireless Client
  •   Wireless Access Point
  •   Archived Data
  • -
  •   Link Aggregate
  • +
  •   Interface Group
  • [% IF user_has_role('port_control') %]
  •   Click "Update View"
  • [% END %]