show aggreate parent in device ports
This commit is contained in:
@@ -183,6 +183,22 @@ __PACKAGE__->might_have(
|
||||
}
|
||||
);
|
||||
|
||||
=head2 agg_master
|
||||
|
||||
Returns another row from the C<device_port> 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
|
||||
|
||||
@@ -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' },
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -66,10 +66,22 @@
|
||||
[% ELSE %]
|
||||
<td nowrap>
|
||||
[% END %]
|
||||
<a class="nd_linkcell nd_this-port-only" href="[% uri_for('/device',
|
||||
<a class="nd_this-port-only" href="[% uri_for('/device',
|
||||
self_options) %]&q=[% params.q | uri %]&f=[% row.port | uri %]&prefer=port">
|
||||
[% row.port | html_entity %]
|
||||
</a></td>
|
||||
[% row.port | html_entity %]</a>
|
||||
[% IF row.slave_of %]<br/>
|
||||
[% IF row.get_column('agg_master_up_admin') != 'up' %]
|
||||
<i class="icon-angle-down"></i>
|
||||
[% ELSIF row.get_column('agg_master_up') == 'up' %]
|
||||
<i class="icon-angle-up text-success"></i>
|
||||
[% ELSE %]
|
||||
<i class="icon-angle-down text-error"></i>
|
||||
[% END %]
|
||||
<a class="nd_this-port-only" href="[% uri_for('/device',
|
||||
self_options) %]&q=[% params.q | uri %]&f=[% row.slave_of | uri %]&prefer=port">
|
||||
[% row.slave_of | html_entity %]</a>
|
||||
[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
|
||||
[% FOREACH config IN settings._extra_device_port_cols %]
|
||||
|
||||
Reference in New Issue
Block a user