From c2600ac550fb8311818f439a7e527017605f7124 Mon Sep 17 00:00:00 2001 From: ram Date: Sat, 23 Feb 2019 15:13:44 +0100 Subject: [PATCH] Change location of ifindex to DevicePortProperties * instead of DevicePort * as requested by Oliver in PR #513 review --- lib/App/Netdisco/DB/Result/DevicePort.pm | 2 -- lib/App/Netdisco/DB/Result/DevicePortProperties.pm | 2 ++ .../Netdisco/Worker/Plugin/Discover/PortProperties.pm | 11 +++++++++++ lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 1 - .../App-Netdisco-DB-53-54-PostgreSQL.sql | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/DevicePort.pm b/lib/App/Netdisco/DB/Result/DevicePort.pm index 73f8d659..216cf869 100644 --- a/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -69,8 +69,6 @@ __PACKAGE__->add_columns( { data_type => "integer", is_nullable => 1 }, "lastchange", { data_type => "bigint", is_nullable => 1 }, - "ifindex", - { data_type => "bigint", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("port", "ip"); diff --git a/lib/App/Netdisco/DB/Result/DevicePortProperties.pm b/lib/App/Netdisco/DB/Result/DevicePortProperties.pm index 81ea937b..b25fdaaf 100644 --- a/lib/App/Netdisco/DB/Result/DevicePortProperties.pm +++ b/lib/App/Netdisco/DB/Result/DevicePortProperties.pm @@ -29,6 +29,8 @@ __PACKAGE__->add_columns( { data_type => "bigint", is_nullable => 1 }, "faststart", { data_type => "boolean", is_nullable => 1 }, + "ifindex", + { data_type => "bigint", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("port", "ip"); diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm index 108d8046..8b492021 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm @@ -101,6 +101,17 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { $properties{ $port }->{remote_serial} = $rem_serial->{ $idx }; } + foreach my $idx (keys %$interfaces) { + my $port = $interfaces->{$idx} or next; + if (!defined $device_ports->{$port}) { + debug sprintf ' [%s] properties/ifindex - local port %s already skipped, ignoring', + $device->ip, $port; + next; + } + + $properties{ $port }->{ifindex} = $idx; + } + return Status->info(" [$device] no port properties to record") unless scalar keys %properties; diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index a8722ef4..63240c3d 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -229,7 +229,6 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { type => $i_type->{$entry}, vlan => $i_vlan->{$entry}, pvid => $i_vlan->{$entry}, - ifindex => $entry, is_master => 'false', slave_of => undef, lastchange => $lc, diff --git a/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql b/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql index c259afc5..64454a87 100644 --- a/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql +++ b/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql @@ -1,5 +1,5 @@ BEGIN; -ALTER TABLE device_port ADD COLUMN "ifindex" bigint; +ALTER TABLE device_port_properties ADD COLUMN "ifindex" bigint; COMMIT;