Updated APIS, and general improvements
parent
5c91265417
commit
2f89e5bc57
|
@ -51,8 +51,8 @@ resources:
|
|||
trash_delete_image_ogrepository:
|
||||
shortName: OgRepository Server
|
||||
description: Delete Image in OgRepository
|
||||
class: ApiPlatform\Metadata\Delete
|
||||
method: DELETE
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: false
|
||||
uriTemplate: /images/server/{uuid}/delete-trash
|
||||
controller: App\Controller\OgRepository\Image\DeleteTrashAction
|
||||
|
@ -60,12 +60,21 @@ resources:
|
|||
permanent_delete_image_ogrepository:
|
||||
shortName: OgRepository Server
|
||||
description: Delete Image in OgRepository
|
||||
class: ApiPlatform\Metadata\Delete
|
||||
method: DELETE
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: false
|
||||
uriTemplate: /images/server/{uuid}/delete-permanent
|
||||
controller: App\Controller\OgRepository\Image\DeletePermanentAction
|
||||
|
||||
recover_image_ogrepository:
|
||||
shortName: OgRepository Server
|
||||
description: Recover Image in OgRepository
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: false
|
||||
uriTemplate: /images/server/{uuid}/recover
|
||||
controller: App\Controller\OgRepository\Image\RecoverAction
|
||||
|
||||
properties:
|
||||
App\Entity\Image:
|
||||
id:
|
||||
|
|
5
env.json
5
env.json
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"vars": {
|
||||
"OG_BOOT_API_URL": "http:\/\/192.168.18.48",
|
||||
"OG_DHCP_API_URL": "http:\/\/192.168.18.48:81",
|
||||
"OG_BOOT_API_URL": "192.168.68.58",
|
||||
"OG_DHCP_API_URL": "192.168.68.58:81",
|
||||
"OG_CORE_IP": "192.168.68.62",
|
||||
"UDS_AUTH_LOGIN": "Usuarios locales",
|
||||
"UDS_AUTH_USERNAME": "natiqindel",
|
||||
"UDS_AUTH_PASSWORD": "correct horse battery staple",
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?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 Version20241120050107 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 trace DROP FOREIGN KEY FK_315BD5A133E1689A');
|
||||
$this->addSql('DROP INDEX IDX_315BD5A133E1689A ON trace');
|
||||
$this->addSql('ALTER TABLE trace ADD command VARCHAR(255) DEFAULT NULL, DROP command_id');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE trace ADD command_id INT NOT NULL, DROP command');
|
||||
$this->addSql('ALTER TABLE trace ADD CONSTRAINT FK_315BD5A133E1689A FOREIGN KEY (command_id) REFERENCES command (id)');
|
||||
$this->addSql('CREATE INDEX IDX_315BD5A133E1689A ON trace (command_id)');
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ use App\Dto\Input\DeployImageInput;
|
|||
use App\Entity\Command;
|
||||
use App\Entity\Image;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\DeployMethodTypes;
|
||||
use App\Model\TraceStatus;
|
||||
use App\Service\Trace\CreateService;
|
||||
|
@ -32,8 +33,6 @@ class DeployImageAction extends AbstractController
|
|||
|
||||
public function __invoke(DeployImageInput $input, Image $image): JsonResponse
|
||||
{
|
||||
$command = $this->entityManager->getRepository(Command::class)->findOneBy(['name' => 'Restaurar Imagen']);
|
||||
|
||||
$partitionInfo = json_decode($image->getPartitionInfo(), true);
|
||||
|
||||
$inputData = [
|
||||
|
@ -52,43 +51,18 @@ class DeployImageAction extends AbstractController
|
|||
|
||||
switch ($input->method){
|
||||
case DeployMethodTypes::UNICAST:
|
||||
$data = [
|
||||
'dsk' => (string) $partitionInfo['numDisk'],
|
||||
'par' => (string) $partitionInfo['numPartition'],
|
||||
'ifs' => "1",
|
||||
'cpt' => "83",
|
||||
'idi' => $image->getUuid(),
|
||||
'nci' => $image->getName(),
|
||||
'ipr' => $image->getRepository()->getIp(),
|
||||
'nfn' => 'RestaurarImagen',
|
||||
'ptc' => DeployMethodTypes::UNICAST,
|
||||
'ids' => '0'
|
||||
];
|
||||
|
||||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $command, $input->client->getEntity());
|
||||
$this->createService->__invoke($input->client->getEntity(), $command, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, DeployMethodTypes::UNICAST);
|
||||
$this->createService->__invoke($input->client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
|
||||
break;
|
||||
|
||||
case DeployMethodTypes::MULTICAST:
|
||||
$data = [
|
||||
'dsk' => (string) $image->getPartitionInfo()['numDisk'],
|
||||
'par' => (string) $image->getPartitionInfo()['numPartition'],
|
||||
'cpt' => "83",
|
||||
'idi' => $image->getUuid(),
|
||||
'nci' => $image->getName(),
|
||||
'ipr' => $image->getRepository()->getIp(),
|
||||
'nfn' => 'CrearImagen',
|
||||
'ids' => '0'
|
||||
];
|
||||
|
||||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $command);
|
||||
$this->createService->__invoke($image->getClient(), $command, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, DeployMethodTypes::MULTICAST);
|
||||
$this->createService->__invoke($image->getClient(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ use App\Entity\Command;
|
|||
use App\Entity\Image;
|
||||
use App\Entity\Trace;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\ImageStatus;
|
||||
use App\Model\TraceStatus;
|
||||
use App\Service\Trace\CreateService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -71,14 +73,15 @@ class CreateImageAction extends AbstractController
|
|||
|
||||
$jobId = json_decode($response->getContent(), true)['job_id'];
|
||||
|
||||
$command = $this->entityManager->getRepository(Command::class)->findOneBy(['name' => 'Crear Imagen']);
|
||||
$image->setStatus(ImageStatus::IN_PROGRESS);
|
||||
$this->entityManager->persist($image);
|
||||
|
||||
$client = $image->getClient();
|
||||
$client->setStatus(ClientStatus::BUSY);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->createService->__invoke($image->getClient(), $command, TraceStatus::IN_PROGRESS, $jobId, []);
|
||||
$this->createService->__invoke($image->getClient(), CommandTypes::CREATE_IMAGE, TraceStatus::IN_PROGRESS, $jobId, []);
|
||||
|
||||
return new JsonResponse(data: $image, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Dto\Input\DeployImageInput;
|
||||
use App\Entity\Client;
|
||||
use App\Entity\Command;
|
||||
use App\Entity\Image;
|
||||
|
@ -34,7 +35,7 @@ class DeployImageAction extends AbstractController
|
|||
}
|
||||
|
||||
|
||||
public function __invoke(Image $image, Command $command, Client $client)
|
||||
public function __invoke(Image $image, DeployImageInput $input, string $method)
|
||||
{
|
||||
if (!$image->getClient()->getIp()) {
|
||||
throw new ValidatorException('IP is required');
|
||||
|
@ -42,6 +43,9 @@ class DeployImageAction extends AbstractController
|
|||
|
||||
$partitionInfo = json_decode($image->getPartitionInfo(), true);
|
||||
|
||||
/** @var Client $client */
|
||||
$client = $input->client->getEntity();
|
||||
|
||||
$data = [
|
||||
'dsk' => (string) $partitionInfo['numDisk'],
|
||||
'par' => (string) $partitionInfo['numPartition'],
|
||||
|
@ -50,7 +54,7 @@ class DeployImageAction extends AbstractController
|
|||
'nci' => $image->getName(),
|
||||
'ipr' => $image->getRepository()->getIp(),
|
||||
'nfn' => 'RestaurarImagen',
|
||||
'ptc' => 'unicast',
|
||||
'ptc' => $method,
|
||||
'ids' => '0'
|
||||
];
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Entity\OperativeSystem;
|
|||
use App\Entity\Partition;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\OgLiveStatus;
|
||||
use App\Service\CreatePartitionService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
|
@ -26,7 +27,8 @@ class StatusAction extends AbstractController
|
|||
{
|
||||
public function __construct(
|
||||
protected readonly EntityManagerInterface $entityManager,
|
||||
protected readonly HttpClientInterface $httpClient
|
||||
protected readonly HttpClientInterface $httpClient,
|
||||
protected readonly CreatePartitionService $createPartitionService
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
@ -41,6 +43,17 @@ class StatusAction extends AbstractController
|
|||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
if ($client->getStatus() === ClientStatus::OG_LIVE) {
|
||||
$this->getOgLiveStatus($client);
|
||||
}
|
||||
|
||||
if ($client->getStatus() === ClientStatus::LINUX) {
|
||||
$this->getSOStatus($client);
|
||||
}
|
||||
}
|
||||
|
||||
public function getOgLiveStatus (Client $client): JsonResponse
|
||||
{
|
||||
try {
|
||||
$response = $this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/ogAdmClient/status', [
|
||||
'verify_peer' => false,
|
||||
|
@ -66,33 +79,43 @@ class StatusAction extends AbstractController
|
|||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
if (isset($data['cfg'])) {
|
||||
foreach ($data['cfg'] as $cfg) {
|
||||
$partitionEntity = $this->entityManager->getRepository(Partition::class)
|
||||
->findOneBy(['client' => $client, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]);
|
||||
$this->createPartitionService->__invoke($data, $client);
|
||||
}
|
||||
|
||||
if (!$partitionEntity) {
|
||||
$partitionEntity = new Partition();
|
||||
}
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
if (isset($cfg['soi']) && $cfg['soi'] !== '') {
|
||||
$operativeSystem = $this->entityManager->getRepository(OperativeSystem::class)
|
||||
->findOneBy(['name' => $cfg['soi']]);
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
if (!$operativeSystem) {
|
||||
$operativeSystem = new OperativeSystem();
|
||||
$operativeSystem->setName($cfg['soi']);
|
||||
$this->entityManager->persist($operativeSystem);
|
||||
}
|
||||
$partitionEntity->setOperativeSystem($operativeSystem);
|
||||
}
|
||||
public function getSOStatus (Client $client): JsonResponse
|
||||
{
|
||||
try {
|
||||
$response = $this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/opengnsys/status', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'timeout' => 10,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'json' => [],
|
||||
]);
|
||||
$statusCode = $response->getStatusCode();
|
||||
$client->setStatus($statusCode === Response::HTTP_OK ? ClientStatus::LINUX : ClientStatus::OFF);
|
||||
|
||||
$partitionEntity->setClient($client);
|
||||
$partitionEntity->setDiskNumber($cfg['disk']);
|
||||
$partitionEntity->setPartitionNumber($cfg['par']);
|
||||
$partitionEntity->setSize($cfg['tam']);
|
||||
$partitionEntity->setMemoryUsage(((int) $cfg['uso']) * 100);
|
||||
$this->entityManager->persist($partitionEntity);
|
||||
}
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
$client->setStatus(ClientStatus::OFF);
|
||||
|
||||
return new JsonResponse(
|
||||
data: ['error' => $e->getMessage()],
|
||||
status: Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
if (isset($data['cfg'])) {
|
||||
$this->createPartitionService->__invoke($data, $client);
|
||||
}
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace App\Controller\OgAgent\Webhook;
|
|||
use App\Entity\Client;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Entity\Partition;
|
||||
use App\Service\CreatePartitionService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
@ -19,7 +20,8 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
class AgentController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
protected readonly EntityManagerInterface $entityManager
|
||||
protected readonly EntityManagerInterface $entityManager,
|
||||
protected readonly CreatePartitionService $createPartitionService
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -42,24 +44,8 @@ class AgentController extends AbstractController
|
|||
return new JsonResponse(['message' => 'Client not found'], Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
foreach ($data['cfg'] as $cfg) {
|
||||
if (isset($cfg['disk']) && isset($cfg['par'])) {
|
||||
$partitionEntity = $this->entityManager->getRepository(Partition::class)
|
||||
->findOneBy(['client' => $clientEntity, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]);
|
||||
|
||||
if (!$partitionEntity) {
|
||||
$partitionEntity = new Partition();
|
||||
}
|
||||
|
||||
$partitionEntity->setClient($clientEntity);
|
||||
$partitionEntity->setDiskNumber((int)$cfg['disk']);
|
||||
$partitionEntity->setPartitionNumber((int) $cfg['par']);
|
||||
$partitionEntity->setSize((int) $cfg['tam'] ?? null);
|
||||
$partitionEntity->setMemoryUsage((int) $cfg['uso'] * 100 ?? null);
|
||||
$partitionEntity->setFileSystem($cfg['fsi'] ?? null);
|
||||
|
||||
$this->entityManager->persist($partitionEntity);
|
||||
}
|
||||
if (isset($data['cfg'])) {
|
||||
$this->createPartitionService->__invoke($data, $clientEntity);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -6,10 +6,14 @@ use App\Controller\OgRepository\Image\CreateAuxFilesAction;
|
|||
use App\Entity\Image;
|
||||
use App\Entity\OperativeSystem;
|
||||
use App\Entity\Partition;
|
||||
use App\Entity\Software;
|
||||
use App\Entity\SoftwareProfile;
|
||||
use App\Entity\Trace;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\ImageStatus;
|
||||
use App\Model\SoftwareTypes;
|
||||
use App\Model\TraceStatus;
|
||||
use App\Service\CreatePartitionService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
@ -28,7 +32,8 @@ class ClientsController extends AbstractController
|
|||
{
|
||||
public function __construct(
|
||||
protected readonly EntityManagerInterface $entityManager,
|
||||
public readonly CreateAuxFilesAction $createAuxFilesAction
|
||||
public readonly CreateAuxFilesAction $createAuxFilesAction,
|
||||
protected readonly CreatePartitionService $createPartitionService
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -55,18 +60,24 @@ class ClientsController extends AbstractController
|
|||
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
|
||||
$image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $data['idi']]);
|
||||
|
||||
if (!$image) {
|
||||
return new JsonResponse(['message' => 'Image not found'], Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
if ($data['res'] === 1) {
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
$image->setStatus(ImageStatus::PENDING);
|
||||
$image->setStatus(ImageStatus::AUX_FILES_PENDING);
|
||||
$image->setCreated(true);
|
||||
if (isset($data['cfg'])) {
|
||||
$this->createPartitionService->__invoke($data, $image->getClient());
|
||||
}
|
||||
$this->createSoftwareProfile($data['inv_sft'], $image);
|
||||
$this->createAuxFilesAction->__invoke($image);
|
||||
|
||||
} else {
|
||||
$trace->setStatus(TraceStatus::FAILED);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
$trace->setOutput($data['der']);
|
||||
|
||||
$image->setCreated(false);
|
||||
}
|
||||
$this->entityManager->persist($image);
|
||||
|
@ -99,4 +110,31 @@ class ClientsController extends AbstractController
|
|||
|
||||
return new JsonResponse([], Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function createSoftwareProfile (string $base64Data, Image $image): void
|
||||
{
|
||||
$decodedData = base64_decode($base64Data);
|
||||
|
||||
$softwareList = explode("\n", $decodedData);
|
||||
|
||||
$softwareProfile = new SoftwareProfile();
|
||||
$softwareProfile->setDescription('Perfil : '.$image->getName());
|
||||
$softwareProfile->setOrganizationalUnit($image->getClient()->getOrganizationalUnit());
|
||||
|
||||
foreach ($softwareList as $software) {
|
||||
$software = trim($software);
|
||||
$softwareEntity = $this->entityManager->getRepository(Software::class)->findOneBy(['name' => $software]);
|
||||
if (!$softwareEntity) {
|
||||
$softwareEntity = new Software();
|
||||
$softwareEntity->setName($software);
|
||||
$softwareEntity->setType(SoftwareTypes::APPLICATION);
|
||||
$this->entityManager->persist($softwareEntity);
|
||||
}
|
||||
|
||||
$softwareEntity->addSoftwareProfile($softwareProfile);
|
||||
}
|
||||
|
||||
$this->entityManager->persist($softwareProfile);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
|
@ -23,6 +23,8 @@ abstract class AbstractOgBootController extends AbstractController
|
|||
public function __construct(
|
||||
#[Autowire(env: 'OG_BOOT_API_URL')]
|
||||
protected string $ogBootApiUrl,
|
||||
#[Autowire(env: 'OG_CORE_IP')]
|
||||
protected string $ogCoreIP,
|
||||
protected readonly EntityManagerInterface $entityManager
|
||||
)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ class GetAction extends AbstractOgBootController
|
|||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class GetCollectionAction extends AbstractOgBootController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives');
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class GetDefaultAction extends AbstractOgBootController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/default');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default');
|
||||
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class GetIsosAction extends AbstractOgBootController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/isos');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/isos');
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class InstallAction extends AbstractOgBootController
|
|||
]
|
||||
];
|
||||
|
||||
$content = $this->createRequest($httpClient, 'POST', $this->ogBootApiUrl.'/ogboot/v1/oglives/install', $params);
|
||||
$content = $this->createRequest($httpClient, 'POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/install', $params);
|
||||
|
||||
$data->setStatus(OgLiveStatus::PENDING);
|
||||
$entityManager->persist($data);
|
||||
|
|
|
@ -36,7 +36,7 @@ class SetDefaultAction extends AbstractOgBootController
|
|||
]
|
||||
];
|
||||
|
||||
$content = $this->createRequest($httpClient, 'PUT', $this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params);
|
||||
$content = $this->createRequest($httpClient, 'PUT', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params);
|
||||
|
||||
$oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class SyncAction extends AbstractOgBootController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl . '/ogboot/v1/oglives');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl . '/ogboot/v1/oglives');
|
||||
|
||||
foreach ($content['message']['installed_ogLives'] as $ogLive) {
|
||||
$ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['checksum' => $ogLive['id']]);
|
||||
|
|
|
@ -31,7 +31,7 @@ class UninstallAction extends AbstractOgBootController
|
|||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest($httpClient, 'DELETE', $this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
|
||||
$content = $this->createRequest($httpClient, 'DELETE', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
|
||||
|
||||
$entityManager->remove($data);
|
||||
$entityManager->flush();
|
||||
|
|
|
@ -27,7 +27,7 @@ class GetAction extends AbstractOgBootController
|
|||
public function __invoke(Client $client, HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
try {
|
||||
$response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/pxes/'.$client->getMac(), [
|
||||
$response = $httpClient->request('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes/'.$client->getMac(), [
|
||||
'headers' => [
|
||||
'accept' => 'application/json',
|
||||
],
|
||||
|
|
|
@ -26,7 +26,7 @@ class GetCollectionAction extends AbstractOgBootController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/pxes');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes');
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -36,19 +36,20 @@ class PostAction extends AbstractOgBootController
|
|||
'mac' => strtolower($client->getMac()),
|
||||
'lang' => 'es_ES.UTF_8',
|
||||
'ip' => $client->getIp(),
|
||||
//'server_ip' => '192.168.2.4', //rootServer (ogCore)
|
||||
'server_ip' => $this->ogBootApiUrl,
|
||||
'router' => $client->getOrganizationalUnit()->getNetworkSettings()->getRouter(),
|
||||
'netmask' => $client->getOrganizationalUnit()->getNetworkSettings() ? $client->getOrganizationalUnit()->getNetworkSettings()->getNetmask() : '255.255.255.0',
|
||||
'computer_name' => $client->getName(),
|
||||
'netiface' => $client->getNetiface(),
|
||||
'group' => $client->getOrganizationalUnit()->getName(),
|
||||
'ogrepo' => $client->getRepository() ? $client->getRepository()->getIp() : '192.168.2.4',
|
||||
//'ogcore' => 'parametro_consola',
|
||||
//'oglive' => '192.168.2.4',
|
||||
'oglog' => '192.168.2.4',
|
||||
//'ogshare' => '192.168.2.4',
|
||||
'ogrepo' => $client->getRepository()->getIp() ,
|
||||
'ogcore' => $this->ogCoreIP,
|
||||
'oglive' => $this->ogBootApiUrl,
|
||||
'oglog' => $client->getOrganizationalUnit()->getNetworkSettings()?->getOgLog(),
|
||||
'ogshare' => $client->getOrganizationalUnit()->getNetworkSettings()?->getOgShare()
|
||||
? $client->getOrganizationalUnit()->getNetworkSettings()?->getOgShare(): $this->ogBootApiUrl,
|
||||
'oglivedir' => $client->getOgLive()->getFilename(),
|
||||
'ogprof' => 'false', // cliente del profesor
|
||||
'ogprof' => 'false',
|
||||
'hardprofile' => $client->getHardwareProfile() ? $client->getHardwareProfile()->getDescription() : 'default',
|
||||
'ogntp' => $client->getOrganizationalUnit()->getNetworkSettings()?->getNtp(), //optional
|
||||
'ogdns' => $client->getOrganizationalUnit()->getNetworkSettings()?->getDns(), //optional
|
||||
|
@ -58,7 +59,7 @@ class PostAction extends AbstractOgBootController
|
|||
];
|
||||
|
||||
try {
|
||||
$response = $httpClient->request('POST', $this->ogBootApiUrl.'/ogboot/v1/pxes', [
|
||||
$response = $httpClient->request('POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes', [
|
||||
'headers' => [
|
||||
'accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
|
|
|
@ -27,7 +27,7 @@ class DeleteAction extends AbstractOgBootController
|
|||
public function __invoke(PxeTemplate $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
try {
|
||||
$response = $httpClient->request('DELETE', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$data->getName(), [
|
||||
$response = $httpClient->request('DELETE', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$data->getName(), [
|
||||
'headers' => [
|
||||
'accept' => 'application/json',
|
||||
],
|
||||
|
|
|
@ -26,7 +26,7 @@ class GetAction extends AbstractOgBootController
|
|||
public function __invoke(PxeTemplate $template, HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
try {
|
||||
$response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$template->getName(), [
|
||||
$response = $httpClient->request('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$template->getName(), [
|
||||
'headers' => [
|
||||
'accept' => 'application/json',
|
||||
],
|
||||
|
|
|
@ -25,7 +25,7 @@ class GetCollectionAction extends AbstractOgBootController
|
|||
public function __invoke(HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
try {
|
||||
$response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [
|
||||
$response = $httpClient->request('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [
|
||||
'headers' => [
|
||||
'accept' => 'application/json',
|
||||
],
|
||||
|
|
|
@ -27,7 +27,7 @@ class PostAction extends AbstractOgBootController
|
|||
public function __invoke(PxeTemplate $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
try {
|
||||
$response = $httpClient->request('POST', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [
|
||||
$response = $httpClient->request('POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [
|
||||
'headers' => [
|
||||
'accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
|
|
|
@ -28,7 +28,7 @@ class SyncAction extends AbstractOgBootController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl . '/ogboot/v1/pxe-templates');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl . '/ogboot/v1/pxe-templates');
|
||||
|
||||
foreach ($content['message'] as $template) {
|
||||
$templateEntity = $this->entityManager->getRepository(PxeTemplate::class)->findOneBy(['name' => $template]);
|
||||
|
|
|
@ -25,7 +25,7 @@ abstract class AbstractOgDhcpController extends AbstractController
|
|||
#[Autowire(env: 'OG_DHCP_API_URL')]
|
||||
protected readonly string $ogDhcpApiUrl,
|
||||
protected readonly EntityManagerInterface $entityManager,
|
||||
protected readonly GetIpAddressAndNetmaskFromCIDRService $getIpAddressAndNetmaskFromCIDRService
|
||||
protected readonly GetIpAddressAndNetmaskFromCIDRService $getIpAddressAndNetmaskFromCIDRService,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class DeleteAction extends AbstractOgDhcpController
|
|||
throw new ValidatorException('Data Id is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest($httpClient, 'DELETE', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId());
|
||||
$content = $this->createRequest($httpClient, 'DELETE', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId());
|
||||
|
||||
$this->entityManager->remove($data);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -42,7 +42,7 @@ class DeleteHostAction extends AbstractOgDhcpController
|
|||
]
|
||||
];
|
||||
|
||||
$content = $this->createRequest($httpClient, 'DELETE', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts', $params);
|
||||
$content = $this->createRequest($httpClient, 'DELETE', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts', $params);
|
||||
|
||||
$data->removeClient($client);
|
||||
$this->entityManager->persist($data);
|
||||
|
|
|
@ -29,7 +29,7 @@ class GetAction extends AbstractOgDhcpController
|
|||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId());
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId());
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class GetCollectionAction extends AbstractOgDhcpController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl . '/ogdhcp/v1/subnets');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl . '/ogdhcp/v1/subnets');
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class GetHostsAction extends AbstractOgDhcpController
|
|||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts');
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class PostAction extends AbstractOgDhcpController
|
|||
]
|
||||
];
|
||||
|
||||
$content = $this->createRequest($httpClient, 'POST', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets' , $params);
|
||||
$content = $this->createRequest($httpClient, 'POST', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets' , $params);
|
||||
|
||||
$data->setServerId($content['message']['id']);
|
||||
$data->setSynchronized(true);
|
||||
|
|
|
@ -44,7 +44,7 @@ class PostHostAction extends AbstractOgDhcpController
|
|||
'json' => $data
|
||||
];
|
||||
|
||||
$content = $this->createRequest($httpClient, 'POST', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getServerId().'/hosts', $params);
|
||||
$content = $this->createRequest($httpClient, 'POST', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getServerId().'/hosts', $params);
|
||||
|
||||
$subnet->addClient($clientEntity);
|
||||
$this->entityManager->persist($subnet);
|
||||
|
|
|
@ -38,7 +38,7 @@ class PutAction extends AbstractOgDhcpController
|
|||
]
|
||||
];
|
||||
|
||||
$content = $this->createRequest($httpClient, 'PUT', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId(), $params);
|
||||
$content = $this->createRequest($httpClient, 'PUT', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId(), $params);
|
||||
|
||||
$this->entityManager->persist($data);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -42,7 +42,7 @@ class PutHostAction extends AbstractOgDhcpController
|
|||
'json' => $data
|
||||
];
|
||||
|
||||
$content = $this->createRequest($httpClient, 'PUT', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getId().'/hosts', $params);
|
||||
$content = $this->createRequest($httpClient, 'PUT', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getId().'/hosts', $params);
|
||||
}
|
||||
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
|
|
|
@ -26,7 +26,7 @@ class SyncAction extends AbstractOgDhcpController
|
|||
*/
|
||||
public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl . '/ogdhcp/v1/subnets');
|
||||
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl . '/ogdhcp/v1/subnets');
|
||||
|
||||
$arraySync = [];
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Controller\OgRepository\Image;
|
|||
use App\Controller\OgRepository\AbstractOgRepositoryController;
|
||||
use App\Entity\Command;
|
||||
use App\Entity\Image;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\ImageStatus;
|
||||
use App\Model\TraceStatus;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -40,14 +41,13 @@ class CreateAuxFilesAction extends AbstractOgRepositoryController
|
|||
];
|
||||
|
||||
$content = $this->createRequest('POST', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/torrentsum', $params);
|
||||
$command = $this->entityManager->getRepository(Command::class)->findOneBy(['name' => 'Crear Imagen']);
|
||||
|
||||
$inputData = [
|
||||
'imageName' => $data->getName(),
|
||||
'imageUuid' => $data->getUuid(),
|
||||
];
|
||||
|
||||
$this->createService->__invoke($data->getClient(), $command, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
||||
$this->createService->__invoke($data->getClient(), CommandTypes::CREATE_IMAGE_AUX_FILE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
||||
|
||||
$data->setStatus(ImageStatus::IN_PROGRESS);
|
||||
$this->entityManager->persist($data);
|
||||
|
|
|
@ -29,7 +29,7 @@ class DeletePermanentAction extends AbstractOgRepositoryController
|
|||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest($httpClient, 'DELETE', 'http://'.$data->getRepository()->getIp().'/ogrepository/v1/images/'.$data->getImageFullsum().'?method=trash');
|
||||
$content = $this->createRequest( 'DELETE', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/'.$data->getImageFullsum().'?method=trash');
|
||||
|
||||
$this->entityManager->remove($data);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -30,7 +30,7 @@ class DeleteTrashAction extends AbstractOgRepositoryController
|
|||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest($httpClient, 'DELETE', 'http://'.$data->getRepository()->getIp().'/ogrepository/v1/images/'.$data->getImageFullsum().'?method=trash');
|
||||
$content = $this->createRequest('DELETE', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/'.$data->getImageFullsum().'?method=trash');
|
||||
|
||||
$data->setStatus(ImageStatus::TRASH);
|
||||
$this->entityManager->persist($data);
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Controller\OgRepository\AbstractOgRepositoryController;
|
|||
use App\Dto\Input\DeployImageInput;
|
||||
use App\Entity\Command;
|
||||
use App\Entity\Image;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\TraceStatus;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -20,7 +21,6 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|||
class DeployImageAction extends AbstractOgRepositoryController
|
||||
{
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
|
@ -29,9 +29,7 @@ class DeployImageAction extends AbstractOgRepositoryController
|
|||
{
|
||||
$client = $input->client;
|
||||
|
||||
$command = $this->entityManager->getRepository(Command::class)->findOneBy(['name' => 'Deploy Imagen']);
|
||||
$this->createService->__invoke($data->getClient(), $command, TraceStatus::IN_PROGRESS, null);
|
||||
|
||||
$this->createService->__invoke($data->getClient(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, null);
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgRepository\Image;
|
||||
|
||||
use App\Controller\OgRepository\AbstractOgRepositoryController;
|
||||
use App\Dto\Input\DeployImageInput;
|
||||
use App\Entity\Image;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\ImageStatus;
|
||||
use App\Model\TraceStatus;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
#[AsController]
|
||||
class RecoverAction extends AbstractOgRepositoryController
|
||||
{
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(Image $data, HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
if (!$data->getImageFullsum()) {
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
'json' => [
|
||||
'ID_img' => $data->getImageFullsum()
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
$content = $this->createRequest('POST', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/trash/images', $params);
|
||||
|
||||
$data->setStatus(ImageStatus::SUCCESS);
|
||||
$this->entityManager->persist($data);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -76,6 +76,12 @@ class NetworkSettingsInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?bool $validation = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $oglog = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $ogshare = null;
|
||||
|
||||
public function __construct(?NetworkSettings $networkSettings = null)
|
||||
{
|
||||
if (!$networkSettings) {
|
||||
|
@ -95,6 +101,8 @@ class NetworkSettingsInput
|
|||
$this->mcastSpeed = $networkSettings->getMcastSpeed();
|
||||
$this->mcastPort = $networkSettings->getMcastPort();
|
||||
$this->mcastMode = $networkSettings->getMcastMode();
|
||||
$this->oglog = $networkSettings->getOglog();
|
||||
$this->ogshare = $networkSettings->getOgshare();
|
||||
|
||||
if ($networkSettings->getMenu()) {
|
||||
$this->menu = new MenuOutput($networkSettings->getMenu());
|
||||
|
@ -130,6 +138,8 @@ class NetworkSettingsInput
|
|||
$networkSettings->setMcastSpeed($this->mcastSpeed);
|
||||
$networkSettings->setMcastPort($this->mcastPort);
|
||||
$networkSettings->setMcastMode($this->mcastMode);
|
||||
$networkSettings->setOglog($this->oglog);
|
||||
$networkSettings->setOgshare($this->ogshare);
|
||||
|
||||
if ($this->menu) {
|
||||
$networkSettings->setMenu($this->menu->getEntity());
|
||||
|
|
|
@ -57,6 +57,12 @@ final class NetworkSettingsOutput extends AbstractOutput
|
|||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?OgLiveOutput $ogLive = null;
|
||||
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $oglog = null;
|
||||
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $ogshare = null;
|
||||
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?bool $validation = null;
|
||||
|
||||
|
@ -83,6 +89,8 @@ final class NetworkSettingsOutput extends AbstractOutput
|
|||
$this->mcastSpeed = $networkSettings->getMcastSpeed();
|
||||
$this->mcastPort = $networkSettings->getMcastPort();
|
||||
$this->mcastMode = $networkSettings->getMcastMode();
|
||||
$this->oglog = $networkSettings->getOglog();
|
||||
$this->ogshare = $networkSettings->getOgshare();
|
||||
|
||||
if ($networkSettings->getMenu()) {
|
||||
$this->menu = new MenuOutput($networkSettings->getMenu());
|
||||
|
|
|
@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
final class TraceOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['trace:read'])]
|
||||
public CommandOutput $command;
|
||||
public ?string $command;
|
||||
|
||||
#[Groups(['trace:read'])]
|
||||
public ClientOutput $client;
|
||||
|
@ -44,7 +44,7 @@ final class TraceOutput extends AbstractOutput
|
|||
{
|
||||
parent::__construct($trace);
|
||||
|
||||
$this->command = new CommandOutput($trace->getCommand());
|
||||
$this->command = $trace->getCommand();
|
||||
$this->client = new ClientOutput($trace->getClient());
|
||||
$this->status = $trace->getStatus();
|
||||
$this->jobId = $trace->getJobId();
|
||||
|
|
|
@ -13,9 +13,8 @@ class Trace extends AbstractEntity
|
|||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Client $client = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'traces')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Command $command = null;
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $command = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $status = null;
|
||||
|
@ -47,12 +46,12 @@ class Trace extends AbstractEntity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getCommand(): ?Command
|
||||
public function getCommand(): ?string
|
||||
{
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
public function setCommand(?Command $command): static
|
||||
public function setCommand(?string $command): static
|
||||
{
|
||||
$this->command = $command;
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
final class CommandTypes
|
||||
{
|
||||
public const string DEPLOY_IMAGE = 'deploy-image';
|
||||
public const string RESTORE_IMAGE = 'restore-image';
|
||||
public const string CREATE_IMAGE = 'create-image';
|
||||
public const string CREATE_IMAGE_AUX_FILE = 'create-image-aux-file';
|
||||
public const string POWER_ON = 'power-on';
|
||||
public const string REBOOT = 'reboot';
|
||||
public const string SHUTDOWN = 'shutdown';
|
||||
public const string LOGIN = 'login';
|
||||
public const string LOGOUT = 'logout';
|
||||
|
||||
private const array COMMAND_TYPES = [
|
||||
self::DEPLOY_IMAGE => 'Deploy Image',
|
||||
self::RESTORE_IMAGE => 'Update Cache',
|
||||
self::CREATE_IMAGE => 'Create Image',
|
||||
self::CREATE_IMAGE_AUX_FILE => 'Crear fichero auxiliar en repositorio',
|
||||
self::POWER_ON => 'Encender',
|
||||
self::REBOOT => 'Reiniciar',
|
||||
self::SHUTDOWN => 'Apagar',
|
||||
self::LOGIN => 'Login',
|
||||
self::LOGOUT => 'Logout',
|
||||
];
|
||||
|
||||
public static function getCommandTypes(): array
|
||||
{
|
||||
return self::COMMAND_TYPES;
|
||||
}
|
||||
|
||||
public static function getCommandType(string $type): ?string
|
||||
{
|
||||
return self::COMMAND_TYPES[$type] ?? null;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ final class ImageStatus
|
|||
{
|
||||
public const string PENDING = 'pending';
|
||||
public const string IN_PROGRESS = 'in-progress';
|
||||
public const string AUX_FILES_PENDING = 'aux-files-pending';
|
||||
public const string SUCCESS = 'success';
|
||||
public const string TRASH = 'trash';
|
||||
public const string FAILED = 'failed';
|
||||
|
@ -13,6 +14,7 @@ final class ImageStatus
|
|||
private const array STATUS = [
|
||||
self::PENDING => 'Pendiente',
|
||||
self::IN_PROGRESS => 'En progreso',
|
||||
self::AUX_FILES_PENDING => 'Archivos auxiliares pendientes',
|
||||
self::TRASH => 'Papelera',
|
||||
self::SUCCESS => 'Completado',
|
||||
self::FAILED => 'Fallido',
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Client;
|
||||
use App\Entity\OperativeSystem;
|
||||
use App\Entity\Partition;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class CreatePartitionService
|
||||
{
|
||||
public function __construct(
|
||||
protected EntityManagerInterface $entityManager
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(array $data, Client $clientEntity): void
|
||||
{
|
||||
foreach ($data['cfg'] as $cfg) {
|
||||
$partitionEntity = $this->entityManager->getRepository(Partition::class)
|
||||
->findOneBy(['client' => $clientEntity, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]);
|
||||
|
||||
if (!$partitionEntity) {
|
||||
$partitionEntity = new Partition();
|
||||
}
|
||||
|
||||
if (isset($cfg['soi']) && $cfg['soi'] !== '') {
|
||||
$operativeSystem = $this->entityManager->getRepository(OperativeSystem::class)
|
||||
->findOneBy(['name' => $cfg['soi']]);
|
||||
|
||||
if (!$operativeSystem) {
|
||||
$operativeSystem = new OperativeSystem();
|
||||
$operativeSystem->setName($cfg['soi']);
|
||||
$this->entityManager->persist($operativeSystem);
|
||||
}
|
||||
$partitionEntity->setOperativeSystem($operativeSystem);
|
||||
}
|
||||
|
||||
$partitionEntity->setClient($clientEntity);
|
||||
$partitionEntity->setDiskNumber($cfg['disk']);
|
||||
$partitionEntity->setPartitionNumber($cfg['par']);
|
||||
$partitionEntity->setSize($cfg['tam']);
|
||||
$partitionEntity->setMemoryUsage(((int) $cfg['uso']) * 100);
|
||||
$this->entityManager->persist($partitionEntity);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
|
@ -15,11 +15,11 @@ readonly class CreateService
|
|||
{
|
||||
}
|
||||
|
||||
public function __invoke(Client $client, Command $command, string $status, ?string $jobId = null, array $input): Trace
|
||||
public function __invoke(Client $client, ?string $command, string $status, string $jobId, ?array $input = []): Trace
|
||||
{
|
||||
$trace = new Trace();
|
||||
$trace->setClient($client);
|
||||
$trace->setCommand($command ?? null);
|
||||
$trace->setCommand($command);
|
||||
$trace->setStatus($status);
|
||||
$trace->setJobId($jobId);
|
||||
$trace->setExecutedAt(new \DateTime());
|
||||
|
|
|
@ -54,12 +54,12 @@ readonly class ImageProcessor implements ProcessorInterface
|
|||
}
|
||||
|
||||
$image = $data->createOrUpdateEntity($entity);
|
||||
$this->validator->validate($image);
|
||||
|
||||
if ($data->source !== 'input') {
|
||||
$response = $this->createImageActionController->__invoke($image);
|
||||
}
|
||||
|
||||
$this->validator->validate($image);
|
||||
$this->imageRepository->save($image);
|
||||
|
||||
return new ImageOutput($image);
|
||||
|
|
|
@ -37,6 +37,7 @@ validators:
|
|||
image:
|
||||
name:
|
||||
not_blank: 'The name should not be blank.'
|
||||
unique: 'The name should be unique.'
|
||||
|
||||
network_settings:
|
||||
ip_address:
|
||||
|
|
|
@ -37,6 +37,7 @@ validators:
|
|||
image:
|
||||
name:
|
||||
not_blank: 'El nombre no debería estar vacío.'
|
||||
unique: 'El nombre debería ser único. Ya existe una imagen con ese nombre.'
|
||||
|
||||
network_settings:
|
||||
ip_address:
|
||||
|
|
Loading…
Reference in New Issue