Added router in subnet. Advanced bootfile changes, and partition assistant updates
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
7856741928
commit
0002ea4ccc
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20241205110301 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE subnet ADD router VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE subnet DROP router');
|
||||
}
|
||||
}
|
|
@ -47,24 +47,26 @@ class PartitionAssistantAction extends AbstractController
|
|||
/** @var Client $client */
|
||||
$client = $input->partitions[0]->client->getEntity();
|
||||
|
||||
$data = [];
|
||||
$diskNumber = 0;
|
||||
$cacheSize = 0;
|
||||
$disks = [];
|
||||
$cpt = '';
|
||||
|
||||
$data = [];
|
||||
$diskData = [];
|
||||
|
||||
foreach ($partitions as $partition) {
|
||||
if ($partition->filesystem === 'CACHE') {
|
||||
$cacheSize = $partition->size * 1024;
|
||||
$disks[$partition->diskNumber] = $cacheSize;
|
||||
}
|
||||
|
||||
$diskNumber = $partition->diskNumber;
|
||||
|
||||
$data[] = [
|
||||
if (!isset($disks[$diskNumber])) {
|
||||
$disks[$diskNumber] = [
|
||||
'diskData' => [],
|
||||
'partitionData' => []
|
||||
];
|
||||
}
|
||||
|
||||
if ($partition->filesystem === 'CACHE') {
|
||||
$disks[$diskNumber]['diskData'] = [
|
||||
'dis' => (string) $diskNumber,
|
||||
'che' => "0",
|
||||
'tch' => (string) ($partition->size * 1024),
|
||||
];
|
||||
}
|
||||
|
||||
$disks[$diskNumber]['partitionData'][] = [
|
||||
'par' => (string) $partition->partitionNumber,
|
||||
'cpt' => $partition->partitionCode,
|
||||
'sfi' => $partition->filesystem,
|
||||
|
@ -73,48 +75,47 @@ class PartitionAssistantAction extends AbstractController
|
|||
];
|
||||
}
|
||||
|
||||
foreach ($disks as $diskNumber => $size) {
|
||||
$diskData[] = [
|
||||
'dis' => (string) $diskNumber,
|
||||
'che' => "0",
|
||||
'tch' => (string) $size,
|
||||
// Hacer una llamada por cada disco
|
||||
foreach ($disks as $diskNumber => $diskInfo) {
|
||||
$data = [];
|
||||
if (!empty($diskInfo['diskData'])) {
|
||||
$data[] = $diskInfo['diskData'];
|
||||
}
|
||||
$data = array_merge($data, $diskInfo['partitionData']);
|
||||
|
||||
$result = [
|
||||
"nfn" => "Configurar",
|
||||
"dsk" => (string) $diskNumber,
|
||||
"cfg" => $data,
|
||||
"ids" => "0"
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/CloningEngine/Configurar', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'json' => $result,
|
||||
]);
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
return new JsonResponse(
|
||||
data: ['error' => "Error en disco $diskNumber: " . $e->getMessage()],
|
||||
status: Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$jobId = json_decode($response->getContent(), true)['job_id'];
|
||||
|
||||
$client->setStatus(ClientStatus::BUSY);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::PARTITION_AND_FORMAT, TraceStatus::IN_PROGRESS, $jobId, []);
|
||||
}
|
||||
|
||||
$data = array_merge($diskData, $data);
|
||||
|
||||
$result = [
|
||||
"nfn" => "Configurar",
|
||||
"dsk" => "1",
|
||||
"cfg" => $data,
|
||||
"ids" => "0"
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpClient->request('POST', 'https://'.$client->getIp().':8000/CloningEngine/Configurar', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'json' => $result,
|
||||
]);
|
||||
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
return new JsonResponse(
|
||||
data: ['error' => $e->getMessage()],
|
||||
status: Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$jobId = json_decode($response->getContent(), true)['job_id'];
|
||||
|
||||
$client->setStatus(ClientStatus::BUSY);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::PARTITION_AND_FORMAT, TraceStatus::IN_PROGRESS, $jobId, []);
|
||||
|
||||
return new JsonResponse(data: $client, status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -124,6 +124,9 @@ class ClientsController extends AbstractController
|
|||
$trace->setFinishedAt(new \DateTime());
|
||||
$image->setStatus(ImageStatus::PENDING);
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
if (isset($data['cfg'])) {
|
||||
$this->createPartitionService->__invoke($data,$client);
|
||||
}
|
||||
} else {
|
||||
$trace->setStatus(TraceStatus::FAILED);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
|
@ -145,7 +148,6 @@ class ClientsController extends AbstractController
|
|||
if ($data['res'] === 1) {
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
if (isset($data['cfg'])) {
|
||||
$this->createPartitionService->__invoke($data,$client);
|
||||
}
|
||||
|
@ -155,6 +157,8 @@ class ClientsController extends AbstractController
|
|||
$trace->setOutput($data['der']);
|
||||
}
|
||||
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->persist($trace);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -32,6 +32,7 @@ class PostAction extends AbstractOgDhcpController
|
|||
'address' => $data->getIpAddress(),
|
||||
'nextServer' => $data->getNextServer(),
|
||||
'bootFileName' => $data->getBootFileName(),
|
||||
'router' => $data->getRouter(),
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class PutAction extends AbstractOgDhcpController
|
|||
'address' => $data->getIpAddress(),
|
||||
'nextServer' => $data->getNextServer(),
|
||||
'bootFileName' => $data->getBootFileName(),
|
||||
'router' => $data->getRouter(),
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
@ -32,6 +32,10 @@ final class SubnetInput
|
|||
#[ApiProperty(description: 'The next server of the subnet', example: "")]
|
||||
public ?string $nextServer = null;
|
||||
|
||||
#[Groups(['subnet:write'])]
|
||||
#[ApiProperty(description: 'The router of the subnet', example: "")]
|
||||
public ?string $router = null;
|
||||
|
||||
#[Groups(['subnet:write'])]
|
||||
#[ApiProperty(description: 'The boot file name of the subnet', example: "")]
|
||||
public ?string $bootFileName = null;
|
||||
|
@ -52,6 +56,7 @@ final class SubnetInput
|
|||
$this->name = $subnet->getName();
|
||||
$this->netmask = $subnet->getNetmask();
|
||||
$this->ipAddress = $subnet->getIpAddress();
|
||||
$this->router = $subnet->getRouter();
|
||||
$this->nextServer = $subnet->getNextServer();
|
||||
$this->bootFileName = $subnet->getBootFileName();
|
||||
|
||||
|
@ -73,6 +78,7 @@ final class SubnetInput
|
|||
$subnet->setIpAddress($this->ipAddress);
|
||||
$subnet->setNextServer($this->nextServer);
|
||||
$subnet->setBootFileName($this->bootFileName);
|
||||
$subnet->setRouter($this->router);
|
||||
|
||||
foreach ($this->organizationalUnits as $organizationalUnit) {
|
||||
$organizationalUnitToAdd[] = $organizationalUnit->getEntity();
|
||||
|
|
|
@ -27,6 +27,9 @@ final class SubnetOutput extends AbstractOutput
|
|||
#[Groups(['subnet:read'])]
|
||||
public ?string $bootFileName = null;
|
||||
|
||||
#[Groups(['subnet:read'])]
|
||||
public ?string $router = null;
|
||||
|
||||
#[Groups(['subnet:read'])]
|
||||
public array $clients;
|
||||
|
||||
|
@ -50,6 +53,7 @@ final class SubnetOutput extends AbstractOutput
|
|||
$this->netmask = $subnet->getNetmask();
|
||||
$this->ipAddress = $subnet->getIpAddress();
|
||||
$this->nextServer = $subnet->getNextServer();
|
||||
$this->router = $subnet->getRouter();
|
||||
$this->bootFileName = $subnet->getBootFileName();
|
||||
$this->synchronized = $subnet->isSynchronized();
|
||||
$this->serverId = $subnet->getServerId();
|
||||
|
|
|
@ -40,6 +40,9 @@ class Subnet extends AbstractEntity
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $serverId = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $router = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -187,4 +190,16 @@ class Subnet extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRouter(): ?string
|
||||
{
|
||||
return $this->router;
|
||||
}
|
||||
|
||||
public function setRouter(?string $router): static
|
||||
{
|
||||
$this->router = $router;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ readonly class CreateService
|
|||
{
|
||||
}
|
||||
|
||||
public function __invoke(Client $client, ?string $command, string $status, string $jobId, ?array $input = []): Trace
|
||||
public function __invoke(Client $client, ?string $command, string $status, ?string $jobId = '', ?array $input = []): Trace
|
||||
{
|
||||
$trace = new Trace();
|
||||
$trace->setClient($client);
|
||||
|
|
Loading…
Reference in New Issue