Move device addresses without DNS query out of model as it is unlikely to be used outside of the report.
This commit is contained in:
@@ -665,62 +665,4 @@ sub with_poestats_as_hashref {
|
|||||||
return \@return;
|
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;
|
1;
|
||||||
|
|||||||
@@ -15,19 +15,26 @@ register_report(
|
|||||||
);
|
);
|
||||||
|
|
||||||
get '/ajax/content/report/deviceaddrnodns' => require_login sub {
|
get '/ajax/content/report/deviceaddrnodns' => require_login sub {
|
||||||
my $results = schema('netdisco')->resultset('Device')
|
my @results = schema('netdisco')->resultset('Device')->search(
|
||||||
->address_nodns_as_hashref;
|
{ '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 unless scalar $results;
|
return unless scalar @results;
|
||||||
|
|
||||||
if ( request->is_ajax ) {
|
if ( request->is_ajax ) {
|
||||||
template 'ajax/report/deviceaddrnodns.tt', { results => $results, },
|
template 'ajax/report/deviceaddrnodns.tt', { results => \@results, },
|
||||||
{ layout => undef };
|
{ layout => undef };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||||
template 'ajax/report/deviceaddrnodns_csv.tt',
|
template 'ajax/report/deviceaddrnodns_csv.tt',
|
||||||
{ results => $results, },
|
{ results => \@results, },
|
||||||
{ layout => undef };
|
{ layout => undef };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user