Merge branch 'master' into og-multiple-domain-suffix
This commit is contained in:
@@ -12,7 +12,7 @@ __PACKAGE__->load_components(qw/
|
||||
|
||||
=head2 skipped( $backend?, $max_deferrals?, $retry_after? )
|
||||
|
||||
Retuns a correlated subquery for the set of C<device_skip> entries that apply
|
||||
Returns a correlated subquery for the set of C<device_skip> entries that apply
|
||||
to some jobs. They match the device IP, current backend, and job action.
|
||||
|
||||
Pass the C<backend> FQDN (or the current host will be used as a default), the
|
||||
|
||||
@@ -187,11 +187,11 @@ Will match exactly the C<model> field.
|
||||
|
||||
=item os
|
||||
|
||||
Will match exactly the C<os> field, which is the operating sytem.
|
||||
Will match exactly the C<os> field, which is the operating system.
|
||||
|
||||
=item os_ver
|
||||
|
||||
Will match exactly the C<os_ver> field, which is the operating sytem software version.
|
||||
Will match exactly the C<os_ver> field, which is the operating system software version.
|
||||
|
||||
=item vendor
|
||||
|
||||
@@ -226,21 +226,20 @@ sub search_by_field {
|
||||
}
|
||||
|
||||
# For Search on Layers
|
||||
my @layer_search = ( '_', '_', '_', '_', '_', '_', '_' );
|
||||
# @layer_search is computer indexed, left->right
|
||||
my $layers = $p->{layers};
|
||||
my @layer_select = ();
|
||||
if ( defined $layers && ref $layers ) {
|
||||
foreach my $layer (@$layers) {
|
||||
next unless defined $layer and length($layer);
|
||||
next if ( $layer < 1 || $layer > 7 );
|
||||
$layer_search[ $layer - 1 ] = 1;
|
||||
push @layer_select,
|
||||
\[ 'substring(me.layers,9-?, 1)::int = 1', $layer ];
|
||||
}
|
||||
}
|
||||
elsif ( defined $layers ) {
|
||||
$layer_search[ $layers - 1 ] = 1;
|
||||
push @layer_select,
|
||||
\[ 'substring(me.layers,9-?, 1)::int = 1', $layers ];
|
||||
}
|
||||
# the database field is in order 87654321
|
||||
my $layer_string = join( '', reverse @layer_search );
|
||||
|
||||
return $rs
|
||||
->search_rs({}, $attrs)
|
||||
@@ -252,8 +251,6 @@ sub search_by_field {
|
||||
{ '-ilike' => "\%$p->{location}\%" }) : ()),
|
||||
($p->{description} ? ('me.description' =>
|
||||
{ '-ilike' => "\%$p->{description}\%" }) : ()),
|
||||
($p->{layers} ? ('me.layers' =>
|
||||
{ '-ilike' => "\%$layer_string" }) : ()),
|
||||
|
||||
($p->{model} ? ('me.model' =>
|
||||
{ '-in' => $p->{model} }) : ()),
|
||||
@@ -264,6 +261,8 @@ sub search_by_field {
|
||||
($p->{vendor} ? ('me.vendor' =>
|
||||
{ '-in' => $p->{vendor} }) : ()),
|
||||
|
||||
($p->{layers} ? (-or => \@layer_select) : ()),
|
||||
|
||||
($p->{dns} ? (
|
||||
-or => [
|
||||
'me.dns' => { '-ilike' => "\%$p->{dns}\%" },
|
||||
|
||||
@@ -40,7 +40,7 @@ sub with_times {
|
||||
});
|
||||
}
|
||||
|
||||
=head2 with_free_ports
|
||||
=head2 with_is_free
|
||||
|
||||
This is a modifier for any C<search()> (including the helpers below) which
|
||||
will add the following additional synthesized columns to the result set:
|
||||
@@ -67,12 +67,13 @@ sub with_is_free {
|
||||
->search({},
|
||||
{
|
||||
'+columns' => { is_free =>
|
||||
\["me.up != 'up' and "
|
||||
."age(now(), to_timestamp(extract(epoch from device.last_discover) "
|
||||
."- (device.uptime - me.lastchange)/100)) "
|
||||
."> ?::interval",
|
||||
[{} => $interval]] },
|
||||
join => 'device',
|
||||
# NOTE this query is in `git grep 'THREE PLACES'`
|
||||
\["me.up_admin = 'up' AND me.up != 'up' AND me.type != 'propVirtual' AND "
|
||||
."((age(now(), to_timestamp(extract(epoch from device.last_discover) - (device.uptime/100))) < ?::interval "
|
||||
."AND (last_node.time_last IS NULL OR age(now(), last_node.time_last) > ?::interval)) "
|
||||
."OR age(now(), to_timestamp(extract(epoch from device.last_discover) - (device.uptime - me.lastchange)/100)) > ?::interval)",
|
||||
[{} => $interval],[ {} => $interval],[ {} => $interval]] },
|
||||
join => [qw/device last_node/],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,14 +97,23 @@ sub only_free_ports {
|
||||
->search_rs($cond, $attrs)
|
||||
->search(
|
||||
{
|
||||
'me.up' => { '!=' => 'up' },
|
||||
},{
|
||||
where =>
|
||||
\["age(now(), to_timestamp(extract(epoch from device.last_discover) "
|
||||
."- (device.uptime - me.lastchange)/100)) "
|
||||
."> ?::interval",
|
||||
# NOTE this query is in `git grep 'THREE PLACES'`
|
||||
'me.up_admin' => 'up',
|
||||
'me.up' => { '!=' => 'up' },
|
||||
'me.type' => { '!=' => 'propVirtual' },
|
||||
-or => [
|
||||
-and => [
|
||||
\["age(now(), to_timestamp(extract(epoch from device.last_discover) - (device.uptime/100))) < ?::interval",
|
||||
[{} => $interval]],
|
||||
-or => [
|
||||
'last_node.time_last' => undef,
|
||||
\["age(now(), last_node.time_last) > ?::interval", [{} => $interval]],
|
||||
]
|
||||
],
|
||||
\["age(now(), to_timestamp(extract(epoch from device.last_discover) - (device.uptime - me.lastchange)/100)) > ?::interval",
|
||||
[{} => $interval]],
|
||||
join => 'device' },
|
||||
],
|
||||
},{ join => [qw/device last_node/] },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user