add speed to retrieved devicelinks

This commit is contained in:
Oliver Gorwits
2017-12-28 23:51:26 +00:00
parent ae5496310e
commit 72961f172d
2 changed files with 12 additions and 2 deletions

View File

@@ -11,11 +11,14 @@ __PACKAGE__->table('device_links');
__PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
SELECT dp.ip AS left_ip, dp.port AS left_port, dp.name AS left_descr,
dp.speed,
dp2.ip AS right_ip, dp2.port AS right_port, dp2.name AS right_descr
FROM ( SELECT device_port.ip, device_port.port, device_port.name,
device_port.speed,
device_port.remote_ip, device_port.remote_port
FROM device_port
WHERE device_port.remote_port IS NOT NULL ) dp
WHERE device_port.remote_port IS NOT NULL
AND device_port.type = 'ethernetCsmacd' ) dp
INNER JOIN device_ip di ON dp.remote_ip = di.alias
INNER JOIN device_port dp2 ON (di.ip = dp2.ip AND dp.remote_port = dp2.port)
WHERE dp.ip <= dp2.ip
@@ -33,6 +36,9 @@ __PACKAGE__->add_columns(
'left_descr' => {
data_type => 'text',
},
'speed' => {
data_type => 'text',
},
'right_ip' => {
data_type => 'inet',
},

View File

@@ -98,7 +98,9 @@ ajax '/ajax/data/device/netmap' => require_login sub {
{ right_ip => $qdev->ip },
]) : ())
}, {
columns => [qw/left_ip right_ip/],
columns => [qw/left_ip speed right_ip/],
'+select' => [\'row_number() over()'],
'+as' => ['row_number'],
result_class => 'DBIx::Class::ResultClass::HashRefInflator',
});
@@ -118,6 +120,8 @@ ajax '/ajax/data/device/netmap' => require_login sub {
push @{$v3data{'links'}}, {
FROMID => $l->{left_ip},
TOID => $l->{right_ip},
SPEED => $l->{speed},
ID => $l->{row_number},
};
++$ok_dev{$l->{left_ip}};