« blib/lib/App/Netdisco/Web/Plugin/Report/DeviceByLocation.pm
↑ Summary
blib/lib/App/Netdisco/Web/Plugin/Report/DevicePoeStatus.pm »
| 1 | package App::Netdisco::Web::Plugin::Report::DeviceDnsMismatch; | ||
| 2 | |||
| 3 | use Dancer ':syntax'; | ||
| 4 | use Dancer::Plugin::DBIC; | ||
| 5 | use Dancer::Plugin::Auth::Extensible; | ||
| 6 | |||
| 7 | use App::Netdisco::Web::Plugin; | ||
| 8 | |||
| 9 | register_report( | ||
| 10 | { category => 'Device', | ||
| 11 | tag => 'devicednsmismatch', | ||
| 12 | label => 'Device Name / DNS Mismatches', | ||
| 13 | provides_csv => 1, | ||
| 14 | api_endpoint => 1, | ||
| 15 | } | ||
| 16 | ); | ||
| 17 | |||
| 18 | get '/ajax/content/report/devicednsmismatch' => require_login sub { | ||
| 19 | |||
| 20 | (my $suffix = '***:'. setting('domain_suffix')) =~ s|\Q(?^\Eu?|(?|g; | ||
| 21 | |||
| 22 | my @results | ||
| 23 | = schema(vars->{'tenant'})->resultset('Virtual::DeviceDnsMismatch') | ||
| 24 | ->search( undef, { bind => [ $suffix, $suffix ] } ) | ||
| 25 | ->columns( [qw/ ip dns name location contact /] )->hri->all; | ||
| 26 | |||
| 27 | return unless scalar @results; | ||
| 28 | |||
| 29 | if ( request->is_ajax ) { | ||
| 30 | my $json = to_json( \@results ); | ||
| 31 | template 'ajax/report/devicednsmismatch.tt', { results => $json }, { layout => 'noop' }; | ||
| 32 | } | ||
| 33 | else { | ||
| 34 | header( 'Content-Type' => 'text/comma-separated-values' ); | ||
| 35 | template 'ajax/report/devicednsmismatch_csv.tt', | ||
| 36 | { results => \@results }, { layout => 'noop' }; | ||
| 37 | } | ||
| 38 | }; | ||
| 39 | |||
| 40 | 1; |