« blib/lib/App/Netdisco/DB/Result/Virtual/UnDirEdgesAgg.pm
↑ Summary
blib/lib/App/Netdisco/DB/Result/Virtual/UserRole.pm »
| 1 | package App::Netdisco::DB::Result::Virtual::UndiscoveredNeighbors; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use utf8; | ||
| 7 | use base 'DBIx::Class::Core'; | ||
| 8 | |||
| 9 | __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||
| 10 | |||
| 11 | __PACKAGE__->table('undiscovered_neighbors'); | ||
| 12 | __PACKAGE__->result_source_instance->is_virtual(1); | ||
| 13 | __PACKAGE__->result_source_instance->view_definition(<<'ENDSQL'); | ||
| 14 | SELECT DISTINCT ON (p.remote_ip, p.port) | ||
| 15 | d.ip, d.name, d.dns, | ||
| 16 | p.port, p.name AS port_description, | ||
| 17 | p.remote_ip, p.remote_id, p.remote_type, p.remote_port, | ||
| 18 | dpp.remote_is_discoverable, dpp.remote_is_wap, dpp.remote_is_phone, dpp.remote_dns, | ||
| 19 | l.log AS comment, | ||
| 20 | a.log, a.finished | ||
| 21 | |||
| 22 | FROM device_port p | ||
| 23 | |||
| 24 | INNER JOIN device d USING (ip) | ||
| 25 | LEFT OUTER JOIN device_skip ds | ||
| 26 | ON ('discover' = ANY(ds.actionset) AND p.remote_ip = ds.device) | ||
| 27 | LEFT OUTER JOIN device_port_properties dpp USING (ip, port) | ||
| 28 | LEFT OUTER JOIN device_port_log l USING (ip, port) | ||
| 29 | LEFT OUTER JOIN admin a | ||
| 30 | ON (p.remote_ip = a.device AND a.action = 'discover') | ||
| 31 | |||
| 32 | WHERE | ||
| 33 | ds.device IS NULL | ||
| 34 | AND dpp.remote_is_discoverable | ||
| 35 | AND ((p.remote_ip NOT IN (SELECT alias FROM device_ip)) | ||
| 36 | OR ((p.remote_ip IS NULL) AND p.is_uplink)) | ||
| 37 | |||
| 38 | ORDER BY | ||
| 39 | p.remote_ip ASC, | ||
| 40 | p.port ASC, | ||
| 41 | l.creation DESC, | ||
| 42 | a.finished DESC | ||
| 43 | ENDSQL | ||
| 44 | |||
| 45 | __PACKAGE__->add_columns( | ||
| 46 | "ip", | ||
| 47 | { data_type => "inet", is_nullable => 0 }, | ||
| 48 | "name", | ||
| 49 | { data_type => "text", is_nullable => 1 }, | ||
| 50 | "dns", | ||
| 51 | { data_type => "text", is_nullable => 1 }, | ||
| 52 | "port", | ||
| 53 | { data_type => "text", is_nullable => 0 }, | ||
| 54 | "port_description", | ||
| 55 | { data_type => "text", is_nullable => 0 }, | ||
| 56 | "remote_ip", | ||
| 57 | { data_type => "inet", is_nullable => 1 }, | ||
| 58 | "remote_port", | ||
| 59 | { data_type => "text", is_nullable => 1 }, | ||
| 60 | "remote_type", | ||
| 61 | { data_type => "text", is_nullable => 1 }, | ||
| 62 | "remote_id", | ||
| 63 | { data_type => "text", is_nullable => 1 }, | ||
| 64 | "remote_is_discoverable", | ||
| 65 | { data_type => "boolean", is_nullable => 1 }, | ||
| 66 | "remote_is_wap", | ||
| 67 | { data_type => "boolean", is_nullable => 1 }, | ||
| 68 | "remote_is_phone", | ||
| 69 | { data_type => "boolean", is_nullable => 1 }, | ||
| 70 | "remote_dns", | ||
| 71 | { data_type => "text", is_nullable => 1 }, | ||
| 72 | "comment", | ||
| 73 | { data_type => "text", is_nullable => 1 }, | ||
| 74 | "log", | ||
| 75 | { data_type => "text", is_nullable => 1 }, | ||
| 76 | "finished", | ||
| 77 | { data_type => "timestamp", is_nullable => 1 }, | ||
| 78 | ); | ||
| 79 | |||
| 80 | 1; |