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 */
|
/** @var Client $client */
|
||||||
$client = $input->partitions[0]->client->getEntity();
|
$client = $input->partitions[0]->client->getEntity();
|
||||||
|
|
||||||
$data = [];
|
|
||||||
$diskNumber = 0;
|
|
||||||
$cacheSize = 0;
|
|
||||||
$disks = [];
|
$disks = [];
|
||||||
$cpt = '';
|
|
||||||
|
|
||||||
$data = [];
|
|
||||||
$diskData = [];
|
|
||||||
|
|
||||||
foreach ($partitions as $partition) {
|
foreach ($partitions as $partition) {
|
||||||
if ($partition->filesystem === 'CACHE') {
|
|
||||||
$cacheSize = $partition->size * 1024;
|
|
||||||
$disks[$partition->diskNumber] = $cacheSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
$diskNumber = $partition->diskNumber;
|
$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,
|
'par' => (string) $partition->partitionNumber,
|
||||||
'cpt' => $partition->partitionCode,
|
'cpt' => $partition->partitionCode,
|
||||||
'sfi' => $partition->filesystem,
|
'sfi' => $partition->filesystem,
|
||||||
|
@ -73,48 +75,47 @@ class PartitionAssistantAction extends AbstractController
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($disks as $diskNumber => $size) {
|
// Hacer una llamada por cada disco
|
||||||
$diskData[] = [
|
foreach ($disks as $diskNumber => $diskInfo) {
|
||||||
'dis' => (string) $diskNumber,
|
$data = [];
|
||||||
'che' => "0",
|
if (!empty($diskInfo['diskData'])) {
|
||||||
'tch' => (string) $size,
|
$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);
|
return new JsonResponse(data: $client, status: Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,9 @@ class ClientsController extends AbstractController
|
||||||
$trace->setFinishedAt(new \DateTime());
|
$trace->setFinishedAt(new \DateTime());
|
||||||
$image->setStatus(ImageStatus::PENDING);
|
$image->setStatus(ImageStatus::PENDING);
|
||||||
$client->setStatus(ClientStatus::OG_LIVE);
|
$client->setStatus(ClientStatus::OG_LIVE);
|
||||||
|
if (isset($data['cfg'])) {
|
||||||
|
$this->createPartitionService->__invoke($data,$client);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$trace->setStatus(TraceStatus::FAILED);
|
$trace->setStatus(TraceStatus::FAILED);
|
||||||
$trace->setFinishedAt(new \DateTime());
|
$trace->setFinishedAt(new \DateTime());
|
||||||
|
@ -145,7 +148,6 @@ class ClientsController extends AbstractController
|
||||||
if ($data['res'] === 1) {
|
if ($data['res'] === 1) {
|
||||||
$trace->setStatus(TraceStatus::SUCCESS);
|
$trace->setStatus(TraceStatus::SUCCESS);
|
||||||
$trace->setFinishedAt(new \DateTime());
|
$trace->setFinishedAt(new \DateTime());
|
||||||
$client->setStatus(ClientStatus::OG_LIVE);
|
|
||||||
if (isset($data['cfg'])) {
|
if (isset($data['cfg'])) {
|
||||||
$this->createPartitionService->__invoke($data,$client);
|
$this->createPartitionService->__invoke($data,$client);
|
||||||
}
|
}
|
||||||
|
@ -155,6 +157,8 @@ class ClientsController extends AbstractController
|
||||||
$trace->setOutput($data['der']);
|
$trace->setOutput($data['der']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$client->setStatus(ClientStatus::OG_LIVE);
|
||||||
|
|
||||||
$this->entityManager->persist($client);
|
$this->entityManager->persist($client);
|
||||||
$this->entityManager->persist($trace);
|
$this->entityManager->persist($trace);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
|
@ -32,6 +32,7 @@ class PostAction extends AbstractOgDhcpController
|
||||||
'address' => $data->getIpAddress(),
|
'address' => $data->getIpAddress(),
|
||||||
'nextServer' => $data->getNextServer(),
|
'nextServer' => $data->getNextServer(),
|
||||||
'bootFileName' => $data->getBootFileName(),
|
'bootFileName' => $data->getBootFileName(),
|
||||||
|
'router' => $data->getRouter(),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ class PutAction extends AbstractOgDhcpController
|
||||||
'address' => $data->getIpAddress(),
|
'address' => $data->getIpAddress(),
|
||||||
'nextServer' => $data->getNextServer(),
|
'nextServer' => $data->getNextServer(),
|
||||||
'bootFileName' => $data->getBootFileName(),
|
'bootFileName' => $data->getBootFileName(),
|
||||||
|
'router' => $data->getRouter(),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@ final class SubnetInput
|
||||||
#[ApiProperty(description: 'The next server of the subnet', example: "")]
|
#[ApiProperty(description: 'The next server of the subnet', example: "")]
|
||||||
public ?string $nextServer = null;
|
public ?string $nextServer = null;
|
||||||
|
|
||||||
|
#[Groups(['subnet:write'])]
|
||||||
|
#[ApiProperty(description: 'The router of the subnet', example: "")]
|
||||||
|
public ?string $router = null;
|
||||||
|
|
||||||
#[Groups(['subnet:write'])]
|
#[Groups(['subnet:write'])]
|
||||||
#[ApiProperty(description: 'The boot file name of the subnet', example: "")]
|
#[ApiProperty(description: 'The boot file name of the subnet', example: "")]
|
||||||
public ?string $bootFileName = null;
|
public ?string $bootFileName = null;
|
||||||
|
@ -52,6 +56,7 @@ final class SubnetInput
|
||||||
$this->name = $subnet->getName();
|
$this->name = $subnet->getName();
|
||||||
$this->netmask = $subnet->getNetmask();
|
$this->netmask = $subnet->getNetmask();
|
||||||
$this->ipAddress = $subnet->getIpAddress();
|
$this->ipAddress = $subnet->getIpAddress();
|
||||||
|
$this->router = $subnet->getRouter();
|
||||||
$this->nextServer = $subnet->getNextServer();
|
$this->nextServer = $subnet->getNextServer();
|
||||||
$this->bootFileName = $subnet->getBootFileName();
|
$this->bootFileName = $subnet->getBootFileName();
|
||||||
|
|
||||||
|
@ -73,6 +78,7 @@ final class SubnetInput
|
||||||
$subnet->setIpAddress($this->ipAddress);
|
$subnet->setIpAddress($this->ipAddress);
|
||||||
$subnet->setNextServer($this->nextServer);
|
$subnet->setNextServer($this->nextServer);
|
||||||
$subnet->setBootFileName($this->bootFileName);
|
$subnet->setBootFileName($this->bootFileName);
|
||||||
|
$subnet->setRouter($this->router);
|
||||||
|
|
||||||
foreach ($this->organizationalUnits as $organizationalUnit) {
|
foreach ($this->organizationalUnits as $organizationalUnit) {
|
||||||
$organizationalUnitToAdd[] = $organizationalUnit->getEntity();
|
$organizationalUnitToAdd[] = $organizationalUnit->getEntity();
|
||||||
|
|
|
@ -27,6 +27,9 @@ final class SubnetOutput extends AbstractOutput
|
||||||
#[Groups(['subnet:read'])]
|
#[Groups(['subnet:read'])]
|
||||||
public ?string $bootFileName = null;
|
public ?string $bootFileName = null;
|
||||||
|
|
||||||
|
#[Groups(['subnet:read'])]
|
||||||
|
public ?string $router = null;
|
||||||
|
|
||||||
#[Groups(['subnet:read'])]
|
#[Groups(['subnet:read'])]
|
||||||
public array $clients;
|
public array $clients;
|
||||||
|
|
||||||
|
@ -50,6 +53,7 @@ final class SubnetOutput extends AbstractOutput
|
||||||
$this->netmask = $subnet->getNetmask();
|
$this->netmask = $subnet->getNetmask();
|
||||||
$this->ipAddress = $subnet->getIpAddress();
|
$this->ipAddress = $subnet->getIpAddress();
|
||||||
$this->nextServer = $subnet->getNextServer();
|
$this->nextServer = $subnet->getNextServer();
|
||||||
|
$this->router = $subnet->getRouter();
|
||||||
$this->bootFileName = $subnet->getBootFileName();
|
$this->bootFileName = $subnet->getBootFileName();
|
||||||
$this->synchronized = $subnet->isSynchronized();
|
$this->synchronized = $subnet->isSynchronized();
|
||||||
$this->serverId = $subnet->getServerId();
|
$this->serverId = $subnet->getServerId();
|
||||||
|
|
|
@ -40,6 +40,9 @@ class Subnet extends AbstractEntity
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
private ?int $serverId = null;
|
private ?int $serverId = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $router = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
@ -187,4 +190,16 @@ class Subnet extends AbstractEntity
|
||||||
|
|
||||||
return $this;
|
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 = new Trace();
|
||||||
$trace->setClient($client);
|
$trace->setClient($client);
|
||||||
|
|
Loading…
Reference in New Issue