Modificada funcion para borrar imagen de cache, no se usa la partición que contenga una imagen desplegada, se usa directamente el nombre del fichero contenido en cache
parent
2860161d93
commit
cd7a2484c5
|
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## [1.7.3] - 2026-05-05
|
||||
### Fixed
|
||||
- Modificada funcion para borrar imagen de cache, no se hace usando la partición que contenga un deploy de imagen, se borra el fichero real de la cache
|
||||
|
||||
## [1.7.2] - 2026-05-04
|
||||
### Fixed
|
||||
- Corregida llamada a instalar/desinstalar oglives en servidores ogboot
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ resources:
|
|||
remove_cache_image:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\BootClientsInput
|
||||
input: App\Dto\Input\RemoveCacheImageInput
|
||||
uriTemplate: /clients/server/remove-cache-image
|
||||
controller: App\Controller\OgAgent\RemoveCacheImageAction
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Dto\Input\BootClientsInput;
|
||||
use App\Dto\Input\RemoveCacheImageInput;
|
||||
use App\Entity\Client;
|
||||
use App\Entity\Partition;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\TraceStatus;
|
||||
|
|
@ -24,19 +23,16 @@ class RemoveCacheImageAction extends AbstractOgAgentController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(BootClientsInput $input): JsonResponse
|
||||
public function __invoke(RemoveCacheImageInput $input): JsonResponse
|
||||
{
|
||||
/** @var Partition $partition */
|
||||
$partition = $input->partition->getEntity();
|
||||
if (!$input->imageName) {
|
||||
throw new BadRequestHttpException('Image name is required');
|
||||
}
|
||||
|
||||
foreach ($input->clients as $clientEntity) {
|
||||
/** @var Client $client */
|
||||
$client = $clientEntity->getEntity();
|
||||
|
||||
if (!$partition->getImage()) {
|
||||
throw new BadRequestHttpException('Image is required');
|
||||
}
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
}
|
||||
|
|
@ -46,7 +42,7 @@ class RemoveCacheImageAction extends AbstractOgAgentController
|
|||
continue;
|
||||
}
|
||||
|
||||
$script = 'rm -r /opt/opengnsys/cache/opt/opengnsys/images/' . $partition->getImage()->getName() . '.*';
|
||||
$script = 'rm -r /opt/opengnsys/cache/opt/opengnsys/images/' . escapeshellarg($input->imageName) . '*';
|
||||
|
||||
$data = [
|
||||
'nfn' => 'EjecutarScript',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
final class RemoveCacheImageInput
|
||||
{
|
||||
/**
|
||||
* @var ClientOutput[]
|
||||
*/
|
||||
#[Groups(['client:write'])]
|
||||
#[ApiProperty(
|
||||
description: 'Los clientes a los que se les borrará la imagen de caché',
|
||||
example: []
|
||||
)]
|
||||
public array $clients = [];
|
||||
|
||||
#[Groups(['client:write'])]
|
||||
#[ApiProperty(
|
||||
description: 'El nombre de la imagen a borrar de la caché',
|
||||
example: 'windows10-ltsc_v1.img'
|
||||
)]
|
||||
public ?string $imageName = null;
|
||||
}
|
||||
Loading…
Reference in New Issue