diff --git a/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm b/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm index 019eaad0..b4e8b265 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/DevicePort.pm @@ -183,6 +183,22 @@ __PACKAGE__->might_have( } ); +=head2 agg_master + +Returns another row from the C table if this port is slave +to another in a link aggregate. + +=cut + +__PACKAGE__->belongs_to( + agg_master => 'App::Netdisco::DB::Result::DevicePort', { + 'foreign.ip' => 'self.ip', + 'foreign.port' => 'self.slave_of', + }, { + join_type => 'LEFT', + } +); + =head2 neighbor_alias When a device port has an attached neighbor device, this relationship will diff --git a/Netdisco/lib/App/Netdisco/DB/ResultSet/DevicePort.pm b/Netdisco/lib/App/Netdisco/DB/ResultSet/DevicePort.pm index 46429de0..71bdce76 100644 --- a/Netdisco/lib/App/Netdisco/DB/ResultSet/DevicePort.pm +++ b/Netdisco/lib/App/Netdisco/DB/ResultSet/DevicePort.pm @@ -64,9 +64,9 @@ sub with_is_free { ->search({}, { '+columns' => { is_free => - \["up != 'up' and " + \["me.up != 'up' and " ."age(now(), to_timestamp(extract(epoch from device.last_discover) " - ."- (device.uptime - lastchange)/100)) " + ."- (device.uptime - me.lastchange)/100)) " ."> ?::interval", [{} => $interval]] }, join => 'device', @@ -93,11 +93,11 @@ sub only_free_ports { ->search_rs($cond, $attrs) ->search( { - 'up' => { '!=' => 'up' }, + 'me.up' => { '!=' => 'up' }, },{ where => \["age(now(), to_timestamp(extract(epoch from device.last_discover) " - ."- (device.uptime - lastchange)/100)) " + ."- (device.uptime - me.lastchange)/100)) " ."> ?::interval", [{} => $interval]], join => 'device' }, diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index b41cd28a..46d0e652 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -108,6 +108,13 @@ get '/ajax/content/device/ports' => require_login sub { $set = $set->search({-or => \@combi}); } + # get aggregate master status + $set = $set->search({}, { + 'join' => 'agg_master', + '+select' => [qw/agg_master.up_admin agg_master.up/], + '+as' => [qw/agg_master_up_admin agg_master_up/], + }); + # make sure query asks for formatted timestamps when needed $set = $set->with_times if param('c_lastchange'); diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index f314ec87..9a3441f2 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -66,10 +66,22 @@ [% ELSE %] [% END %] - - [% row.port | html_entity %] - + [% row.port | html_entity %] + [% IF row.slave_of %]
+ [% IF row.get_column('agg_master_up_admin') != 'up' %] + + [% ELSIF row.get_column('agg_master_up') == 'up' %] + + [% ELSE %] + + [% END %] + + [% row.slave_of | html_entity %] + [% END %] + [% END %] [% FOREACH config IN settings._extra_device_port_cols %]