refs #1523. Hierarchy networkSettings
testing/ogcore-api/pipeline/head This commit looks good Details

hotfix-timeout
Manuel Aranda Rosales 2025-02-17 13:11:49 +01:00
parent ca3e547b56
commit 546546bb42
13 changed files with 159 additions and 54 deletions

View File

@ -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 Version20250217095913 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 organizational_unit ADD exclude_parent_changes TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organizational_unit DROP exclude_parent_changes');
}
}

View File

@ -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 Version20250217115241 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 ADD progress INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE trace DROP progress');
}
}

View File

@ -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 Version20250217120940 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 network_settings DROP validation, DROP og_log');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE network_settings ADD validation TINYINT(1) DEFAULT NULL, ADD og_log VARCHAR(255) DEFAULT NULL');
}
}

View File

@ -161,6 +161,11 @@ final class ClientInput
$client = new Client();
}
$menu = $this->menu?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getMenu();
$ogLive = $this->ogLive?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getOgLive();
$hardwareProfile = $this->hardwareProfile?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getHardwareProfile();
$repository = $this->repository?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getRepository();
$client->setName($this->name);
$client->setSerialNumber($this->serialNumber);
$client->setNetiface($this->netiface);
@ -168,10 +173,10 @@ final class ClientInput
$client->setNetDriver($this->netDriver);
$client->setMac($this->mac);
$client->setIp($this->ip);
$client->setMenu($this->menu?->getEntity());
$client->setOgLive($this->ogLive?->getEntity());
$client->setHardwareProfile($this->hardwareProfile?->getEntity());
$client->setRepository($this->repository?->getEntity());
$client->setMenu($menu);
$client->setOgLive($ogLive);
$client->setHardwareProfile($hardwareProfile);
$client->setRepository($repository);
$client->setTemplate($this->template?->getEntity());
$client->setPosition($this->position);
$client->setStatus($this->status);

View File

@ -77,12 +77,6 @@ class NetworkSettingsInput
#[Groups(['organizational-unit:write'])]
public ?ImageRepositoryOutput $repository = null;
#[Groups(['organizational-unit:write'])]
public ?bool $validation = null;
#[Groups(['organizational-unit:write'])]
public ?string $oglog = null;
#[Groups(['organizational-unit:write'])]
public ?string $ogshare = null;
@ -146,7 +140,6 @@ 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) {
@ -165,8 +158,6 @@ class NetworkSettingsInput
$networkSettings->setRepository($this->repository->getEntity());
}
$networkSettings->setValidation($this->validation);
return $networkSettings;
}
}

View File

@ -57,6 +57,9 @@ class OrganizationalUnitInput
#[Groups(['organizational-unit:write'])]
public ?bool $remotePc = false;
#[Groups(['organizational-unit:write'])]
public ?bool $excludeParentChanges = null;
public function __construct(?OrganizationalUnit $organizationalUnit = null)
{
if (!$organizationalUnit) {
@ -102,6 +105,7 @@ class OrganizationalUnitInput
$organizationalUnit->setComments($this->comments);
$organizationalUnit->setType($this->type);
$organizationalUnit->setRemotePc($this->remotePc);
$organizationalUnit->setExcludeParentChanges($this->excludeParentChanges);
if ($this->networkSettings){
$organizationalUnit->setNetworkSettings($this->networkSettings->createOrUpdateEntity($organizationalUnit->getNetworkSettings()));

View File

@ -60,15 +60,9 @@ final class NetworkSettingsOutput extends AbstractOutput
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
public ?ImageRepositoryOutput $repository = 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;
#[Groups(['organizational-unit:read'])]
public \DateTime $createdAt;
@ -92,7 +86,6 @@ 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()) {
@ -111,7 +104,6 @@ final class NetworkSettingsOutput extends AbstractOutput
$this->repository = new ImageRepositoryOutput($networkSettings->getRepository());
}
$this->validation = $networkSettings->getValidation();
$this->createdAt = $networkSettings->getCreatedAt();
$this->createdBy = $networkSettings->getCreatedBy();
}

View File

@ -61,6 +61,9 @@ final class OrganizationalUnitOutput extends AbstractOutput
#[Groups(['organizational-unit:read'])]
public ?bool $available = null;
#[Groups(['organizational-unit:read'])]
public ?bool $excludeParentChanges = null;
#[Groups(['organizational-unit:read'])]
public \DateTime $createdAt;
@ -99,6 +102,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
)->toArray();
}
$this->excludeParentChanges = $organizationalUnit->isExcludeParentChanges();
$this->path = $organizationalUnit->getPath();
$this->createdAt = $organizationalUnit->getCreatedAt();
$this->createdBy = $organizationalUnit->getCreatedBy();

View File

