getImage(); if (!$client->getIp()) { throw new ValidatorException('IP is required'); } $partitionInfo = json_decode($image->getPartitionInfo(), true); $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' => $image->getName(), 'ipr' => $repository->getIp(), 'nfn' => 'RestaurarImagen', 'ptc' => $ptcValue, 'ids' => '0' ]; try { $response = $this->httpClient->request('POST', 'https://'.$client->getIp().':8000/CloningEngine/RestaurarImagen', [ 'verify_peer' => false, 'verify_host' => false, 'headers' => [ 'Content-Type' => 'application/json', ], 'json' => $data, ]); $this->logger->info('Deploying image', ['image' => $image->getId()]); } catch (TransportExceptionInterface $e) { $this->logger->error('Error deploying image', ['image' => $image->getId(), 'error' => $e->getMessage()]); } $jobId = json_decode($response->getContent(), true)['job_id']; $client->setStatus(ClientStatus::BUSY); $this->entityManager->persist($client); $this->entityManager->flush(); return $jobId; } }