Search device by CDP/LLDP advertised ID or Type
This commit is contained in:
@@ -177,6 +177,17 @@ __PACKAGE__->has_many(
|
||||
'ip', { join_type => 'RIGHT' }
|
||||
);
|
||||
|
||||
=head2 neighbor_ports
|
||||
|
||||
Returns the set of ports on other devices which connect to this device
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
neighbor_ports => 'App::Netdisco::DB::Result::DevicePort',
|
||||
{ 'foreign.remote_ip' => 'self.ip' },
|
||||
);
|
||||
|
||||
=head2 community
|
||||
|
||||
Returns the row from the community string table, if one exists.
|
||||
|
||||
@@ -176,6 +176,14 @@ Will match exactly the C<os_ver> field, which is the operating sytem software ve
|
||||
|
||||
Will match exactly the C<vendor> (manufacturer).
|
||||
|
||||
=item neighbor_id
|
||||
|
||||
Will match the device if it has advertised this ID to a CDP/LLDP neighbor.
|
||||
|
||||
=item neighbor_type
|
||||
|
||||
Will match the device if it has advertised this Type to a CDP/LLDP neighbor.
|
||||
|
||||
=item dns
|
||||
|
||||
Can match any of the Device IP address aliases as a substring.
|
||||
@@ -234,6 +242,11 @@ sub search_by_field {
|
||||
($p->{layers} ? ('me.layers' =>
|
||||
{ '-ilike' => "\%$layer_string" }) : ()),
|
||||
|
||||
($p->{neighbor_id} ? ('neighbor_ports.remote_id' =>
|
||||
{ '-ilike' => "\%$p->{neighbor_id}\%" }) : ()),
|
||||
($p->{neighbor_type} ? ('neighbor_ports.remote_type' =>
|
||||
{ '-ilike' => "\%$p->{neighbor_type}\%" }) : ()),
|
||||
|
||||
($p->{model} ? ('me.model' =>
|
||||
{ '-in' => $p->{model} }) : ()),
|
||||
($p->{os_ver} ? ('me.os_ver' =>
|
||||
@@ -256,8 +269,8 @@ sub search_by_field {
|
||||
},
|
||||
{
|
||||
order_by => [qw/ me.dns me.ip /],
|
||||
(($p->{dns} or $p->{ip}) ? (
|
||||
join => 'device_ips',
|
||||
(($p->{dns} or $p->{ip} or $p->{neighbor_id} or $p->{neighbor_type}) ? (
|
||||
join => [qw/device_ips neighbor_ports/],
|
||||
distinct => 1,
|
||||
) : ()),
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ register_search_tab(
|
||||
# device with various properties or a default match-all
|
||||
get '/ajax/content/search/device' => require_login sub {
|
||||
my $has_opt = List::MoreUtils::any { param($_) }
|
||||
qw/name location dns ip description model os_ver vendor layers/;
|
||||
qw/name location dns ip description model os_ver vendor layers
|
||||
neighbor_id neighbor_type/;
|
||||
my $rs;
|
||||
|
||||
if ($has_opt) {
|
||||
|
||||
Reference in New Issue
Block a user