Updated rempte Pc sync
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
parent
279e65e92b
commit
7a9e133a92
|
|
@ -182,6 +182,13 @@ final class ClientOutput extends AbstractOutput
|
|||
)]
|
||||
public ?BootServerOutput $bootServer = null;
|
||||
|
||||
#[Groups(['client:read', 'organizational-unit:read'])]
|
||||
#[ApiProperty(
|
||||
description: 'Indica si el cliente tiene una reserva activa de RemotePC (UDS)',
|
||||
example: false
|
||||
)]
|
||||
public bool $isRemotePcActive = false;
|
||||
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
parent::__construct($client);
|
||||
|
|
@ -236,6 +243,8 @@ final class ClientOutput extends AbstractOutput
|
|||
if ($client->getBootServer()) {
|
||||
$this->bootServer = new BootServerOutput($client->getBootServer());
|
||||
}
|
||||
|
||||
$this->isRemotePcActive = (bool) $client->getRemotePC()?->isReservedActive();
|
||||
}
|
||||
|
||||
public function convertMaskToCIDR($mask): int
|
||||
|
|
|
|||
|
|
@ -25,49 +25,13 @@ class UdsSyncOnClientStatusListener
|
|||
|
||||
public function preUpdate(PreUpdateEventArgs $args): void
|
||||
{
|
||||
$entity = $args->getObject();
|
||||
|
||||
if (!$entity instanceof Client) {
|
||||
return;
|
||||
}
|
||||
|
||||
$changeSet = $args->getObjectManager()->getUnitOfWork()->getEntityChangeSet($entity);
|
||||
|
||||
if (!array_key_exists('status', $changeSet)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't sync while the machine has an active RemotePC reservation.
|
||||
// Any status change during a reservation (INITIALIZING, OG_LIVE via InclusionCliente,
|
||||
// WINDOWS after boot, etc.) would compute max_srvs=0/visible=false and cause UDS
|
||||
// to cancel the active session with an unreserve call.
|
||||
// The sync will fire again after unreserve clears the reservation (reservedUntil=null).
|
||||
$remotePC = $entity->getRemotePC();
|
||||
if ($remotePC && $remotePC->isReservedActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ou = $entity->getOrganizationalUnit();
|
||||
if (!$ou || !$ou->getRemoteCalendar()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->syncNeeded = true;
|
||||
// UDS sync on client status change is disabled.
|
||||
// Sync is now triggered manually via the calendar sync button.
|
||||
}
|
||||
|
||||
public function postFlush(PostFlushEventArgs $args): void
|
||||
{
|
||||
if (!$this->syncNeeded) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->syncNeeded = false;
|
||||
|
||||
try {
|
||||
$this->udsClient->__invoke();
|
||||
$this->logger->info('UDS sync triggered by client status change');
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->warning('UDS sync failed after client status change', ['error' => $e->getMessage()]);
|
||||
}
|
||||
// UDS sync on client status change is disabled.
|
||||
// Sync is now triggered manually via the calendar sync button.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue