solve conflicts
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
commit
865d356b06
|
@ -7,6 +7,7 @@
|
|||
/public/bundles/
|
||||
/var/
|
||||
/vendor/
|
||||
api/public/bundles/
|
||||
###< symfony/framework-bundle ###
|
||||
|
||||
#phpstorm
|
||||
|
@ -36,3 +37,4 @@ debian/files
|
|||
### Certificates
|
||||
certs/
|
||||
|
||||
|
||||
|
|
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,4 +1,19 @@
|
|||
# Changelog
|
||||
## [0.17.2] - 2025-08-04
|
||||
## Improved
|
||||
- Se ha cambiado la respuesta de algunos endpoints que llaman al ogAgent. Ahora devuelve el job_id asociado a la traza.
|
||||
|
||||
---
|
||||
## [0.17.1] - 2025-07-29
|
||||
### Fixed
|
||||
- Se ha corregido un bug que aparecia al borrar un cliente. Este error hacia que se borrara el cliente de la base de datos, pero no del DHCP ( en caso de que perteneciera a uno) y el fichero de arranque.
|
||||
|
||||
---
|
||||
## [0.17.0] - 2025-07-20
|
||||
### Added
|
||||
- Se ha añadido la funcionalidad para modificar imagenes de ogGit.
|
||||
|
||||
---
|
||||
## [0.16.0] - 2025-06-27
|
||||
### Added
|
||||
- Se ha cambiado el html del menu para ser compatible con HTML5.
|
||||
|
|
|
@ -45,20 +45,28 @@ class DeployGitImageAction extends AbstractController
|
|||
{
|
||||
$this->validator->validate($input);
|
||||
|
||||
$this->handleGitDeployment($input);
|
||||
$clientJobs = $this->handleGitDeployment($input);
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
return new JsonResponse(data: $clientJobs, status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
private function handleGitDeployment(DeployGitImageInput $input): void
|
||||
private function handleGitDeployment(DeployGitImageInput $input): array
|
||||
{
|
||||
$clientJobs = [];
|
||||
|
||||
foreach ($input->clients as $client) {
|
||||
$inputData = $this->createInputData($input, $client->getEntity());
|
||||
$this->processDeployment($client->getEntity(), $input, $inputData, DeployMethodTypes::GIT);
|
||||
$jobId = $this->processDeployment($client->getEntity(), $input, $inputData, DeployMethodTypes::GIT);
|
||||
|
||||
if ($jobId) {
|
||||
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
|
||||
}
|
||||
}
|
||||
|
||||
return $clientJobs;
|
||||
}
|
||||
|
||||
private function processDeployment($client, DeployGitImageInput $input, array $inputData, string $deployType): void
|
||||
private function processDeployment($client, DeployGitImageInput $input, array $inputData, string $deployType): ?string
|
||||
{
|
||||
$agentJobId = $this->deployGitImageOgAgentAction->__invoke($input, $client);
|
||||
|
||||
|
@ -66,10 +74,12 @@ class DeployGitImageAction extends AbstractController
|
|||
if ($input->queue) {
|
||||
$this->createService->__invoke($client, CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData);
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
|
||||
return $agentJobId;
|
||||
}
|
||||
|
||||
private function createInputData(DeployGitImageInput $input, $client): array
|
||||
|
|
|
@ -47,42 +47,58 @@ class DeployImageAction extends AbstractController
|
|||
{
|
||||
$this->validator->validate($input);
|
||||
|
||||
$clientJobs = [];
|
||||
|
||||
if ($input->type === 'monolithic') {
|
||||
$this->handleMonolithicDeployment($input, $image);
|
||||
$clientJobs = $this->handleMonolithicDeployment($input, $image);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
return new JsonResponse(data: $clientJobs, status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
private function handleMonolithicDeployment(DeployImageInput $input, ImageImageRepository $image): void
|
||||
private function handleMonolithicDeployment(DeployImageInput $input, ImageImageRepository $image): array
|
||||
{
|
||||
$clientJobs = [];
|
||||
|
||||
switch ($input->method) {
|
||||
case DeployMethodTypes::UNICAST:
|
||||
case DeployMethodTypes::UNICAST_DIRECT:
|
||||
$this->handleUnicastDeployment($input, $image);
|
||||
$clientJobs = $this->handleUnicastDeployment($input, $image);
|
||||
break;
|
||||
case DeployMethodTypes::MULTICAST_UFTP:
|
||||
case DeployMethodTypes::MULTICAST_UFTP_DIRECT:
|
||||
case DeployMethodTypes::MULTICAST_UDPCAST:
|
||||
case DeployMethodTypes::MULTICAST_UDPCAST_DIRECT:
|
||||
$this->handleMulticastDeployment($input, $image);
|
||||
$clientJobs = $this->handleMulticastDeployment($input, $image);
|
||||
break;
|
||||
case DeployMethodTypes::TORRENT:
|
||||
$this->handleTorrentDeployment($input, $image);
|
||||
$clientJobs = $this->handleTorrentDeployment($input, $image);
|
||||
break;
|
||||
}
|
||||
|
||||
return $clientJobs;
|
||||
}
|
||||
|
||||
private function handleUnicastDeployment(DeployImageInput $input, ImageImageRepository $image): void
|
||||
private function handleUnicastDeployment(DeployImageInput $input, ImageImageRepository $image): array
|
||||
{
|
||||
$clientJobs = [];
|
||||
|
||||
foreach ($input->clients as $client) {
|
||||
$inputData = $this->createInputData($input, $image, $client->getEntity());
|
||||
$this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::UNICAST);
|
||||
$jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::UNICAST);
|
||||
|
||||
if ($jobId) {
|
||||
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
|
||||
}
|
||||
}
|
||||
|
||||
return $clientJobs;
|
||||
}
|
||||
|
||||
private function handleMulticastDeployment(DeployImageInput $input, ImageImageRepository $image): void
|
||||
private function handleMulticastDeployment(DeployImageInput $input, ImageImageRepository $image): array
|
||||
{
|
||||
$clientJobs = [];
|
||||
|
||||
foreach ($input->clients as $client) {
|
||||
$inputData = $this->createMulticastInputData($input, $image, $client->getEntity());
|
||||
|
||||
|
@ -92,12 +108,20 @@ class DeployImageAction extends AbstractController
|
|||
continue;
|
||||
}
|
||||
|
||||
$this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::MULTICAST);
|
||||
$jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::MULTICAST);
|
||||
|
||||
if ($jobId) {
|
||||
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
|
||||
}
|
||||
}
|
||||
|
||||
return $clientJobs;
|
||||
}
|
||||
|
||||
private function handleTorrentDeployment(DeployImageInput $input, ImageImageRepository $image): void
|
||||
private function handleTorrentDeployment(DeployImageInput $input, ImageImageRepository $image): array
|
||||
{
|
||||
$clientJobs = [];
|
||||
|
||||
foreach ($input->clients as $client) {
|
||||
$inputData = $this->createTorrentInputData($input, $image, $client->getEntity());
|
||||
|
||||
|
@ -112,11 +136,17 @@ class DeployImageAction extends AbstractController
|
|||
throw $e;
|
||||
}
|
||||
|
||||
$this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::TORRENT);
|
||||
$jobId = $this->processDeployment($client->getEntity(), $input, $image, $inputData, DeployMethodTypes::TORRENT);
|
||||
|
||||
if ($jobId) {
|
||||
$clientJobs[(string) '/clients/' . $client->getEntity()->getUuid()] = $jobId;
|
||||
}
|
||||
}
|
||||
|
||||
return $clientJobs;
|
||||
}
|
||||
|
||||
private function processDeployment($client, DeployImageInput $input, ImageImageRepository $image, array $inputData, string $deployType): void
|
||||
private function processDeployment($client, DeployImageInput $input, ImageImageRepository $image, array $inputData, string $deployType): ?string
|
||||
{
|
||||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, $client, $deployType);
|
||||
|
||||
|
@ -124,10 +154,12 @@ class DeployImageAction extends AbstractController
|
|||
if ($input->queue) {
|
||||
$this->createService->__invoke($client, CommandTypes::DEPLOY_IMAGE, TraceStatus::PENDING, null, $inputData);
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
|
||||
return $agentJobId;
|
||||
}
|
||||
|
||||
private function createInputData(DeployImageInput $input, ImageImageRepository $image, $client): array
|
||||
|
|
|
@ -213,7 +213,7 @@ class CreateImageAction extends AbstractOgAgentController
|
|||
);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: $image, status: Response::HTTP_OK);
|
||||
return new JsonResponse(data: ['/clients/' . $client->getUuid() => $jobId], status: Response::HTTP_OK);
|
||||
} catch (Exception $e) {
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($client);
|
||||
|
@ -351,7 +351,7 @@ class CreateImageAction extends AbstractOgAgentController
|
|||
);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: $image, status: Response::HTTP_OK);
|
||||
return new JsonResponse(data: ['/clients/' . $client->getUuid() => $jobId], status: Response::HTTP_OK);
|
||||
} catch (Exception $e) {
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($client);
|
||||
|
|
|
@ -45,6 +45,8 @@ class PartitionAssistantAction extends AbstractOgAgentController
|
|||
throw new BadRequestHttpException('Partitions is required');
|
||||
}
|
||||
|
||||
$clientJobs = [];
|
||||
|
||||
foreach ($input->clients as $clientInput) {
|
||||
/** @var Client $client */
|
||||
$client = $clientInput->getEntity();
|
||||
|
@ -134,9 +136,11 @@ class PartitionAssistantAction extends AbstractOgAgentController
|
|||
} else {
|
||||
$this->createService->__invoke($client, CommandTypes::PARTITION_AND_FORMAT, TraceStatus::IN_PROGRESS, $jobId, $data);
|
||||
}
|
||||
|
||||
$clientJobs['/clients/' . $client->getUuid()] = $jobId;
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
return new JsonResponse(data: $clientJobs, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class RunScriptAction extends AbstractOgAgentController
|
|||
}
|
||||
|
||||
$jobId = $response['job_id'];
|
||||
$clientJobs[(string) $client->get] = $jobId;
|
||||
$clientJobs[(string) '/clients/' . $client->getUuid()] = $jobId;
|
||||
|
||||
$this->handleSuccess($client, $input, $response, $existingTrace);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class DeleteHostAction extends AbstractOgDhcpController
|
|||
{
|
||||
$client = $this->entityManager->getRepository(Client::class)->findOneBy(['uuid' => $clientUuid]);
|
||||
|
||||
if (!$client || $client->getSubnet() !== $data) {
|
||||
if (!$client) {
|
||||
throw new BadRequestHttpException('Client not found');
|
||||
}
|
||||
|
||||
|
|
|
@ -103,16 +103,16 @@ readonly class ClientProcessor implements ProcessorInterface
|
|||
private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null
|
||||
{
|
||||
$client = $this->clientRepository->findOneByUuid($uriVariables['uuid']);
|
||||
$this->clientRepository->delete($client);
|
||||
|
||||
if ($this->kernel->getEnvironment() !== 'test') {
|
||||
|
||||
if ($client->getSubnet()) {
|
||||
$this->deleteHostAction->__invoke($client->getSubnet(), $client->getUuid());
|
||||
}
|
||||
$this->deletePxeAction->__invoke($client->getUuid());
|
||||
$this->deletePxeAction->__invoke($client->getMac());
|
||||
}
|
||||
|
||||
$this->clientRepository->delete($client);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
|||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
readonly class ImageProcessor implements ProcessorInterface
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ readonly class ImageProcessor implements ProcessorInterface
|
|||
* @throws \Exception
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): ImageOutput|null
|
||||
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): ImageOutput|null|JsonResponse
|
||||
{
|
||||
switch ($operation){
|
||||
case $operation instanceof Post:
|
||||
|
@ -55,7 +56,7 @@ readonly class ImageProcessor implements ProcessorInterface
|
|||
* @throws \Exception
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): ImageOutput
|
||||
private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): JsonResponse
|
||||
{
|
||||
if (!($data instanceof ImageInput)) {
|
||||
throw new \Exception(sprintf('data is not instance of %s', ImageInput::class));
|
||||
|
@ -87,7 +88,12 @@ readonly class ImageProcessor implements ProcessorInterface
|
|||
throw new \Exception($content['error'] ?? 'Error creating image');
|
||||
}
|
||||
|
||||
return new ImageOutput($data->selectedImage?->getEntity() ?? $image);
|
||||
if ($response instanceof JsonResponse && $response->getStatusCode() === 200) {
|
||||
$jobContent = json_decode($response->getContent(), true);
|
||||
return new JsonResponse(data: $jobContent, status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: ['/clients/' . $image->getClient()->getUuid() => ['headers' => []]], status: Response::HTTP_OK);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error('Error processing image creation/update', [
|
||||
'error' => $e->getMessage(),
|
||||
|
|
|
@ -74,7 +74,13 @@ readonly class PartitionProcessor implements ProcessorInterface
|
|||
//$this->partitionRepository->save($entity);
|
||||
}
|
||||
|
||||
$this->partitionAssistantAction->__invoke($data);
|
||||
$response = $this->partitionAssistantAction->__invoke($data);
|
||||
|
||||
// Si hay una respuesta exitosa, devolvemos el contenido del job ID
|
||||
if ($response instanceof JsonResponse && $response->getStatusCode() === 200) {
|
||||
$jobContent = json_decode($response->getContent(), true);
|
||||
return new JsonResponse(data: $jobContent, status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
return new JsonResponse('OK', Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue