investigar
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
269ed2202e
commit
8569e73fea
|
|
@ -507,16 +507,33 @@ class ExecutePendingTracesCommand extends Command
|
|||
private function executeLogin(Trace $trace, array $input): bool
|
||||
{
|
||||
$client = $trace->getClient();
|
||||
|
||||
if (!isset($input['partition'])) {
|
||||
throw new \Exception("Partition not found in trace input");
|
||||
|
||||
if ($client->getStatus() !== ClientStatus::OG_LIVE) {
|
||||
$this->logger->info('Login trace deferred: client not in OGLive', [
|
||||
'client' => $client->getUuid(),
|
||||
'status' => $client->getStatus(),
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$partition = $this->entityManager->getRepository(\App\Entity\Partition::class)
|
||||
->findOneBy(['uuid' => $input['partition']]);
|
||||
|
||||
if (!$partition) {
|
||||
throw new \Exception("Partition not found with UUID: {$input['partition']}");
|
||||
if (isset($input['partition'])) {
|
||||
$partition = $this->entityManager->getRepository(Partition::class)
|
||||
->findOneBy(['uuid' => $input['partition']]);
|
||||
if (!$partition) {
|
||||
throw new \Exception("Partition not found with UUID: {$input['partition']}");
|
||||
}
|
||||
} elseif (isset($input['dsk']) && isset($input['par'])) {
|
||||
$partition = $this->entityManager->getRepository(Partition::class)
|
||||
->findOneBy([
|
||||
'client' => $client,
|
||||
'diskNumber' => $input['dsk'],
|
||||
'partitionNumber' => $input['par'],
|
||||
]);
|
||||
if (!$partition) {
|
||||
throw new \Exception("Partition not found for disk {$input['dsk']} partition {$input['par']}");
|
||||
}
|
||||
} else {
|
||||
throw new \Exception("Partition not found in trace input");
|
||||
}
|
||||
|
||||
$bootClientsInput = new BootClientsInput();
|
||||
|
|
|
|||
|
|
@ -52,8 +52,13 @@ class LoginAction extends AbstractOgAgentController
|
|||
throw new BadRequestHttpException('IP is required');
|
||||
}
|
||||
|
||||
$partitionInput = [
|
||||
'dsk' => $partition->getDiskNumber(),
|
||||
'par' => $partition->getPartitionNumber(),
|
||||
];
|
||||
|
||||
if ($client->getStatus() !== ClientStatus::OG_LIVE) {
|
||||
$this->createService->__invoke($client, CommandTypes::LOGIN, TraceStatus::PENDING, null, []);
|
||||
$this->createService->__invoke($client, CommandTypes::LOGIN, TraceStatus::PENDING, null, $partitionInput);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +79,7 @@ class LoginAction extends AbstractOgAgentController
|
|||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
$this->createService->__invoke($client, CommandTypes::LOGIN, TraceStatus::PENDING, null, []);
|
||||
$this->createService->__invoke($client, CommandTypes::LOGIN, TraceStatus::PENDING, null, $partitionInput);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Entity\AgentQueue;
|
|||
use App\Entity\Client;
|
||||
use App\Entity\Partition;
|
||||
use App\Entity\RemotePC;
|
||||
use App\Entity\Trace;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\TraceStatus;
|
||||
|
|
@ -20,6 +21,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
|
|
@ -102,6 +104,17 @@ class RemotePcController extends AbstractController
|
|||
$queueRepo = $this->entityManager->getRepository(AgentQueue::class);
|
||||
$queueRepo->deleteByClientAndOperations($client, self::QUEUE_OPERATIONS);
|
||||
|
||||
$this->entityManager->createQuery(
|
||||
'DELETE FROM App\Entity\Trace t
|
||||
WHERE t.client = :client
|
||||
AND t.command = :command
|
||||
AND t.status = :status'
|
||||
)
|
||||
->setParameter('client', $client)
|
||||
->setParameter('command', CommandTypes::LOGIN)
|
||||
->setParameter('status', TraceStatus::PENDING)
|
||||
->execute();
|
||||
|
||||
$this->sendPowerOff($client);
|
||||
|
||||
$this->logger->info('RemotePC: client unreserved', ['client_id' => $client->getId()]);
|
||||
|
|
@ -230,18 +243,20 @@ class RemotePcController extends AbstractController
|
|||
$repository = $client->getRepository();
|
||||
if ($repository?->getIp()) {
|
||||
$this->httpClient->request('POST', 'http://' . $repository->getIp() . ':8006/ogrepository/v1/wol', [
|
||||
'json' => ['broadcast_ip' => '255.255.255.255', 'mac' => $client->getMac()],
|
||||
]);
|
||||
'json' => ['broadcast_ip' => '255.255.255.255', 'mac' => $client->getMac()],
|
||||
'timeout' => 2.0,
|
||||
])->getStatusCode();
|
||||
$this->logger->info('RemotePC: WoL sent', ['mac' => $client->getMac()]);
|
||||
}
|
||||
} else {
|
||||
$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 $e) {
|
||||
} catch (TransportExceptionInterface | HttpExceptionInterface $e) {
|
||||
$this->logger->warning('RemotePC: boot command failed', ['client_id' => $client->getId(), 'error' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
|
|
@ -258,6 +273,7 @@ class RemotePcController extends AbstractController
|
|||
try {
|
||||
$this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/opengnsys/IniciarSesion', [
|
||||
'verify_host' => false,
|
||||
'timeout' => 2.0,
|
||||
'json' => [
|
||||
'nfn' => 'IniciarSesion',
|
||||
'dsk' => (string) $partition->getDiskNumber(),
|
||||
|
|
@ -265,11 +281,11 @@ class RemotePcController extends AbstractController
|
|||
'ids' => '0',
|
||||
],
|
||||
'headers' => ['Authorization' => $client->getToken()],
|
||||
]);
|
||||
])->getStatusCode();
|
||||
$client->setStatus(ClientStatus::INITIALIZING);
|
||||
$this->entityManager->persist($client);
|
||||
$this->logger->info('RemotePC: IniciarSesion sent', ['ip' => $client->getIp()]);
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
} catch (TransportExceptionInterface | HttpExceptionInterface $e) {
|
||||
$this->logger->warning('RemotePC: IniciarSesion failed', ['client_id' => $client->getId(), 'error' => $e->getMessage()]);
|
||||
$this->createService->__invoke($client, CommandTypes::LOGIN, TraceStatus::PENDING, null, [
|
||||
'dsk' => $partition->getDiskNumber(),
|
||||
|
|
@ -283,9 +299,10 @@ class RemotePcController extends AbstractController
|
|||
try {
|
||||
$this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/opengnsys/Apagar', [
|
||||
'verify_host' => false,
|
||||
'timeout' => 2.0,
|
||||
'headers' => ['Authorization' => $client->getToken()],
|
||||
]);
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
])->getStatusCode();
|
||||
} catch (TransportExceptionInterface | HttpExceptionInterface $e) {
|
||||
$this->logger->warning('RemotePC: poweroff failed', ['client_id' => $client->getId(), 'error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue