From 809ecd0d37acd066eb455873edb2cbada69f9996 Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Fri, 31 Jul 2026 13:36:04 +0200 Subject: [PATCH] feat(inventory): add disk_type to partition and net_speed to client --- migrations/Version20260731113500.php | 33 ++++++++++++++++++++++++++ src/Dto/Output/ClientOutput.php | 8 +++++++ src/Dto/Output/PartitionOutput.php | 8 +++++++ src/Entity/Client.php | 15 ++++++++++++ src/Entity/Partition.php | 15 ++++++++++++ src/Service/CreatePartitionService.php | 13 ++++++++++ 6 files changed, 92 insertions(+) create mode 100644 migrations/Version20260731113500.php diff --git a/migrations/Version20260731113500.php b/migrations/Version20260731113500.php new file mode 100644 index 0000000..76cf1cd --- /dev/null +++ b/migrations/Version20260731113500.php @@ -0,0 +1,33 @@ +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'); + } +} diff --git a/src/Dto/Output/ClientOutput.php b/src/Dto/Output/ClientOutput.php index bdf707f..e250cf9 100644 --- a/src/Dto/Output/ClientOutput.php +++ b/src/Dto/Output/ClientOutput.php @@ -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()) { diff --git a/src/Dto/Output/PartitionOutput.php b/src/Dto/Output/PartitionOutput.php index 0063ba6..9479373 100644 --- a/src/Dto/Output/PartitionOutput.php +++ b/src/Dto/Output/PartitionOutput.php @@ -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 ; diff --git a/src/Entity/Client.php b/src/Entity/Client.php index 4f039ab..5761e05 100644 --- a/src/Entity/Client.php +++ b/src/Entity/Client.php @@ -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; diff --git a/src/Entity/Partition.php b/src/Entity/Partition.php index 6574b15..a2919b0 100644 --- a/src/Entity/Partition.php +++ b/src/Entity/Partition.php @@ -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; diff --git a/src/Service/CreatePartitionService.php b/src/Service/CreatePartitionService.php index 9e16482..81bed55 100644 --- a/src/Service/CreatePartitionService.php +++ b/src/Service/CreatePartitionService.php @@ -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']];