refs #1088. Deploy Image. Improvements
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
59ce82ef43
commit
40c34a0112
|
@ -45,22 +45,17 @@ class DeployImageAction extends AbstractController
|
|||
/** @var Partition $partition */
|
||||
$partition = $input->partition->getEntity();
|
||||
|
||||
switch ($input->method){
|
||||
case DeployMethodTypes::UNICAST:
|
||||
case DeployMethodTypes::UNICAST_DIRECT:
|
||||
$inputData = [
|
||||
'method' => $input->method,
|
||||
'client' => $input->client->getEntity()->getUuid(),
|
||||
'image' => $image->getUuid(),
|
||||
'p2pMode' => $input->p2pMode,
|
||||
'p2pTime' => $input->p2pTime,
|
||||
'mcastIp' => $input->mcastIp,
|
||||
'mcastPort' => $input->mcastPort,
|
||||
'mcastSpeed' => $input->mcastSpeed,
|
||||
'mcastMode' => $input->mcastMode,
|
||||
'numDisk' => (string) $partition->getDiskNumber(),
|
||||
'numPartition' => (string) $partition->getPartitionNumber(),
|
||||
];
|
||||
|
||||
switch ($input->method){
|
||||
case DeployMethodTypes::UNICAST:
|
||||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, DeployMethodTypes::UNICAST);
|
||||
$this->createService->__invoke($input->client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
|
||||
|
@ -69,6 +64,21 @@ class DeployImageAction extends AbstractController
|
|||
case DeployMethodTypes::MULTICAST_UFTP:
|
||||
case DeployMethodTypes::MULTICAST_UDPCAST:
|
||||
case DeployMethodTypes::MULTICAST:
|
||||
case DeployMethodTypes::MULTICAST_UFTP_DIRECT:
|
||||
case DeployMethodTypes::MULTICAST_UDPCAST_DIRECT:
|
||||
|
||||
$inputData = [
|
||||
'method' => $input->method,
|
||||
'client' => $input->client->getEntity()->getUuid(),
|
||||
'image' => $image->getUuid(),
|
||||
'mcastIp' => $input->mcastIp,
|
||||
'mcastPort' => $input->mcastPort,
|
||||
'mcastSpeed' => $input->mcastSpeed,
|
||||
'mcastMode' => $input->mcastMode,
|
||||
'numDisk' => (string) $partition->getDiskNumber(),
|
||||
'numPartition' => (string) $partition->getPartitionNumber(),
|
||||
];
|
||||
|
||||
try {
|
||||
$this->deployImageOgRepositoryAction->__invoke($input, $image, $this->httpClient);
|
||||
} catch (\Exception $e) {
|
||||
|
@ -78,6 +88,22 @@ class DeployImageAction extends AbstractController
|
|||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, DeployMethodTypes::MULTICAST);
|
||||
$this->createService->__invoke($input->client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
|
||||
break;
|
||||
|
||||
case DeployMethodTypes::TORRENT:
|
||||
$inputData = [
|
||||
'method' => $input->method,
|
||||
'client' => $input->client->getEntity()->getUuid(),
|
||||
'image' => $image->getUuid(),
|
||||
'p2pMode' => $input->p2pMode,
|
||||
'p2pTime' => $input->p2pTime,
|
||||
'numDisk' => (string) $partition->getDiskNumber(),
|
||||
'numPartition' => (string) $partition->getPartitionNumber(),
|
||||
];
|
||||
|
||||
$agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, DeployMethodTypes::TORRENT);
|
||||
$this->createService->__invoke($input->client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ class DeployImageAction extends AbstractController
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
public function __invoke(Image $image, DeployImageInput $input, string $method)
|
||||
{
|
||||
if (!$image->getClient()->getIp()) {
|
||||
|
@ -52,13 +51,24 @@ class DeployImageAction extends AbstractController
|
|||
$partition = $input->partition->getEntity();
|
||||
|
||||
$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'),
|
||||
};
|
||||
|
||||
$ptcValue = "$method $input->mcastPort:$input->mcastMode:$input->mcastIp:$input->mcastSpeed:$input->maxClients:$input->maxTime";
|
||||
$ptcMulticastValue = "$method $input->mcastPort:$input->mcastMode:$input->mcastIp:$input->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'),
|
||||
};
|
||||
|
||||
$data = [
|
||||
'dsk' => (string) $partition->getDiskNumber(),
|
||||
|
|
|
@ -47,7 +47,7 @@ class StatusAction extends AbstractController
|
|||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
if ($client->getStatus() === ClientStatus::OG_LIVE || $client->getStatus() === ClientStatus::OFF || $client->getStatus() === ClientStatus::BUSY) {
|
||||
if ($client->getStatus() === ClientStatus::OG_LIVE || $client->getStatus() === ClientStatus::OFF || $client->getStatus() === ClientStatus::BUSY || $client->getStatus() === ClientStatus::INITIALIZING) {
|
||||
$response = $this->getOgLiveStatus($client);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace App\Controller\OgAgent\Webhook;
|
|||
use App\Entity\Client;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Entity\Partition;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Service\CreatePartitionService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -47,6 +48,9 @@ class AgentController extends AbstractController
|
|||
return new JsonResponse(['message' => 'Client not found'], Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
$clientEntity->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($clientEntity);
|
||||
|
||||
if (isset($data['cfg'])) {
|
||||
$this->createPartitionService->__invoke($data, $clientEntity);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ class ClientsController extends AbstractController
|
|||
}
|
||||
|
||||
$softwareProfile = new SoftwareProfile();
|
||||
$softwareProfile->setDescription('Perfil: ' . $image->getName());
|
||||
$softwareProfile->setDescription('Perfil software: ' . $image->getClient()->getName());
|
||||
$softwareProfile->setOrganizationalUnit($image->getClient()->getOrganizationalUnit());
|
||||
|
||||
foreach ($existingSoftware as $softwareEntity) {
|
||||
|
|
|
@ -38,14 +38,14 @@ class DeployImageAction extends AbstractOgRepositoryController
|
|||
'bitrate' => (string) $input->mcastSpeed.'M',
|
||||
'ip' => $input->mcastIp,
|
||||
'port' => $input->mcastPort,
|
||||
'method' => 'full',
|
||||
'nclients' => 20,
|
||||
'maxtime' => 120
|
||||
'method' => $input->mcastMode,
|
||||
'nclients' => $input->maxClients,
|
||||
'maxtime' => $input->maxTime
|
||||
]
|
||||
];
|
||||
|
||||
$type = match ($input->method) {
|
||||
'udpcast' => DeployMethodTypes::MULTICAST_UDPCAST,
|
||||
'udpcast', 'udpcast_direct' => DeployMethodTypes::MULTICAST_UDPCAST,
|
||||
'p2p' => DeployMethodTypes::TORRENT,
|
||||
default => DeployMethodTypes::MULTICAST_UFTP,
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ class WoLAction extends AbstractOgRepositoryController
|
|||
|
||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp(). ':8006/ogrepository/v1/wol', $params);
|
||||
|
||||
$client->setStatus(ClientStatus::OFF);
|
||||
$client->setStatus(ClientStatus::INITIALIZING);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
|
|
@ -5,10 +5,12 @@ namespace App\Model;
|
|||
final class DeployMethodTypes
|
||||
{
|
||||
public const string MULTICAST = 'multicast';
|
||||
|
||||
public const string MULTICAST_UFTP = 'uftp';
|
||||
public const string MULTICAST_UFTP_DIRECT = 'uftp-direct';
|
||||
public const string MULTICAST_UDPCAST = 'udpcast';
|
||||
public const string MULTICAST_UDPCAST_DIRECT = 'udp-direct';
|
||||
public const string UNICAST = 'unicast';
|
||||
public const string UNICAST_DIRECT = 'unicast-direct';
|
||||
public const string TORRENT = 'p2p';
|
||||
|
||||
private const array DEPLOYMENT_METHOD_TYPES = [
|
||||
|
|
Loading…
Reference in New Issue