diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Device.pm b/Netdisco/lib/App/Netdisco/DB/Result/Device.pm index 19aefbc2..f571714d 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/Device.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/Device.pm @@ -92,6 +92,15 @@ all the interface IP aliases configured on the Device. __PACKAGE__->has_many( device_ips => 'App::Netdisco::DB::Result::DeviceIp', 'ip' ); +=head2 device_modules + +Returns rows from the C table which relate to this Device. That +is, all the constituent modiles within the Device. + +=cut + +__PACKAGE__->has_many( device_modules => 'App::Netdisco::DB::Result::DeviceModule', 'ip' ); + =head2 vlans Returns the C entries for this Device. That is, the list of VLANs diff --git a/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm b/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm index c2cca09e..5c8ee32a 100644 --- a/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/Netdisco/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -275,7 +275,7 @@ The following fields are inspected for a match: =item contact -=item serial +=item serial (including modules) =item location @@ -287,6 +287,7 @@ The following fields are inspected for a match: =item ip (including aliases) + =back =cut @@ -318,6 +319,7 @@ sub search_fuzzy { -or => [ 'me.contact' => { '-ilike' => $q }, 'me.serial' => { '-ilike' => $q }, + 'device_modules.serial' => { '-ilike' => $q }, 'me.location' => { '-ilike' => $q }, 'me.name' => { '-ilike' => $q }, 'me.description' => { '-ilike' => $q }, @@ -330,7 +332,7 @@ sub search_fuzzy { }, { order_by => [qw/ me.dns me.ip /], - join => 'device_ips', + join => [qw/device_ips device_modules/], distinct => 1, } );