From 1620feaa6aa9f3e2f1613d2cb2b79f99df2227b1 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Fri, 22 Feb 2019 22:53:20 +0100 Subject: [PATCH 1/3] tiny typo iteself -> itself --- lib/App/Netdisco/Util/Device.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Util/Device.pm b/lib/App/Netdisco/Util/Device.pm index a4b481fe..a6af95fa 100644 --- a/lib/App/Netdisco/Util/Device.pm +++ b/lib/App/Netdisco/Util/Device.pm @@ -100,8 +100,8 @@ sub delete_device { =head2 renumber_device( $current_ip, $new_ip ) Will update all records in Netdisco referring to the device with -C<$current_ip> to use C<$new_ip> instead, followed by renumbering the device -iteself. +C<$current_ip> to use C<$new_ip> instead, followed by renumbering the +device itself. Returns true if the transaction completes, else returns false. From 24a7e8047032bc99cacf3670d0b8ef89eda29e0b Mon Sep 17 00:00:00 2001 From: ram Date: Thu, 21 Feb 2019 22:15:12 +0100 Subject: [PATCH 2/3] PR for #510 - store ifindex in device_port --- lib/App/Netdisco/DB.pm | 2 +- lib/App/Netdisco/DB/Result/DevicePort.pm | 2 ++ lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 1 + share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql diff --git a/lib/App/Netdisco/DB.pm b/lib/App/Netdisco/DB.pm index 008b5369..5c589386 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 = 53; # schema version used for upgrades, keep as integer + $VERSION = 54; # 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 216cf869..73f8d659 100644 --- a/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -69,6 +69,8 @@ __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/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index 63240c3d..a8722ef4 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -229,6 +229,7 @@ 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 new file mode 100644 index 00000000..c259afc5 --- /dev/null +++ b/share/schema_versions/App-Netdisco-DB-53-54-PostgreSQL.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE device_port ADD COLUMN "ifindex" bigint; + +COMMIT; From c2600ac550fb8311818f439a7e527017605f7124 Mon Sep 17 00:00:00 2001 From: ram Date: Sat, 23 Feb 2019 15:13:44 +0100 Subject: [PATCH 3/3] 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;