[#74] Device Name / DNS mismatches report
This commit is contained in:
		| @@ -0,0 +1,25 @@ | ||||
| package App::Netdisco::DB::Result::Virtual::DeviceDnsMismatch; | ||||
|  | ||||
| use strict; | ||||
| use warnings; | ||||
|  | ||||
| use utf8; | ||||
| use base 'App::Netdisco::DB::Result::Device'; | ||||
|  | ||||
| __PACKAGE__->load_components('Helper::Row::SubClass'); | ||||
| __PACKAGE__->subclass; | ||||
|  | ||||
| __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||||
| __PACKAGE__->table('device_dns_mismatch'); | ||||
| __PACKAGE__->result_source_instance->is_virtual(1); | ||||
| __PACKAGE__->result_source_instance->view_definition(<<'ENDSQL'); | ||||
| SELECT * | ||||
| FROM device | ||||
| WHERE dns IS NULL | ||||
|   OR name IS NULL | ||||
|   OR lower(trim(TRAILING ? | ||||
|                 FROM dns)::text) != lower(trim(TRAILING ? | ||||
|                                                FROM name)::text) | ||||
| ENDSQL | ||||
|  | ||||
| 1; | ||||
| @@ -0,0 +1,37 @@ | ||||
| package App::Netdisco::Web::Plugin::Report::DeviceDnsMismatch; | ||||
|  | ||||
| use Dancer ':syntax'; | ||||
| use Dancer::Plugin::DBIC; | ||||
| use Dancer::Plugin::Auth::Extensible; | ||||
|  | ||||
| use App::Netdisco::Web::Plugin; | ||||
|  | ||||
| register_report( | ||||
|     {   category     => 'Device', | ||||
|         tag          => 'devicednsmismatch', | ||||
|         label        => 'Device Name / DNS Mismatches', | ||||
|         provides_csv => 1, | ||||
|     } | ||||
| ); | ||||
|  | ||||
| get '/ajax/content/report/devicednsmismatch' => require_login sub { | ||||
|      | ||||
|     my $suffix = setting('domain_suffix') || ''; | ||||
|  | ||||
|     my $rs = schema('netdisco')->resultset('Virtual::DeviceDnsMismatch') | ||||
|         ->search( undef, { bind => [ $suffix, $suffix ] } ); | ||||
|  | ||||
|     return unless $rs->has_rows; | ||||
|  | ||||
|     if ( request->is_ajax ) { | ||||
|         template 'ajax/report/devicednsmismatch.tt', { results => $rs, }, | ||||
|             { layout => undef }; | ||||
|     } | ||||
|     else { | ||||
|         header( 'Content-Type' => 'text/comma-separated-values' ); | ||||
|         template 'ajax/report/devicednsmismatch_csv.tt', { results => $rs, }, | ||||
|             { layout => undef }; | ||||
|     } | ||||
| }; | ||||
|  | ||||
| 1; | ||||
		Reference in New Issue
	
	Block a user