getImage(); if (!$client->getIp()) { throw new ValidatorException('IP is required'); } $method = match ($input->method) { DeployMethodTypes::MULTICAST_UFTP_DIRECT, DeployMethodTypes::MULTICAST_UDPCAST_DIRECT, => 'multicast-direct', DeployMethodTypes::MULTICAST, DeployMethodTypes::MULTICAST_UFTP, DeployMethodTypes::MULTICAST_UDPCAST => 'multicast', DeployMethodTypes::UNICAST_DIRECT => 'unicast-direct', DeployMethodTypes::UNICAST => 'unicast', DeployMethodTypes::TORRENT => 'torrent', default => throw new ValidatorException('Invalid method'), }; $mcastMode = $input->mcastMode.'-duplex'; $mcastSpeed = $input->mcastSpeed.'M'; $ptcMulticastValue = "$method $input->mcastPort:$mcastMode:$input->mcastIp:$mcastSpeed:$input->maxClients:$input->maxTime"; $ptcTorrentValue = "$method $input->p2pMode:$input->p2pTime"; $ptcUnicastValue = $method; $ptcValue = match ($input->method) { DeployMethodTypes::MULTICAST, DeployMethodTypes::MULTICAST_UFTP, DeployMethodTypes::MULTICAST_UFTP_DIRECT, DeployMethodTypes::MULTICAST_UDPCAST, DeployMethodTypes::MULTICAST_UDPCAST_DIRECT => $ptcMulticastValue, DeployMethodTypes::UNICAST, DeployMethodTypes::UNICAST_DIRECT => $ptcUnicastValue, DeployMethodTypes::TORRENT => $ptcTorrentValue, default => throw new ValidatorException('Invalid method'), }; $repository = $imageImageRepository->getRepository(); $data = [ 'dsk' => (string) $input->diskNumber, 'par' => (string) $input->partitionNumber, 'ifs' => "1", 'idi' => $image->getUuid(), 'nci' => $imageImageRepository->getName(), 'ipr' => $repository->getIp(), 'nfn' => 'RestaurarImagen', 'ptc' => $ptcValue, 'ids' => '0' ]; $response = $this->createRequest( method: 'POST', url: 'https://'.$client->getIp().':8000/opengnsys/RestaurarImagen', params: [ 'json' => $data, ], token: $client->getToken(), ); $this->logger->info('Deploying image', [ 'image' => $imageImageRepository->getName(), 'repository' => $repository->getIp()]); if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) { throw new ValidatorException('Error deploying image'); } $jobId = $response['job_id']; $client->setStatus(ClientStatus::BUSY); $this->entityManager->persist($client); $this->entityManager->flush(); return $jobId; } }