clients as $clientEntity) { /** @var Client $client */ $client = $clientEntity->getEntity(); if (!$client->getIp()) { throw new ValidatorException('IP is required'); } if ($client->getStatus() === ClientStatus::OFF) { continue; } $endpoint = $client->getStatus() === ClientStatus::OG_LIVE ? 'opengnsys/Apagar' : 'opengnsys/poweroff'; $data = [ 'nfn' => 'Apagar', 'ids' => '0' ]; try { $response = $this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/'.$endpoint, [ 'verify_peer' => false, 'verify_host' => false, 'headers' => [ 'Content-Type' => 'application/json', ], 'json' => $data, ]); $this->logger->info('Powering off client', ['client' => $client->getId()]); $jobId = json_decode($response->getContent(), true)['job_id']; } catch (ClientExceptionInterface | ServerExceptionInterface | TransportExceptionInterface | TransportException $e) { $this->logger->error('Error power off client', [ 'image' => $client->getIp(), 'error' => $e->getMessage() ]); continue; } $client->setStatus(ClientStatus::TURNING_OFF); $this->entityManager->persist($client); $this->entityManager->flush(); $this->createService->__invoke($client, CommandTypes::SHUTDOWN, TraceStatus::SUCCESS, $jobId, []); } return new JsonResponse(data: [], status: Response::HTTP_OK); } }