From 744f655bb472b9f36d06ba6f84cf4b98490e8989 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Wed, 3 Sep 2025 17:10:33 +0200 Subject: [PATCH 1/2] refs #2753. Command task bug. Partition --- src/Command/ExecutePendingTracesCommand.php | 63 ++++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/Command/ExecutePendingTracesCommand.php b/src/Command/ExecutePendingTracesCommand.php index 89cc958..383ffbd 100644 --- a/src/Command/ExecutePendingTracesCommand.php +++ b/src/Command/ExecutePendingTracesCommand.php @@ -165,15 +165,39 @@ class ExecutePendingTracesCommand extends Command { $client = $trace->getClient(); - if (!isset($input['image'])) { - throw new \Exception("Image UUID not found in trace input"); + $image = null; + + if (isset($input['action']) && $input['action'] === 'create') { + $image = new Image(); + $image->setName($input['imageName'] ?? 'Image_' . uniqid()); + $image->setType($input['type'] ?? 'monolithic'); + $image->setRemotePc($input['remotePc'] ?? false); + $image->setIsGlobal($input['isGlobal'] ?? false); + $image->setClient($client); + $this->entityManager->persist($image); + } elseif (isset($input['action']) && $input['action'] === 'update') { + if (!isset($input['imageUuid'])) { + throw new \Exception("Image UUID not found in trace input for update operation"); + } + + $image = $this->entityManager->getRepository(Image::class) + ->findOneBy(['uuid' => $input['imageUuid']]); + + if (!$image) { + throw new \Exception("Image not found with UUID: {$input['imageUuid']} for update operation"); + } + } else { + throw new \Exception("Either 'create' or 'update' field must be set to true in trace input"); } - - $image = $this->entityManager->getRepository(Image::class) - ->findOneBy(['uuid' => $input['image']]); - - if (!$image) { - throw new \Exception("Image not found with UUID: {$input['image']}"); + + if (isset($input['diskNumber']) && isset($input['partitionNumber'])) { + $partitionInfo = [ + 'numDisk' => $input['diskNumber'], + 'numPartition' => $input['partitionNumber'], + 'partitionCode' => $input['partitionCode'] ?? 'LINUX', + 'filesystem' => $input['filesystem'] ?? 'EXT4' + ]; + $image->setPartitionInfo(json_encode($partitionInfo)); } $partition = null; @@ -201,7 +225,7 @@ class ExecutePendingTracesCommand extends Command ); if ($response->getStatusCode() === 200) { - $trace->setStatus(TraceStatus::SUCCESS); + $trace->setStatus(TraceStatus::IN_PROGRESS); $trace->setFinishedAt(new \DateTime()); $this->entityManager->persist($trace); $this->entityManager->flush(); @@ -265,21 +289,16 @@ class ExecutePendingTracesCommand extends Command $partitionInput->clients = [new ClientOutput($client)]; $partitions = []; - $diskNumber = 1; foreach ($input as $item) { - if (isset($item['dis'])) { - $diskNumber = (int)$item['dis']; - } elseif (isset($item['par'])) { - $partitionInputObj = new PartitionInput(); - $partitionInputObj->diskNumber = $diskNumber; - $partitionInputObj->partitionNumber = (int)$item['par']; - $partitionInputObj->partitionCode = $item['cpt'] ?? 'LINUX'; - $partitionInputObj->size = (float)($item['tam'] / 1024); - $partitionInputObj->filesystem = $item['sfi'] ?? 'EXT4'; - $partitionInputObj->format = ($item['ope'] ?? '0') === '1'; - $partitions[] = $partitionInputObj; - } + $partitionInputObj = new PartitionInput(); + $partitionInputObj->diskNumber = $item['diskNumber']; + $partitionInputObj->partitionNumber = (int)$item['partitionNumber']; + $partitionInputObj->partitionCode = $item['partitionCode'] ?? 'LINUX'; + $partitionInputObj->size = (float)($item['size'] / 1024); + $partitionInputObj->filesystem = $item['filesystem'] ?? 'EXT4'; + $partitionInputObj->format = ($item['format'] ?? '0') === '1'; + $partitions[] = $partitionInputObj; } $partitionInput->partitions = $partitions; -- 2.40.1 From 20ac98c29c0013b446be493bd83582ad7fed4761 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Wed, 3 Sep 2025 17:11:26 +0200 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0d743e..b9eda4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## [0.22.2] - 2025-09-03 +### Fixed +- Se ha corregido un error con el particionador, en las tareas programadas. + +--- ## [0.22.1] - 2025-09-03 ### Fixed - Se ha corregido un typo. -- 2.40.1