feat(remotepc): add reboot on unreserve configuration for UDS
ogcore-debian-package/pipeline/head This commit looks good Details
ogcore-debian-package/pipeline/tag This commit looks good Details
testing/ogcore-api/pipeline/head There was a failure building this commit Details

devel 1.11.0
Juan Manuel Bardallo 2026-10-02 13:57:44 +02:00
parent 803ce6568a
commit 6d63ca00df
6 changed files with 87 additions and 1 deletions

View File

@ -1,5 +1,10 @@
# Changelog
## [1.11.0] - 2026-10-02
### Added
- **RemotePC**: Añadida la propiedad `remotePcRebootOnUnreserve` a la entidad `OrganizationalUnit` para permitir configurar si un equipo remoto debe ser reiniciado en lugar de apagado cuando UDS libera su reserva.
## [1.10.0] - 2026-09-23
### Added

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 Version20261002135500 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add remotePcRebootOnUnreserve property to OrganizationalUnit';
}
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 remote_pc_reboot_on_unreserve TINYINT(1) NOT NULL DEFAULT 0');
}
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 remote_pc_reboot_on_unreserve');
}
}

View File

@ -183,7 +183,11 @@ class RemotePcController extends AbstractController
->setParameter('status', TraceStatus::PENDING)
->execute();
$this->sendPowerOff($client);
if ($client->getOrganizationalUnit() && $client->getOrganizationalUnit()->isRemotePcRebootOnUnreserve()) {
$this->sendReboot($client);
} else {
$this->sendPowerOff($client);
}
$this->logger->info('RemotePC: client unreserved', ['client_id' => $client->getId()]);
@ -375,6 +379,20 @@ class RemotePcController extends AbstractController
}
}
private function sendReboot(Client $client): void
{
try {
$this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/opengnsys/Reiniciar', [
'verify_host' => false,
'timeout' => 2.0,
'headers' => ['Authorization' => $client->getToken()],
])->getStatusCode();
$this->logger->info('RemotePC: reboot sent', ['ip' => $client->getIp()]);
} catch (TransportExceptionInterface | HttpExceptionInterface $e) {
$this->logger->warning('RemotePC: reboot failed', ['client_id' => $client->getId(), 'error' => $e->getMessage()]);
}
}
private function createQueueEntry(Client $client, \DateTimeInterface $execTime, string $operation): void
{
$entry = new AgentQueue();

View File

@ -102,6 +102,13 @@ class OrganizationalUnitInput
)]
public ?bool $remotePc = false;
#[Groups(['organizational-unit:write'])]
#[ApiProperty(
description: 'Indica si RemotePC debe reiniciar el equipo al liberar la reserva',
example: false
)]
public ?bool $remotePcRebootOnUnreserve = false;
#[Groups(['organizational-unit:write'])]
#[ApiProperty(
description: 'Si excluir cambios del padre',
@ -128,6 +135,7 @@ class OrganizationalUnitInput
$this->comments = $organizationalUnit->getComments();
$this->type = $organizationalUnit->getType();
$this->remotePc = $organizationalUnit->isRemotePc();
$this->remotePcRebootOnUnreserve = $organizationalUnit->isRemotePcRebootOnUnreserve();
if ($organizationalUnit->getNetworkSettings()){
$this->networkSettings = new NetworkSettingsInput($organizationalUnit->getNetworkSettings());
}
@ -155,6 +163,7 @@ class OrganizationalUnitInput
$organizationalUnit->setComments($this->comments);
$organizationalUnit->setType($this->type);
$organizationalUnit->setRemotePc($this->remotePc);
$organizationalUnit->setRemotePcRebootOnUnreserve($this->remotePcRebootOnUnreserve ?? false);
$organizationalUnit->setExcludeParentChanges($this->excludeParentChanges);
if ($this->networkSettings){

View File

@ -109,6 +109,13 @@ final class OrganizationalUnitOutput extends AbstractOutput
)]
public ?bool $remotePc = null;
#[Groups(['organizational-unit:read'])]
#[ApiProperty(
description: 'Indica si RemotePC debe reiniciar el equipo al liberar la reserva',
example: false
)]
public ?bool $remotePcRebootOnUnreserve = null;
#[Groups(['organizational-unit:read'])]
#[ApiProperty(
description: 'Indica si está disponible según el calendario',
@ -150,6 +157,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
$this->capacity = $organizationalUnit->getCapacity();
$this->type = $organizationalUnit->getType();
$this->remotePc = $organizationalUnit->isRemotePc();
$this->remotePcRebootOnUnreserve = $organizationalUnit->isRemotePcRebootOnUnreserve();
$this->available = $organizationalUnit->getRemoteCalendar() && $organizationalUnit->getRemoteCalendar()->isAvailable();
$this->networkSettings = $organizationalUnit->getNetworkSettings() ? new NetworkSettingsOutput($organizationalUnit->getNetworkSettings()) : null;
$this->remoteCalendar = $organizationalUnit->getRemoteCalendar() ? new RemoteCalendarOutput($organizationalUnit->getRemoteCalendar()) : null;

View File

@ -89,6 +89,9 @@ class OrganizationalUnit extends AbstractEntity
#[ORM\Column]
private ?bool $remotePc = false;
#[ORM\Column]
private ?bool $remotePcRebootOnUnreserve = false;
#[ORM\Column]
private ?bool $reserved = false;
@ -404,6 +407,18 @@ class OrganizationalUnit extends AbstractEntity
return $this;
}
public function isRemotePcRebootOnUnreserve(): ?bool
{
return $this->remotePcRebootOnUnreserve;
}
public function setRemotePcRebootOnUnreserve(bool $remotePcRebootOnUnreserve): static
{
$this->remotePcRebootOnUnreserve = $remotePcRebootOnUnreserve;
return $this;
}
public function isReserved(): ?bool
{
return $this->reserved;