From d572334a7303568c70a094ce8d57d62dd7344b2c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 21 Sep 2017 19:50:52 +0100 Subject: [PATCH 1/4] #253 add some dependencies - what harm can it do? --- Build.PL | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Build.PL b/Build.PL index 690bc4bd..b5d2adb4 100644 --- a/Build.PL +++ b/Build.PL @@ -51,6 +51,8 @@ Module::Build->new( 'Opcode' => '1.07', 'Path::Class' => '0.32', 'Plack' => '1.0023', + 'Plack::Handler::Twiggy' => '0', + 'Plack::Middleware::Debug' => '0', 'Plack::Middleware::Expires' => '0.03', 'Plack::Middleware::ReverseProxy' => '0.15', 'Pod::Usage' => 0, From 5ee0206c9121dbd81d3c89f428615e5eff81e63d Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 21 Sep 2017 19:53:56 +0100 Subject: [PATCH 2/4] #346 custom reports should allow trailing sql semicolon --- lib/App/Netdisco/Web/GenericReport.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Web/GenericReport.pm b/lib/App/Netdisco/Web/GenericReport.pm index 84a2cda8..800fa2ef 100644 --- a/lib/App/Netdisco/Web/GenericReport.pm +++ b/lib/App/Netdisco/Web/GenericReport.pm @@ -28,8 +28,9 @@ foreach my $report (@{setting('reports')}) { my $schema = ($report->{database} || 'netdisco'); my $rs = schema($schema)->resultset('Virtual::GenericReport')->result_source; + (my $query = $report->{query}) =~ s/;$//; - $rs->view_definition($report->{query}); + $rs->view_definition($query); $rs->remove_columns($rs->columns); $rs->add_columns( exists $report->{query_columns} ? @{ $report->{query_columns} } From 65ba93acc0a15fd67d1256742831977b6b84a70f Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 21 Sep 2017 20:05:38 +0100 Subject: [PATCH 3/4] #342 Job Queue Add Hostname or FQDN --- lib/App/Netdisco/DB/Result/Admin.pm | 11 +++++++++++ lib/App/Netdisco/JobQueue/PostgreSQL.pm | 1 + share/views/ajax/admintask/jobqueue.tt | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/DB/Result/Admin.pm b/lib/App/Netdisco/DB/Result/Admin.pm index cc5daa54..27e0cf9f 100644 --- a/lib/App/Netdisco/DB/Result/Admin.pm +++ b/lib/App/Netdisco/DB/Result/Admin.pm @@ -90,6 +90,17 @@ __PACKAGE__->has_many( device_skips => 'App::Netdisco::DB::Result::DeviceSkip', { cascade_copy => 0, cascade_update => 0, cascade_delete => 0 } ); +=head2 target + +Returns the single C to which this Job entry was associated. + +The JOIN is of type LEFT, in case the C is not in the database. + +=cut + +__PACKAGE__->belongs_to( target => 'App::Netdisco::DB::Result::Device', + { 'foreign.ip' => 'self.device' }, { join_type => 'LEFT' } ); + =head1 METHODS =head2 summary diff --git a/lib/App/Netdisco/JobQueue/PostgreSQL.pm b/lib/App/Netdisco/JobQueue/PostgreSQL.pm index 6de293e1..0f1eda9c 100644 --- a/lib/App/Netdisco/JobQueue/PostgreSQL.pm +++ b/lib/App/Netdisco/JobQueue/PostgreSQL.pm @@ -251,6 +251,7 @@ sub jq_complete { sub jq_log { return schema('netdisco')->resultset('Admin')->search({}, { + prefetch => 'target', order_by => { -desc => [qw/entered device action/] }, rows => 50, })->with_times->hri->all; diff --git a/share/views/ajax/admintask/jobqueue.tt b/share/views/ajax/admintask/jobqueue.tt index b148969d..10ec7df6 100644 --- a/share/views/ajax/admintask/jobqueue.tt +++ b/share/views/ajax/admintask/jobqueue.tt @@ -39,7 +39,7 @@ [% IF row.action == 'discover' AND row.status == 'error' %] [% row.device | html_entity %] [% ELSE %] - [% row.device | html_entity %] + [% row.target.dns || row.device | html_entity %] [% END %] [% row.port | html_entity %] From 8dc4b9bc0e8f3062ea24cf17291bec671d7ba957 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 21 Sep 2017 20:12:22 +0100 Subject: [PATCH 4/4] #331 do not set community{_rw} defaults --- lib/App/Netdisco/Configuration.pm | 7 +++++++ share/config.yml | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Configuration.pm b/lib/App/Netdisco/Configuration.pm index 2606f3cb..410b993b 100644 --- a/lib/App/Netdisco/Configuration.pm +++ b/lib/App/Netdisco/Configuration.pm @@ -52,6 +52,13 @@ if (ref {} eq ref setting('database')) { # always set this $ENV{DBIC_TRACE_PROFILE} = 'console'; +# if snmp_auth or device_auth not set, add defaults to community{_rw} +if ((setting('snmp_auth') and 0 == scalar @{ setting('snmp_auth') }) + or (setting('device_auth') and 0 == scalar @{ setting('device_auth') })) { + config->{'community'} = [ @{setting('community')}, 'public' ]; + config->{'community_rw'} = [ @{setting('community_rw')}, 'private' ]; +} + # defaults for workers setting('workers')->{queue} ||= 'PostgreSQL'; if (exists setting('workers')->{interactives} diff --git a/share/config.yml b/share/config.yml index ddc1ef26..061320e8 100644 --- a/share/config.yml +++ b/share/config.yml @@ -124,8 +124,8 @@ host_groups: - 'fe80::/10' - '127.0.0.0/8' device_identity: [] -community: ['public'] -community_rw: ['private'] +community: [] +community_rw: [] snmp_auth: [] get_community: "" bulkwalk_off: false