From cd7a2484c5a810488b9f779e18d388edc6389a9f Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Wed, 6 May 2026 12:28:28 +0200 Subject: [PATCH] =?UTF-8?q?Modificada=20funcion=20para=20borrar=20imagen?= =?UTF-8?q?=20de=20cache,=20no=20se=20usa=20la=20partici=C3=B3n=20que=20co?= =?UTF-8?q?ntenga=20una=20imagen=20desplegada,=20se=20usa=20directamente?= =?UTF-8?q?=20el=20nombre=20del=20fichero=20contenido=20en=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 +++ config/api_platform/Client.yaml | 2 +- .../OgAgent/RemoveCacheImageAction.php | 16 +++++------ src/Dto/Input/RemoveCacheImageInput.php | 27 +++++++++++++++++++ 4 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 src/Dto/Input/RemoveCacheImageInput.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e492cc..769580f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/config/api_platform/Client.yaml b/config/api_platform/Client.yaml index 84bb7d5..c8a2963 100644 --- a/config/api_platform/Client.yaml +++ b/config/api_platform/Client.yaml @@ -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 diff --git a/src/Controller/OgAgent/RemoveCacheImageAction.php b/src/Controller/OgAgent/RemoveCacheImageAction.php index e5ee009..f8a1cc7 100644 --- a/src/Controller/OgAgent/RemoveCacheImageAction.php +++ b/src/Controller/OgAgent/RemoveCacheImageAction.php @@ -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', diff --git a/src/Dto/Input/RemoveCacheImageInput.php b/src/Dto/Input/RemoveCacheImageInput.php new file mode 100644 index 0000000..a48be05 --- /dev/null +++ b/src/Dto/Input/RemoveCacheImageInput.php @@ -0,0 +1,27 @@ +