Compare commits

...

3 Commits

10 changed files with 101 additions and 8 deletions

View File

@ -45,6 +45,52 @@ services:
arguments: [ { 'enabled': ~, 'readOnly': ~ } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task_schedule.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task_schedule.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', 'commandTask.id': 'exact' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task_schedule.boolean:
parent: 'api_platform.doctrine.orm.boolean_filter'
arguments: [ { 'enabled': ~} ]
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task_script.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task_script.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', 'commandTask.id': 'exact' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.command_task_script.boolean:
parent: 'api_platform.doctrine.orm.boolean_filter'
arguments: [ { 'enabled': ~ } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.hardware.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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'])]

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -82,6 +82,7 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
$client->setOgLive($networkSettings->getOgLive());
$client->setMenu($networkSettings->getMenu());
$client->setRepository($networkSettings->getRepository());
$client->setTemplate($networkSettings->getPxeTemplate());
$this->entityManager->persist($client);
}
@ -116,6 +117,7 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
$newNetworkSettings->setMenu($organizationalUnitEntity->getNetworkSettings()->getMenu());
$newNetworkSettings->setRepository($organizationalUnitEntity->getNetworkSettings()->getRepository());
$newNetworkSettings->setOgLive($organizationalUnitEntity->getNetworkSettings()->getOgLive());
$newNetworkSettings->setPxeTemplate($organizationalUnitEntity->getNetworkSettings()->getPxeTemplate());
$newNetworkSettings->setNetiface($organizationalUnitEntity->getNetworkSettings()->getNetiface());
return $newNetworkSettings;

View File

@ -21,8 +21,9 @@ readonly class CreateTraceService
foreach ($commandTask->getClients() as $client) {
$trace = new Trace();
$trace->setClient($client);
$trace->setCommand($command);
$trace->setCommand($command->getName());
$trace->setStatus(TraceStatus::PENDING);
$trace->setInput($commandTask->getParameters());
$trace->setExecutedAt($commandTask->getDatetime());
$this->entityManager->persist($trace);
}
@ -33,7 +34,8 @@ readonly class CreateTraceService
foreach ($commandTask->getClients() as $client) {
$trace = new Trace();
$trace->setClient($client);
$trace->setCommand($command);
$trace->setCommand($command->getName());
$trace->setInput($commandTask->getParameters());
$trace->setStatus(TraceStatus::PENDING);
$trace->setExecutedAt($commandTask->getDatetime());
$this->entityManager->persist($trace);