@ -34,6 +34,9 @@ final class TraceOutput extends AbstractOutput
#[Groups(['trace:read'])]
public ?\DateTimeInterface $finishedAt = null;
#[Groups(['trace:read'])]
public ?int $progress = null;
#[Groups(['trace:read'])]
public \DateTime $createdAt;
@ -56,6 +59,7 @@ final class TraceOutput extends AbstractOutput
$this->output = $trace->getOutput();
$this->input = $trace->getInput();
$this->finishedAt = $trace->getFinishedAt();
$this->progress = $trace->getProgress();
$this->createdAt = $trace->getCreatedAt();
$this->createdBy = $trace->getCreatedBy();
}

View File

@ -63,9 +63,6 @@ class NetworkSettings extends AbstractEntity
#[ORM\JoinColumn(nullable: true)]
private ?HardwareProfile $hardwareProfile = null;
#[ORM\Column(nullable: true)]
private ?bool $validation = null;
#[ORM\ManyToOne]
private ?ImageRepository $repository = null;
@ -73,9 +70,6 @@ class NetworkSettings extends AbstractEntity
#[ORM\JoinColumn( onDelete: 'SET NULL')]
private ?OgLive $ogLive = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $ogLog = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $ogShare = null;
@ -293,18 +287,6 @@ class NetworkSettings extends AbstractEntity
return $this;
}
public function getValidation(): ?bool
{
return $this->validation;
}
public function setValidation(?bool $validation): static
{
$this->validation = $validation;
return $this;
}
public function getRepository(): ?ImageRepository
{
return $this->repository;
@ -329,18 +311,6 @@ class NetworkSettings extends AbstractEntity
return $this;
}
public function getOgLog(): ?string
{
return $this->ogLog;
}
public function setOgLog(?string $ogLog): static
{
$this->ogLog = $ogLog;
return $this;
}
public function getOgShare(): ?string
{
return $this->ogShare;

View File

@ -97,6 +97,9 @@ class OrganizationalUnit extends AbstractEntity
#[ORM\Column]
private ?bool $reserved = false;
#[ORM\Column(nullable: true)]
private ?bool $excludeParentChanges = null;
public function __construct()
{
parent::__construct();
@ -429,4 +432,16 @@ class OrganizationalUnit extends AbstractEntity
return $this;
}
public function isExcludeParentChanges(): ?bool
{
return $this->excludeParentChanges ?? false;
}
public function setExcludeParentChanges(?bool $excludeParentChanges): static
{
$this->excludeParentChanges = $excludeParentChanges;
return $this;
}
}

View File

@ -34,6 +34,9 @@ class Trace extends AbstractEntity
#[ORM\Column(type: "json", nullable: true)]
private ?array $input = null;
#[ORM\Column(nullable: true)]
private ?int $progress = null;
public function getClient(): ?Client
{
return $this->client;
@ -129,4 +132,16 @@ class Trace extends AbstractEntity
return $this;
}
public function getProgress(): ?int
{
return $this->progress;
}
public function setProgress(?int $progress): static
{
$this->progress = $progress;
return $this;
}
}

View File

@ -42,7 +42,7 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
/** @var OrganizationalUnit $organizationalUnitEntity */
$organizationalUnitEntity = $organizationalUnitOutput->getEntity();
if ($organizationalUnitEntity->getNetworkSettings() === null) {
if ($organizationalUnitEntity->getNetworkSettings() === null || $organizationalUnitEntity->isExcludeParentChanges()) {
return;
}
@ -56,8 +56,15 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
private function updateChildrenNetworkSettings(OrganizationalUnit $parentUnit, NetworkSettings $networkSettings): void
{
/** @var OrganizationalUnit $childUnit */
foreach ($parentUnit->getOrganizationalUnits() as $childUnit) {
$childUnit->setNetworkSettings($networkSettings);
//var_dump($childUnit->getNetworkSettings()->getMcastPort());
if ($childUnit->isExcludeParentChanges()) {
$childUnit->setNetworkSettings(null);
} else{
$childUnit->setNetworkSettings($networkSettings);
}
$this->entityManager->persist($childUnit);
$this->updateChildrenNetworkSettings($childUnit, $networkSettings);
@ -66,7 +73,12 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
private function buildNetworkSettings($organizationalUnitEntity): NetworkSettings
{
$newNetworkSettings = new NetworkSettings();
if ($organizationalUnitEntity->getNetworkSettings() === null) {
$newNetworkSettings = new NetworkSettings();
} else {
$newNetworkSettings = $organizationalUnitEntity->getNetworkSettings();
}
$newNetworkSettings->setNextServer($organizationalUnitEntity->getNetworkSettings()->getNextServer());
$newNetworkSettings->setBootFileName($organizationalUnitEntity->getNetworkSettings()->getBootFileName());
$newNetworkSettings->setProxy($organizationalUnitEntity->getNetworkSettings()->getProxy());