« blib/lib/App/Netdisco/DB/Result/Virtual/NodesDiscovered.pm
↑ Summary
blib/lib/App/Netdisco/DB/Result/Virtual/PollerPerformance.pm »
| 1 | package App::Netdisco::DB::Result::Virtual::OrphanedDevices; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use utf8; | ||
| 7 | use base 'App::Netdisco::DB::Result::Device'; | ||
| 8 | |||
| 9 | __PACKAGE__->load_components('Helper::Row::SubClass'); | ||
| 10 | __PACKAGE__->subclass; | ||
| 11 | |||
| 12 | __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||
| 13 | __PACKAGE__->table('orphaned_devices'); | ||
| 14 | __PACKAGE__->result_source_instance->is_virtual(1); | ||
| 15 | __PACKAGE__->result_source_instance->view_definition(<<'ENDSQL'); | ||
| 16 | SELECT * | ||
| 17 | FROM device | ||
| 18 | WHERE ip NOT IN | ||
| 19 | ( SELECT DISTINCT dp.ip AS ip | ||
| 20 | FROM | ||
| 21 | (SELECT device_port.ip, | ||
| 22 | device_port.remote_ip | ||
| 23 | FROM device_port | ||
| 24 | WHERE device_port.remote_port IS NOT NULL | ||
| 25 | GROUP BY device_port.ip, | ||
| 26 | device_port.remote_ip | ||
| 27 | ORDER BY device_port.ip) dp | ||
| 28 | LEFT JOIN device_ip_resolved di ON dp.remote_ip = di.alias | ||
| 29 | WHERE di.ip IS NOT NULL) | ||
| 30 | ENDSQL | ||
| 31 | |||
| 32 | 1; |