From 51f968e494d4e9c350a8c5c9a88d2c34986a99d3 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Wed, 1 Oct 2025 08:21:23 +0200 Subject: [PATCH] Fixed some command task bugs --- .../CreateImageRepositoriesCommand.php | 286 ++++++++++++++++++ src/Command/ExecutePendingTracesCommand.php | 4 +- src/Controller/DeployGitImageAction.php | 37 ++- .../OgAgent/CheckPartitionSizesAction.php | 14 - src/Controller/OgAgent/CreateImageAction.php | 1 - .../OgAgent/DeployGitImageAction.php | 11 +- src/Controller/OgAgent/DeployImageAction.php | 16 +- .../OgAgent/PartitionAssistantAction.php | 9 - src/Controller/OgAgent/RebootAction.php | 11 - .../OgAgent/RemoveCacheImageAction.php | 1 - src/Controller/OgAgent/RunScriptAction.php | 10 +- .../OgAgent/UpdateGitImageAction.php | 2 +- 12 files changed, 316 insertions(+), 86 deletions(-) create mode 100644 src/Command/CreateImageRepositoriesCommand.php diff --git a/src/Command/CreateImageRepositoriesCommand.php b/src/Command/CreateImageRepositoriesCommand.php new file mode 100644 index 0000000..14ed999 --- /dev/null +++ b/src/Command/CreateImageRepositoriesCommand.php @@ -0,0 +1,286 @@ +setDescription('Crea una ImageRepository y/o ImageImageRepository') + ->addArgument('action', InputArgument::OPTIONAL, 'Acción a realizar: repository, image-repository, o both', 'both') + ->addOption('repository-name', null, InputOption::VALUE_OPTIONAL, 'Nombre del repositorio de imágenes') + ->addOption('repository-ip', null, InputOption::VALUE_OPTIONAL, 'IP del repositorio de imágenes') + ->addOption('repository-user', null, InputOption::VALUE_OPTIONAL, 'Usuario del repositorio', ImageRepository::DEFAULT_USER) + ->addOption('repository-ssh-port', null, InputOption::VALUE_OPTIONAL, 'Puerto SSH del repositorio') + ->addOption('repository-comments', null, InputOption::VALUE_OPTIONAL, 'Comentarios del repositorio') + ->addOption('image-name', null, InputOption::VALUE_OPTIONAL, 'Nombre de la imagen') + ->addOption('image-type', null, InputOption::VALUE_OPTIONAL, 'Tipo de imagen', 'Server') + ->addOption('image-version', null, InputOption::VALUE_OPTIONAL, 'Versión de la imagen', '1') + ->addOption('image-repository-name', null, InputOption::VALUE_OPTIONAL, 'Nombre para ImageImageRepository') + ->addOption('image-repository-status', null, InputOption::VALUE_OPTIONAL, 'Status para ImageImageRepository', ImageStatus::SUCCESS) + ->addOption('batch', 'b', InputOption::VALUE_NONE, 'Modo no interactivo (usar solo opciones)'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $action = $input->getArgument('action'); + $batchMode = $input->getOption('batch'); + + $helper = $this->getHelper('question'); + + $output->writeln('🚀 Creador de ImageRepository e ImageImageRepository'); + $output->writeln(''); + + try { + switch ($action) { + case 'repository': + $imageRepository = $this->createImageRepository($input, $output, $helper, $batchMode); + $output->writeln("✅ ImageRepository creado exitosamente: {$imageRepository->getName()}"); + break; + + case 'image-repository': + $imageImageRepository = $this->createImageImageRepository($input, $output, $helper, $batchMode); + $output->writeln("✅ ImageImageRepository creado exitosamente: {$imageImageRepository->getName()}"); + break; + + case 'both': + default: + $output->writeln('Creando ImageRepository primero...'); + $imageRepository = $this->createImageRepository($input, $output, $helper, $batchMode); + $output->writeln("✅ ImageRepository creado: {$imageRepository->getName()}"); + + $output->writeln(''); + $output->writeln('Ahora creando ImageImageRepository...'); + $imageImageRepository = $this->createImageImageRepository($input, $output, $helper, $batchMode, $imageRepository); + $output->writeln("✅ ImageImageRepository creado: {$imageImageRepository->getName()}"); + break; + } + + $this->entityManager->flush(); + $output->writeln(''); + $output->writeln('🎉 ¡Proceso completado exitosamente!'); + + return Command::SUCCESS; + + } catch (\Exception $e) { + $output->writeln("❌ Error: {$e->getMessage()}"); + return Command::FAILURE; + } + } + + private function createImageRepository(InputInterface $input, OutputInterface $output, $helper, bool $batchMode): ImageRepository + { + // Recopilar datos para ImageRepository + $name = $input->getOption('repository-name'); + if (!$name && !$batchMode) { + $question = new Question('Nombre del repositorio de imágenes: '); + $question->setValidator(function ($value) { + if (empty($value)) { + throw new \RuntimeException('El nombre no puede estar vacío'); + } + return $value; + }); + $name = $helper->ask($input, $output, $question); + } + + $ip = $input->getOption('repository-ip'); + if (!$ip && !$batchMode) { + $question = new Question('IP del repositorio: '); + $question->setValidator(function ($value) { + if (empty($value)) { + throw new \RuntimeException('La IP no puede estar vacía'); + } + if (!filter_var($value, FILTER_VALIDATE_IP)) { + throw new \RuntimeException('La IP no es válida'); + } + return $value; + }); + $ip = $helper->ask($input, $output, $question); + } + + $user = $input->getOption('repository-user') ?: ImageRepository::DEFAULT_USER; + if (!$batchMode) { + $question = new Question("Usuario [{$user}]: ", $user); + $user = $helper->ask($input, $output, $question); + } + + $sshPort = $input->getOption('repository-ssh-port'); + if (!$sshPort && !$batchMode) { + $question = new Question('Puerto SSH [22]: ', '22'); + $sshPort = $helper->ask($input, $output, $question); + } + + $comments = $input->getOption('repository-comments'); + if (!$comments && !$batchMode) { + $question = new Question('Comentarios (opcional): '); + $comments = $helper->ask($input, $output, $question); + } + + // Crear ImageRepository + $imageRepository = new ImageRepository(); + $imageRepository->setName($name); + $imageRepository->setIp($ip); + $imageRepository->setUser($user); + $imageRepository->setSshPort($sshPort); + if ($comments) { + $imageRepository->setComments($comments); + } + + $this->entityManager->persist($imageRepository); + + return $imageRepository; + } + + private function createImageImageRepository(InputInterface $input, OutputInterface $output, $helper, bool $batchMode, ?ImageRepository $repository = null): ImageImageRepository + { + // Si no tenemos repository, necesitamos seleccionar uno existente + if (!$repository) { + $repositories = $this->imageRepository->findAll(); + if (empty($repositories)) { + throw new \RuntimeException('No hay ImageRepositories disponibles. Crea uno primero.'); + } + + if (!$batchMode) { + $output->writeln('Repositorios disponibles:'); + foreach ($repositories as $i => $repo) { + $output->writeln(" [{$i}] {$repo->getName()} ({$repo->getIp()})"); + } + + $question = new Question('Selecciona un repositorio (número): '); + $question->setValidator(function ($value) use ($repositories) { + if (!is_numeric($value) || !isset($repositories[$value])) { + throw new \RuntimeException('Selección inválida'); + } + return (int)$value; + }); + $repoIndex = $helper->ask($input, $output, $question); + $repository = $repositories[$repoIndex]; + } else { + $repository = $repositories[0]; // Usar el primero disponible en modo batch + } + } + + // Obtener todas las imágenes disponibles + $images = $this->entityManager->getRepository(Image::class)->findAll(); + $image = null; + + if (!empty($images) && !$batchMode) { + $output->writeln('Imágenes disponibles:'); + foreach ($images as $i => $img) { + $output->writeln(" [{$i}] {$img->getName()} (Tipo: {$img->getType()})"); + } + $output->writeln(" [new] Crear nueva imagen"); + + $question = new Question('Selecciona una imagen o "new" para crear nueva: '); + $imageChoice = $helper->ask($input, $output, $question); + + if ($imageChoice !== 'new' && is_numeric($imageChoice) && isset($images[$imageChoice])) { + $image = $images[$imageChoice]; + } + } + + // Si no hay imagen seleccionada, crear una nueva + if (!$image) { + $imageName = $input->getOption('image-name'); + if (!$imageName && !$batchMode) { + $question = new Question('Nombre de la imagen: '); + $question->setValidator(function ($value) { + if (empty($value)) { + throw new \RuntimeException('El nombre de la imagen no puede estar vacío'); + } + return $value; + }); + $imageName = $helper->ask($input, $output, $question); + } + + $imageType = $input->getOption('image-type') ?: 'Server'; + if (!$batchMode) { + $question = new Question("Tipo de imagen [{$imageType}]: ", $imageType); + $imageType = $helper->ask($input, $output, $question); + } + + $imageVersion = $input->getOption('image-version') ?: 1; + if (!$batchMode) { + $question = new Question("Versión de la imagen [{$imageVersion}]: ", $imageVersion); + $imageVersion = (int)$helper->ask($input, $output, $question); + } + + // Crear nueva imagen + $image = new Image(); + $image->setName($imageName); + $image->setType($imageType); + $image->setVersion($imageVersion); + $image->setRemotePc(false); + $image->setIsGlobal(true); + + $this->entityManager->persist($image); + } + + // Recopilar datos para ImageImageRepository + $imageRepositoryName = $input->getOption('image-repository-name'); + if (!$imageRepositoryName && !$batchMode) { + $defaultName = $image->getName() . '_' . $repository->getName(); + $question = new Question("Nombre para ImageImageRepository [{$defaultName}]: ", $defaultName); + $imageRepositoryName = $helper->ask($input, $output, $question); + } elseif (!$imageRepositoryName) { + $imageRepositoryName = $image->getName() . '_' . $repository->getName(); + } + + $status = $input->getOption('image-repository-status') ?: ImageStatus::SUCCESS; + if (!$batchMode) { + $output->writeln('Status disponibles:'); + foreach (ImageStatus::getStatusKeys() as $statusKey) { + $output->writeln(" - {$statusKey}"); + } + $question = new Question("Status [{$status}]: ", $status); + $question->setValidator(function ($value) { + if (!in_array($value, ImageStatus::getStatusKeys())) { + throw new \RuntimeException('Status inválido'); + } + return $value; + }); + $status = $helper->ask($input, $output, $question); + } + + // Crear ImageImageRepository + $imageImageRepository = new ImageImageRepository(); + $imageImageRepository->setName($imageRepositoryName); + $imageImageRepository->setImage($image); + $imageImageRepository->setRepository($repository); + $imageImageRepository->setStatus($status); + $imageImageRepository->setCreated(true); + $imageImageRepository->setVersion($image->getVersion()); + + $this->entityManager->persist($imageImageRepository); + + return $imageImageRepository; + } +} \ No newline at end of file diff --git a/src/Command/ExecutePendingTracesCommand.php b/src/Command/ExecutePendingTracesCommand.php index a0b8abe..5b96e1a 100644 --- a/src/Command/ExecutePendingTracesCommand.php +++ b/src/Command/ExecutePendingTracesCommand.php @@ -223,7 +223,7 @@ class ExecutePendingTracesCommand extends Command if (isset($input['action']) && $input['action'] === 'create') { $image = new Image(); - $image->setName($input['imageName'] ?? 'Image_' . uniqid()); + $image->setName($input['name'] ); $image->setType($input['type'] ?? 'monolithic'); $image->setRemotePc($input['remotePc'] ?? false); $image->setIsGlobal($input['isGlobal'] ?? false); @@ -368,7 +368,7 @@ class ExecutePendingTracesCommand extends Command $partitionInputObj->partitionCode = $item['partitionCode'] ?? 'LINUX'; $partitionInputObj->size = $item['size']; $partitionInputObj->filesystem = $item['filesystem'] ?? 'EXT4'; - $partitionInputObj->format = ($item['format'] ?? '0') === '1'; + $partitionInputObj->format = $item['format'] ?? false; $partitions[] = $partitionInputObj; } diff --git a/src/Controller/DeployGitImageAction.php b/src/Controller/DeployGitImageAction.php index 73744f1..5f0d82f 100644 --- a/src/Controller/DeployGitImageAction.php +++ b/src/Controller/DeployGitImageAction.php @@ -6,32 +6,24 @@ namespace App\Controller; use ApiPlatform\Validator\ValidatorInterface; use App\Dto\Input\DeployGitImageInput; -use App\Entity\Command; -use App\Entity\Image; -use App\Model\ClientStatus; -use App\Entity\ImageImageRepository; -use App\Entity\OrganizationalUnit; -use App\Entity\Partition; use App\Model\CommandTypes; use App\Model\DeployMethodTypes; use App\Model\TraceStatus; use App\Service\Trace\CreateService; -use Doctrine\ORM\EntityManagerInterface; +use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Attribute\Route; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; class DeployGitImageAction extends AbstractController { public function __construct( - protected readonly EntityManagerInterface $entityManager, protected readonly CreateService $createService, protected readonly ValidatorInterface $validator, + protected readonly LoggerInterface $logger, public readonly \App\Controller\OgAgent\DeployGitImageAction $deployGitImageOgAgentAction, ) { } @@ -55,11 +47,25 @@ class DeployGitImageAction extends AbstractController $clientJobs = []; foreach ($input->clients as $client) { - $inputData = $this->createInputData($input, $client->getEntity()); - $jobId = $this->processDeployment($client->getEntity(), $input, $inputData, DeployMethodTypes::GIT); - - if ($jobId) { - $clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId; + try { + $inputData = $this->createInputData($input, $client->getEntity()); + $jobId = $this->processDeployment($client->getEntity(), $input, $inputData, DeployMethodTypes::GIT); + + if ($jobId) { + $clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId; + } + } catch (\Exception $e) { + $this->logger->warning('Error deploying git image to client', [ + 'client_uuid' => $client->getEntity()->getUuid(), + 'error' => $e->getMessage() + ]); + + if ($input->queue) { + $inputData = $this->createInputData($input, $client->getEntity()); + $this->createService->__invoke($client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData); + } + + continue; } } @@ -85,7 +91,6 @@ class DeployGitImageAction extends AbstractController private function createInputData(DeployGitImageInput $input, $client): array { return [ - 'method' => $input->method, 'client' => $client->getUuid(), 'hexsha' => $input->hexsha, 'repositoryName' => $input->repositoryName, diff --git a/src/Controller/OgAgent/CheckPartitionSizesAction.php b/src/Controller/OgAgent/CheckPartitionSizesAction.php index 2131efd..bac590a 100644 --- a/src/Controller/OgAgent/CheckPartitionSizesAction.php +++ b/src/Controller/OgAgent/CheckPartitionSizesAction.php @@ -6,28 +6,14 @@ namespace App\Controller\OgAgent; use App\Dto\Input\CheckPartitionSizesInput; use App\Entity\Client; -use App\Entity\Command; -use App\Entity\Image; use App\Entity\Partition; -use App\Entity\Trace; -use App\Model\ClientStatus; -use App\Model\CommandTypes; -use App\Model\ImageStatus; -use App\Model\TraceStatus; -use App\Service\Trace\CreateService; -use Doctrine\ORM\EntityManagerInterface; -use Psr\Log\LoggerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Routing\Attribute\Route; -use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; class CheckPartitionSizesAction extends AbstractOgAgentController { diff --git a/src/Controller/OgAgent/CreateImageAction.php b/src/Controller/OgAgent/CreateImageAction.php index e0a32b5..803d86b 100644 --- a/src/Controller/OgAgent/CreateImageAction.php +++ b/src/Controller/OgAgent/CreateImageAction.php @@ -200,7 +200,6 @@ class CreateImageAction extends AbstractOgAgentController if ($existingTrace) { $existingTrace->setStatus(TraceStatus::IN_PROGRESS); $existingTrace->setJobId($jobId); - $existingTrace->setInput($inputData); $this->entityManager->persist($existingTrace); $this->entityManager->flush(); } else { diff --git a/src/Controller/OgAgent/DeployGitImageAction.php b/src/Controller/OgAgent/DeployGitImageAction.php index 8e4ee8a..0607ca8 100644 --- a/src/Controller/OgAgent/DeployGitImageAction.php +++ b/src/Controller/OgAgent/DeployGitImageAction.php @@ -6,10 +6,7 @@ namespace App\Controller\OgAgent; use App\Dto\Input\DeployGitImageInput; use App\Entity\Client; -use App\Entity\Image; use App\Model\ClientStatus; -use Doctrine\ORM\EntityManagerInterface; -use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; @@ -31,7 +28,7 @@ class DeployGitImageAction extends AbstractOgAgentController throw new BadRequestHttpException('IP is required'); } - if (!$input->hexsha && !$input->tag) { + if (!$input->hexsha) { throw new BadRequestHttpException('Either hexsha or tag is required for Git image deployment'); } @@ -51,9 +48,9 @@ class DeployGitImageAction extends AbstractOgAgentController 'idi' => $input->repositoryName, 'image_name' => $input->repositoryName, 'repository' => $repository->getIp(), - 'nfn' => 'RestaurarImagenGit', + 'nfn' => 'RestaurarImagenGit', 'ids' => '0', - 'commit' => $input->hexsha ?? $input->tag, + 'commit' => $input->hexsha, 'branch' => $input->branch ]; @@ -71,7 +68,7 @@ class DeployGitImageAction extends AbstractOgAgentController $this->logger->info('Deploying Git image', [ 'repository' => $input->repositoryName, 'branch' => $input->branch, - 'ref' => $input->hexsha ?? $input->tag, + 'ref' => $input->hexsha, 'client' => $client->getIp() ]); diff --git a/src/Controller/OgAgent/DeployImageAction.php b/src/Controller/OgAgent/DeployImageAction.php index dbc4085..5d12823 100644 --- a/src/Controller/OgAgent/DeployImageAction.php +++ b/src/Controller/OgAgent/DeployImageAction.php @@ -6,29 +6,15 @@ namespace App\Controller\OgAgent; use App\Dto\Input\DeployImageInput; use App\Entity\Client; -use App\Entity\Command; -use App\Entity\Image; use App\Entity\ImageImageRepository; -use App\Entity\Partition; -use App\Entity\Trace; use App\Model\ClientStatus; use App\Model\DeployMethodTypes; -use App\Model\TraceStatus; -use App\Service\Trace\CreateService; -use Doctrine\ORM\EntityManagerInterface; -use Psr\Log\LoggerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpClient\Exception\TransportException; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Routing\Attribute\Route; -use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; -use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; class DeployImageAction extends AbstractOgAgentController { diff --git a/src/Controller/OgAgent/PartitionAssistantAction.php b/src/Controller/OgAgent/PartitionAssistantAction.php index 6f05bad..119a534 100644 --- a/src/Controller/OgAgent/PartitionAssistantAction.php +++ b/src/Controller/OgAgent/PartitionAssistantAction.php @@ -6,28 +6,20 @@ namespace App\Controller\OgAgent; use App\Dto\Input\PartitionPostInput; use App\Entity\Client; -use App\Entity\Command; -use App\Entity\Image; use App\Entity\Partition; use App\Entity\Trace; use App\Model\ClientStatus; use App\Model\CommandTypes; -use App\Model\ImageStatus; use App\Model\TraceStatus; -use App\Service\Trace\CreateService; use Doctrine\ORM\EntityManagerInterface; -use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Routing\Attribute\Route; -use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; class PartitionAssistantAction extends AbstractOgAgentController { @@ -130,7 +122,6 @@ class PartitionAssistantAction extends AbstractOgAgentController if ($existingTrace) { $existingTrace->setStatus(TraceStatus::IN_PROGRESS); $existingTrace->setJobId($jobId); - $existingTrace->setInput($data); $this->entityManager->persist($existingTrace); $this->entityManager->flush(); } else { diff --git a/src/Controller/OgAgent/RebootAction.php b/src/Controller/OgAgent/RebootAction.php index 60f18d5..a52f35f 100644 --- a/src/Controller/OgAgent/RebootAction.php +++ b/src/Controller/OgAgent/RebootAction.php @@ -6,27 +6,16 @@ namespace App\Controller\OgAgent; use App\Dto\Input\MultipleClientsInput; use App\Entity\Client; -use App\Entity\Command; -use App\Entity\Image; -use App\Entity\Trace; use App\Model\ClientStatus; use App\Model\CommandTypes; -use App\Model\ImageStatus; use App\Model\TraceStatus; -use App\Service\Trace\CreateService; -use Doctrine\ORM\EntityManagerInterface; -use Psr\Log\LoggerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Routing\Attribute\Route; -use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; class RebootAction extends AbstractOgAgentController { diff --git a/src/Controller/OgAgent/RemoveCacheImageAction.php b/src/Controller/OgAgent/RemoveCacheImageAction.php index f7fa159..e5ee009 100644 --- a/src/Controller/OgAgent/RemoveCacheImageAction.php +++ b/src/Controller/OgAgent/RemoveCacheImageAction.php @@ -11,7 +11,6 @@ use App\Model\TraceStatus; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; diff --git a/src/Controller/OgAgent/RunScriptAction.php b/src/Controller/OgAgent/RunScriptAction.php index f380d39..6d0ae99 100644 --- a/src/Controller/OgAgent/RunScriptAction.php +++ b/src/Controller/OgAgent/RunScriptAction.php @@ -2,26 +2,19 @@ namespace App\Controller\OgAgent; -use App\Dto\Input\CommandExecuteInput; -use App\Dto\Input\MultipleClientsInput; +use App\Dto\Input\CommandExecuteInput; use App\Entity\Client; use App\Entity\Trace; use App\Model\ClientStatus; use App\Model\CommandTypes; use App\Model\TraceStatus; -use App\Service\Trace\CreateService; -use Doctrine\ORM\EntityManagerInterface; -use Psr\Log\LoggerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; class RunScriptAction extends AbstractOgAgentController { @@ -170,7 +163,6 @@ class RunScriptAction extends AbstractOgAgentController $status = ($this->isLinuxOrWindows($client) || $this->isLinuxOrWindowsSession($client)) ? TraceStatus::SENT : TraceStatus::IN_PROGRESS; $trace->setStatus($status); $trace->setJobId($jobId); - $trace->setInput($inputData); $this->entityManager->persist($trace); $this->entityManager->flush(); } diff --git a/src/Controller/OgAgent/UpdateGitImageAction.php b/src/Controller/OgAgent/UpdateGitImageAction.php index 296b092..07551cf 100644 --- a/src/Controller/OgAgent/UpdateGitImageAction.php +++ b/src/Controller/OgAgent/UpdateGitImageAction.php @@ -47,7 +47,7 @@ class UpdateGitImageAction extends AbstractOgAgentController 'nfn' => 'ModificarImagenGit', 'ids' => '0', 'branch' => $input->destinationBranch, - 'options' => $input->options ? 'force push' : null, + 'options' => $input->options ? 'force_push' : null, ]; $url = 'https://'.$client->getIp().':8000/opengnsys/ModificarImagenGit';