Close cleanup; only try to run power actions against non-suspended & installed servers; closes #2760

This commit is contained in:
Dane Everitt 2020-11-29 12:50:22 -08:00
parent 26d409c29c
commit 16f49f8dc1
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 40 additions and 107 deletions

View file

@ -194,45 +194,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
}
}
/**
* Return all of the servers that should have a power action performed against them.
*
* @param int[] $servers
* @param int[] $nodes
* @param bool $returnCount
* @return int|\Illuminate\Support\LazyCollection
*/
public function getServersForPowerAction(array $servers = [], array $nodes = [], bool $returnCount = false)
{
$instance = $this->getBuilder();
if (! empty($nodes) && ! empty($servers)) {
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);
} else if (empty($nodes) && ! empty($servers)) {
$instance->whereIn('id', $servers);
} else if (! empty($nodes) && empty($servers)) {
$instance->whereIn('node_id', $nodes);
}
if ($returnCount) {
return $instance->count();
}
return $instance->with('node')->cursor();
}
/**
* Return the total number of servers that will be affected by the query.
*
* @param int[] $servers
* @param int[] $nodes
* @return int
*/
public function getServersForPowerActionCount(array $servers = [], array $nodes = []): int
{
return $this->getServersForPowerAction($servers, $nodes, true);
}
/**
* Check if a given UUID and UUID-Short string are unique to a server.
*