show aggreate parent in device ports

This commit is contained in:
Oliver Gorwits
2014-01-12 19:14:48 +00:00
parent 3a4beed2f1
commit 79c69f5a0f
4 changed files with 42 additions and 7 deletions

View File

@@ -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

View File

@@ -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' },

View File

@@ -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');