diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index 7ac0df5a..6efad9c1 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -371,6 +371,12 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { vars->{'hook_data'}->{'ports'} = [values %deviceports]; schema('netdisco')->resultset('DevicePort')->txn_do_locked(sub { + # backup the custom_fields + my @fields = grep {exists $deviceports{$_->{port}}} $device->ports + ->search(undef, {columns => [qw/port custom_fields/]})->hri->all; + $deviceports{$_->{port}}->{custom_fields} = $_->{custom_fields} + for @fields; + my $gone = $device->ports->delete({keep_nodes => 1}); debug sprintf ' [%s] interfaces - removed %d interfaces', $device->ip, $gone;