refs #1943. Added PXE template to NetworkSettings
parent
68a2e4f205
commit
e48917181f
|
@ -165,6 +165,7 @@ final class ClientInput
|
|||
$ogLive = $this->ogLive?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getOgLive();
|
||||
$hardwareProfile = $this->hardwareProfile?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getHardwareProfile();
|
||||
$repository = $this->repository?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getRepository();
|
||||
$template = $this->template?->getEntity() ?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getPxeTemplate();
|
||||
|
||||
$client->setName($this->name);
|
||||
$client->setSerialNumber($this->serialNumber);
|
||||
|
@ -177,7 +178,7 @@ final class ClientInput
|
|||
$client->setOgLive($ogLive);
|
||||
$client->setHardwareProfile($hardwareProfile);
|
||||
$client->setRepository($repository);
|
||||
$client->setTemplate($this->template?->getEntity());
|
||||
$client->setTemplate($template);
|
||||
$client->setPosition($this->position);
|
||||
$client->setStatus($this->status);
|
||||
$client->setMaintenance($this->maintenance);
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Dto\Output\HardwareProfileOutput;
|
|||
use App\Dto\Output\ImageRepositoryOutput;
|
||||
use App\Dto\Output\MenuOutput;
|
||||
use App\Dto\Output\OgLiveOutput;
|
||||
use App\Dto\Output\PxeTemplateOutput;
|
||||
use App\Entity\HardwareProfile;
|
||||
use App\Entity\Menu;
|
||||
use App\Entity\NetworkSettings;
|
||||
|
@ -80,6 +81,9 @@ class NetworkSettingsInput
|
|||
#[Groups(['organizational-unit:write'])]
|
||||
public ?ImageRepositoryOutput $repository = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?PxeTemplateOutput $pxeTemplate = null;
|
||||
|
||||
#[Groups(['organizational-unit:write'])]
|
||||
public ?string $ogshare = null;
|
||||
|
||||
|
@ -120,6 +124,10 @@ class NetworkSettingsInput
|
|||
if ($networkSettings->getRepository()) {
|
||||
$this->repository = new ImageRepositoryOutput($networkSettings->getRepository());
|
||||
}
|
||||
|
||||
if ($networkSettings->getPxeTemplate()) {
|
||||
$this->pxeTemplate = new PxeTemplateOutput($networkSettings->getPxeTemplate());
|
||||
}
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?NetworkSettings $networkSettings = null): NetworkSettings
|
||||
|
@ -160,6 +168,10 @@ class NetworkSettingsInput
|
|||
$networkSettings->setRepository($this->repository->getEntity());
|
||||
}
|
||||
|
||||
if ($this->pxeTemplate) {
|
||||
$networkSettings->setPxeTemplate($this->pxeTemplate->getEntity());
|
||||
}
|
||||
|
||||
return $networkSettings;
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ final class ClientOutput extends AbstractOutput
|
|||
|
||||
#[Groups(['client:read', 'organizational-unit:read', 'pxe-template:read', 'trace:read', 'subnet:read'])]
|
||||
#[ApiProperty(readableLink: true )]
|
||||
public ?PxeTemplateOutput $template = null;
|
||||
public ?PxeTemplateOutput $pxeTemplate = null;
|
||||
|
||||
#[Groups(['client:read', 'organizational-unit:read', 'pxe-template:read', 'trace:read', 'subnet:read'])]
|
||||
#[ApiProperty(readableLink: true )]
|
||||
|
@ -106,7 +106,6 @@ final class ClientOutput extends AbstractOutput
|
|||
|
||||
$this->menu = $client->getMenu() ? new MenuOutput($client->getMenu()) : null;
|
||||
$this->position = $client->getPosition();
|
||||
$this->template = $client->getTemplate() ? new PxeTemplateOutput($client->getTemplate()) : null;
|
||||
|
||||
$repository = $client->getRepository()
|
||||
?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getRepository();
|
||||
|
@ -118,6 +117,11 @@ final class ClientOutput extends AbstractOutput
|
|||
|
||||
$this->ogLive = $ogLive ? new OgLiveOutput($ogLive) : null;
|
||||
|
||||
$template = $client->getTemplate()
|
||||
?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getPxeTemplate();
|
||||
|
||||
$this->pxeTemplate = $template ? new PxeTemplateOutput($template) : null;
|
||||
|
||||
$this->hardwareProfile = $client->getHardwareProfile() ? new HardwareProfileOutput($client->getHardwareProfile()) : null;
|
||||
$this->subnet = $client->getSubnet()?->getIpAddress();
|
||||
$this->status = $client->getStatus();
|
||||
|
|
|
@ -63,6 +63,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 ?PxeTemplateOutput $pxeTemplate = null;
|
||||
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $ogshare = null;
|
||||
|
||||
|
@ -108,6 +111,10 @@ final class NetworkSettingsOutput extends AbstractOutput
|
|||
$this->repository = new ImageRepositoryOutput($networkSettings->getRepository());
|
||||
}
|
||||
|
||||
if ($networkSettings->getPxeTemplate()) {
|
||||
$this->pxeTemplate = new PxeTemplateOutput($networkSettings->getPxeTemplate());
|
||||
}
|
||||
|
||||
$this->createdAt = $networkSettings->getCreatedAt();
|
||||
$this->createdBy = $networkSettings->getCreatedBy();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
#[Get(shortName: 'OrganizationalUnit')]
|
||||
final class OrganizationalUnitOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['organizational-unit:read', "client:read", "user:read", 'organizational-unit:read:collection:short', 'software-profile:read'])]
|
||||
#[Groups(['organizational-unit:read', "client:read", "user:read", 'organizational-unit:read:collection:short', 'software-profile:read', 'command-task:read'])]
|
||||
public string $name;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
|
|
|
@ -76,6 +76,9 @@ class NetworkSettings extends AbstractEntity
|
|||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $ogShare = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?PxeTemplate $pxeTemplate = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -337,4 +340,16 @@ class NetworkSettings extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPxeTemplate(): ?PxeTemplate
|
||||
{
|
||||
return $this->pxeTemplate;
|
||||
}
|
||||
|
||||
public function setPxeTemplate(?PxeTemplate $pxeTemplate): static
|
||||
{
|
||||
$this->pxeTemplate = $pxeTemplate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,10 +49,14 @@ final readonly class ClientSubscriber implements EventSubscriberInterface
|
|||
/** @var Client $client */
|
||||
$client = $clientOutput->getEntity();
|
||||
|
||||
if ($client->getTemplate() === null) {
|
||||
$template = !$client->getTemplate() ?
|
||||
$client->getTemplate() :
|
||||
$client->getOrganizationalUnit()?->getNetworkSettings()?->getPxeTemplate();
|
||||
|
||||
if ($template === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->postAction->__invoke($client, $client->getTemplate());
|
||||
$this->postAction->__invoke($client, $template);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue