Merge pull request 'devel 1.9.4 Se guarda informacion del tipo de disco y de la velocidad de red de cada cliente' (#127) from devel into main
ogcore-debian-package/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/head There was a failure building this commit Details
ogcore-debian-package/pipeline/tag This commit looks good Details

Reviewed-on: #127
pull/128/head 1.9.4
Juan Manuel Bardallo 2026-09-01 09:42:27 +02:00
commit 3ab24ee3ef
7 changed files with 106 additions and 2 deletions

View File

@ -1,5 +1,10 @@
# Changelog
## [1.9.4] - 2026-07-31
### Added
- Inventario Hardware: Añadida captura y persistencia del tipo de disco (`diskType` en la entidad `Partition`) y de la velocidad de red (`netSpeed` en la entidad `Client`). Estos campos ahora se exponen a través de la API REST para su visualización en el frontend.
## [1.9.3] - 2026-07-31
### Fixed

View File

@ -0,0 +1,33 @@
<?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 Version20260731113500 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add diskType to partition and netSpeed to client';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client ADD net_speed INT DEFAULT NULL');
$this->addSql('ALTER TABLE `partition` ADD disk_type VARCHAR(50) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `partition` DROP disk_type');
$this->addSql('ALTER TABLE client DROP net_speed');
}
}

View File

@ -71,6 +71,13 @@ final class ClientOutput extends AbstractOutput
)]
public ?string $netDriver = '';
#[Groups(['client:read'])]
#[ApiProperty(
description: 'La velocidad de la red',
example: 1000
)]
public ?int $netSpeed = null;
#[Groups(['client:read'])]
#[ApiProperty(
description: 'La unidad organizativa a la que pertenece el cliente',
@ -207,6 +214,7 @@ final class ClientOutput extends AbstractOutput
$this->ip = $client->getIp();
$this->netiface = $client->getNetiface();
$this->netDriver = $client->getNetDriver();
$this->netSpeed = $client->getNetSpeed();
$this->firmwareType = $client->getFirmwareType();
if ($client->getOrganizationalUnit()) {

View File

@ -17,6 +17,13 @@ class PartitionOutput extends AbstractOutput
example: 1
)]
public ?int $diskNumber = null;
#[Groups(['partition:read', 'client:read'])]
#[ApiProperty(
description: 'El tipo de disco',
example: 'NVMe'
)]
public ?string $diskType = null;
#[Groups(['partition:read', 'client:read'])]
#[ApiProperty(
@ -86,6 +93,7 @@ class PartitionOutput extends AbstractOutput
parent::__construct($partition);
$this->diskNumber = $partition->getDiskNumber();
$this->diskType = $partition->getDiskType();
$this->partitionNumber = $partition->getPartitionNumber();
$this->partitionCode = $partition->getPartitionCode();
$this->size = $partition->getSize() / 1024 ;

View File

@ -58,6 +58,9 @@ class Client extends AbstractEntity
#[ORM\JoinColumn(onDelete: 'SET NULL')]
private ?HardwareProfile $hardwareProfile = null;
#[ORM\Column(nullable: true)]
private ?int $netSpeed = null;
#[ORM\Column(nullable: true)]
private ?bool $validation = null;
@ -253,6 +256,18 @@ class Client extends AbstractEntity
return $this;
}
public function getNetSpeed(): ?int
{
return $this->netSpeed;
}
public function setNetSpeed(?int $netSpeed): static
{
$this->netSpeed = $netSpeed;
return $this;
}
public function getValidation(): ?bool
{
return $this->validation;

View File

@ -13,6 +13,9 @@ class Partition extends AbstractEntity
#[ORM\Column(nullable: true)]
private ?int $diskNumber = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $diskType = null;
#[ORM\Column(nullable: true)]
private ?int $partitionNumber = null;
@ -58,6 +61,18 @@ class Partition extends AbstractEntity
return $this;
}
public function getDiskType(): ?string
{
return $this->diskType;
}
public function setDiskType(?string $diskType): static
{
$this->diskType = $diskType;
return $this;
}
public function getDiskNumber(): ?int
{
return $this->diskNumber;

View File

@ -30,14 +30,29 @@ class CreatePartitionService
return isset($cfg['disk'], $cfg['par'], $cfg['tam'], $cfg['uso'], $cfg['fsi']);
});
$fwtFound = false;
$spdFound = false;
foreach ($data['cfg'] as $cfg) {
if (!empty($cfg['fwt'])) {
if (!$fwtFound && !empty($cfg['fwt'])) {
$clientEntity->setFirmwareType($cfg['fwt']);
$this->entityManager->persist($clientEntity);
$fwtFound = true;
}
if (!$spdFound && !empty($cfg['spd'])) {
$clientEntity->setNetSpeed((int) $cfg['spd']);
$spdFound = true;
}
if ($fwtFound && $spdFound) {
break;
}
}
if ($fwtFound || $spdFound) {
$this->entityManager->persist($clientEntity);
}
foreach ($filteredCfg as $cfg) {
$partitionEntity = $this->entityManager->getRepository(Partition::class)
->findOneBy(['client' => $clientEntity, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]);
@ -113,6 +128,11 @@ class CreatePartitionService
$partitionEntity->setFilesystem($cfg['fsi']);
$partitionEntity->setMemoryUsage(((int) $cfg['uso']) * 100);
$partitionEntity->setCacheContent($cfg['cac'] ?? null);
if (isset($cfg['dty']) && $cfg['dty'] !== '') {
$partitionEntity->setDiskType($cfg['dty']);
}
$this->entityManager->persist($partitionEntity);
$receivedPartitions[] = ['disk' => $cfg['disk'], 'partition' => $cfg['par']];