develop #51

Merged
maranda merged 2 commits from develop into main 2025-09-03 17:12:03 +02:00
2 changed files with 46 additions and 22 deletions

View File

@ -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.

View File

@ -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;