composer-install
parent
0f52548284
commit
e27e4b408f
|
@ -11,9 +11,11 @@ use App\Entity\Trace;
|
|||
use App\Model\ClientStatus;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\ImageStatus;
|
||||
use App\Model\PartitionTypes;
|
||||
use App\Model\TraceStatus;
|
||||
use App\Service\Trace\CreateService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -35,6 +37,12 @@ class CreateImageAction extends AbstractController
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(Image $image): JsonResponse
|
||||
{
|
||||
if (!$image->getClient()->getIp()) {
|
||||
|
@ -46,7 +54,7 @@ class CreateImageAction extends AbstractController
|
|||
$data = [
|
||||
'dsk' => (string) $partitionInfo['numDisk'],
|
||||
'par' => (string) $partitionInfo['numPartition'],
|
||||
'cpt' => "83",
|
||||
'cpt' => null,
|
||||
'idi' => $image->getUuid(),
|
||||
'nci' => $image->getName(),
|
||||
'ipr' => $image->getRepository()->getIp(),
|
||||
|
@ -54,6 +62,20 @@ class CreateImageAction extends AbstractController
|
|||
'ids' => '0'
|
||||
];
|
||||
|
||||
$partitionTypes = PartitionTypes::getPartitionTypes();
|
||||
|
||||
$partitionCode = $partitionInfo['partitionCode'];
|
||||
$cptKey = array_search($partitionCode, array_column($partitionTypes, 'name'), true);
|
||||
|
||||
if ($cptKey !== false) {
|
||||
$keys = array_keys($partitionTypes);
|
||||
$partitionTypeCode = $keys[$cptKey];
|
||||
|
||||
$data['cpt'] = dechex($partitionTypeCode);
|
||||
} else {
|
||||
throw new Exception("El tipo de partición '$partitionCode' no se encontró en la lista.");
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->httpClient->request('POST', 'https://'.$image->getClient()->getIp().':8000/CloningEngine/CrearImagen', [
|
||||
'verify_peer' => false,
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Entity\OperativeSystem;
|
|||
use App\Entity\Partition;
|
||||
use App\Model\PartitionTypes;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
|
||||
class CreatePartitionService
|
||||
{
|
||||
|
@ -52,12 +53,20 @@ class CreatePartitionService
|
|||
$partitionEntity->setPartitionNumber($cfg['par']);
|
||||
$partitionEntity->setSize($cfg['tam']);
|
||||
|
||||
if (isset($cfg['cpt']) && $cfg['fsi'] !== '') {
|
||||
$partitionEntity->setPartitionCode(PartitionTypes::getPartitionType(hexdec((integer)$cfg['cpt']))['name']);
|
||||
if (isset($cfg['cpt']) && $cfg['cpt'] !== '') {
|
||||
$decimalValue = hexdec($cfg['cpt']);
|
||||
$partitionType = PartitionTypes::getPartitionType($decimalValue);
|
||||
|
||||
if ($partitionType) {
|
||||
$partitionEntity->setPartitionCode($partitionType['name']);
|
||||
} else {
|
||||
throw new Exception("El tipo de partición con código {$decimalValue} no se encontró.");
|
||||
}
|
||||
} else {
|
||||
$partitionEntity->setPartitionCode(PartitionTypes::getPartitionType(0)['name']);
|
||||
}
|
||||
|
||||
|
||||
$partitionEntity->setFilesystem($cfg['fsi']);
|
||||
$partitionEntity->setMemoryUsage(((int) $cfg['uso']) * 100);
|
||||
$this->entityManager->persist($partitionEntity);
|
||||
|
|
Loading…
Reference in New Issue