[#74] Device Name / DNS mismatches report

This commit is contained in:
Eric A. Miller
2014-01-26 20:50:01 -05:00
parent 00b370ed0e
commit e23c30f0be
6 changed files with 100 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
[NEW FEATURES]
* [#86] Use Vendor abbrevs to enhance node display in device port view
* [#74] Device Name / DNS mismatches report
[ENHANCEMENTS]

View File

@@ -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;

View File

@@ -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;

View File

@@ -43,6 +43,7 @@ web_plugins:
- Report::HalfDuplex
- Report::DeviceAddrNoDNS
- Report::DeviceByLocation
- Report::DeviceDnsMismatch
- Report::DevicePoeStatus
- Report::DuplexMismatch
- Report::IpInventory

View File

@@ -0,0 +1,23 @@
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<thead>
<tr>
<th>Name</th>
<th>DNS</th>
<th>IP Address</th>
<th>Contact</th>
<th>Location</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td><a href="[% search_device %]&q=[% row.dns || row.ip | uri %]">
[% row.name | html_entity %]</a>
<td>[% row.dns | html_entity %]</td>
<td>[% row.ip | html_entity %]</td>
<td>[% row.contact | html_entity %]</td>
<td>[% row.location | html_entity %]</td>
</tr>
[% END %]
</tbody>
</table>

View File

@@ -0,0 +1,13 @@
[% USE CSV -%]
[% CSV.dump([ 'Name' 'DNS' 'IP Address' 'Contact' 'Location' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% mylist.push(row.name) %]
[% mylist.push(row.dns) %]
[% mylist.push(row.ip) %]
[% mylist.push(row.contact) %]
[% mylist.push(row.location) %]
[% CSV.dump(mylist) %]
[% END %]