clients as $clientEntity) { /** @var Client $client */ $client = $clientEntity->getEntity(); if (!$client->getIp()) { throw new ValidatorException('IP is required'); } $data = [ 'nfn' => 'EjecutarScript', 'scp' => base64_encode($input->script), 'ids' => '0' ]; $response = $this->createRequest( method: 'POST', url: 'https://'.$client->getIp().':8000/opengnsys/EjecutarScript', params: [ 'json' => $data, ], token: $client->getToken(), ); if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) { throw new ValidatorException('Error deploying image'); } $this->logger->info('Powering off client', ['client' => $client->getId()]); $jobId = $response['job_id']; $this->entityManager->persist($client); $this->entityManager->flush(); $inputData = [ 'script' => $input->script, ]; $this->createService->__invoke($client, CommandTypes::RUN_SCRIPT, TraceStatus::SUCCESS, $jobId, $inputData); } return new JsonResponse(data: [], status: Response::HTTP_OK); } }