link infostrings!

This commit is contained in:
Oliver Gorwits
2017-12-30 23:41:19 +00:00
parent f3ba260142
commit 6453f99b28
5 changed files with 47 additions and 4 deletions

View File

@@ -15,24 +15,28 @@ __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
__PACKAGE__->table('device_links');
__PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
SELECT dp.ip AS left_ip, array_agg(dp.port) AS left_port, array_agg(dp.name) AS left_descr,
SELECT dp.ip AS left_ip, ld.dns AS left_dns, ld.name AS left_name,
array_agg(dp.port) AS left_port, array_agg(dp.name) AS left_descr,
sum(btrim(dp.speed, ' MGTbps')::float
* (CASE btrim(dp.speed, ' 0123456789.')
WHEN 'Gbps' THEN 1000
WHEN 'Tbps' THEN 1000000
ELSE 1 END)) AS aggspeed,
count(*) AS aggports,
dp2.ip AS right_ip, array_agg(dp2.port) AS right_port, array_agg(dp2.name) AS right_descr
dp2.ip AS right_ip, rd.dns AS right_dns, rd.name AS right_name,
array_agg(dp2.port) AS right_port, array_agg(dp2.name) AS right_descr
FROM device_port dp
INNER JOIN device ld ON dp.ip = ld.ip
INNER JOIN device_ip di ON dp.remote_ip = di.alias
INNER JOIN device rd ON di.ip = rd.ip
INNER JOIN device_port dp2 ON (di.ip = dp2.ip AND dp.remote_port = dp2.port)
WHERE dp.remote_port IS NOT NULL
AND dp.type = 'ethernetCsmacd'
AND dp.speed LIKE '%bps'
AND dp.ip <= dp2.ip
GROUP BY left_ip, right_ip
GROUP BY left_ip, left_dns, left_name, right_ip, right_dns, right_name
ORDER BY dp.ip
ENDSQL
);
@@ -41,6 +45,12 @@ __PACKAGE__->add_columns(
'left_ip' => {
data_type => 'inet',
},
'left_dns' => {
data_type => 'text',
},
'left_name' => {
data_type => 'text',
},
'left_port' => {
data_type => '[text]',
},
@@ -56,6 +66,12 @@ __PACKAGE__->add_columns(
'right_ip' => {
data_type => 'inet',
},
'right_dns' => {
data_type => 'text',
},
'right_name' => {
data_type => 'text',
},
'right_port' => {
data_type => '[text]',
},