Add Device addresses with DNS entries report
This commit is contained in:
@@ -665,4 +665,62 @@ sub with_poestats_as_hashref {
|
||||
return \@return;
|
||||
}
|
||||
|
||||
=head2 address_nodns_as_hashref
|
||||
|
||||
This is a modifier for C<search()> which returns a list of hash references
|
||||
for devices addresses without a corresponding DNS entry.
|
||||
|
||||
Note: The DNS resolver checks both reverse and forward entries of the
|
||||
address. Verify reverse and forward DNS entries if it appears an address
|
||||
was included erroneously.
|
||||
|
||||
Returned hash keys:
|
||||
|
||||
=over 4
|
||||
|
||||
=item ip
|
||||
|
||||
The primary IP address of the device.
|
||||
|
||||
=item dns
|
||||
|
||||
DNS entry of primary IP address of the device.
|
||||
|
||||
=item name
|
||||
|
||||
C<sysName> of the device.
|
||||
|
||||
=item location
|
||||
|
||||
C<sysLocation> of the device.
|
||||
|
||||
=item contact
|
||||
|
||||
C<sysContact> of the device.
|
||||
|
||||
=item alias
|
||||
|
||||
IP address belonging to the device without a corresponding DNS
|
||||
entry.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub address_nodns_as_hashref {
|
||||
my ( $rs, $cond, $attrs ) = @_;
|
||||
|
||||
my @return = $rs->search(
|
||||
{ 'device_ips.dns' => undef },
|
||||
{ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
|
||||
select => [ 'ip', 'dns', 'name', 'location', 'contact' ],
|
||||
join => [qw/device_ips/],
|
||||
'+columns' => [ { 'alias' => 'device_ips.alias' }, ],
|
||||
order_by => { -asc => [qw/me.ip device_ips.alias/] },
|
||||
}
|
||||
)->all;
|
||||
|
||||
return \@return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package App::Netdisco::Web::Plugin::Report::DeviceAddrNoDNS;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_report(
|
||||
{ category => 'Device',
|
||||
tag => 'deviceaddrnodns',
|
||||
label => 'Addresses without DNS Entries',
|
||||
provides_csv => 1,
|
||||
}
|
||||
);
|
||||
|
||||
get '/ajax/content/report/deviceaddrnodns' => require_login sub {
|
||||
my $results = schema('netdisco')->resultset('Device')
|
||||
->address_nodns_as_hashref;
|
||||
|
||||
return unless scalar $results;
|
||||
|
||||
if ( request->is_ajax ) {
|
||||
template 'ajax/report/deviceaddrnodns.tt', { results => $results, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/report/deviceaddrnodns_csv.tt',
|
||||
{ results => $results, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user