feat(inventory): add disk_type to partition and net_speed to client
ogcore-debian-package/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/head There was a failure building this commit Details

pull/127/head
Juan Manuel Bardallo 2026-07-31 13:36:04 +02:00
parent 4a7034798f
commit 809ecd0d37
6 changed files with 92 additions and 0 deletions

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

@ -37,6 +37,14 @@ class CreatePartitionService
break;
}
}
foreach ($data['cfg'] as $cfg) {
if (!empty($cfg['spd'])) {
$clientEntity->setNetSpeed((int) $cfg['spd']);
$this->entityManager->persist($clientEntity);
break;
}
}
foreach ($filteredCfg as $cfg) {
$partitionEntity = $this->entityManager->getRepository(Partition::class)
@ -113,6 +121,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']];