From fc46384fc66f8c276cd6fbaf6581af8a5a4ef9ee Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 6 Jul 2020 19:49:57 +0100 Subject: [PATCH] #227 Do not overwrite partially retrieved data with null or incorrect values this and two related commits implements: - setting snmp_field_protection which can be used to protect any database field from having a null value set - extra device discover worker which prefetches SNMP interfaces and performs some sanity checks and comparison against the DB the two checks will return job status ERROR with CANCELLED if they see anything fishy. --- lib/App/Netdisco/Backend/Job.pm | 8 ++++++++ share/config.yml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Backend/Job.pm b/lib/App/Netdisco/Backend/Job.pm index 34e97f1b..4b8429f7 100644 --- a/lib/App/Netdisco/Backend/Job.pm +++ b/lib/App/Netdisco/Backend/Job.pm @@ -93,6 +93,8 @@ sub best_status { my $cur_level = 0; my $cur_status = ''; + return Status->error()->status if $job->is_cancelled; + foreach my $status (reverse @{ $job->_statuslist }) { next if $status->phase and $status->phase !~ m/^(?:early|main|store|late)$/; @@ -122,6 +124,12 @@ sub finalise_status { my $max_level = Status->error()->level; + if ($job->is_cancelled and scalar @{ $job->_statuslist }) { + $job->status( $job->_statuslist->[-1]->status ); + $job->log( $job->_statuslist->[-1]->log ); + return; + } + foreach my $status (reverse @{ $job->_statuslist }) { next if $status->phase and $status->phase !~ m/^(?:check|early|main|store|late)$/; diff --git a/share/config.yml b/share/config.yml index c3c22297..6b5842fd 100644 --- a/share/config.yml +++ b/share/config.yml @@ -233,7 +233,7 @@ snmpretries: 2 snmp_remoteport: {} snmp_field_protection: device: - serial: ['any'] + serial: ['group:__ANY__'] devices_no: [] devices_only: [] discover_no: []