Updated ogLive API. OgAgent deploy-image fixed bug in partitionInfo
testing/ogcore-api/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/tag This commit looks good Details

composer-install opengnsys_devel-0.0.15
Manuel Aranda Rosales 2024-11-27 11:21:03 +01:00
parent 82c42f04f5
commit e3b5bc202c
12 changed files with 42 additions and 31 deletions

View File

@ -8,6 +8,7 @@ use App\Dto\Input\DeployImageInput;
use App\Entity\Command; use App\Entity\Command;
use App\Entity\Image; use App\Entity\Image;
use App\Entity\OrganizationalUnit; use App\Entity\OrganizationalUnit;
use App\Entity\Partition;
use App\Model\CommandTypes; use App\Model\CommandTypes;
use App\Model\DeployMethodTypes; use App\Model\DeployMethodTypes;
use App\Model\TraceStatus; use App\Model\TraceStatus;
@ -33,7 +34,8 @@ class DeployImageAction extends AbstractController
public function __invoke(DeployImageInput $input, Image $image): JsonResponse public function __invoke(DeployImageInput $input, Image $image): JsonResponse
{ {
$partitionInfo = json_decode($image->getPartitionInfo(), true); /** @var Partition $partition */
$partition = $input->partition->getEntity();
$inputData = [ $inputData = [
'method' => $input->method, 'method' => $input->method,
@ -45,8 +47,8 @@ class DeployImageAction extends AbstractController
'mcastPort' => $input->mcastPort, 'mcastPort' => $input->mcastPort,
'mcastSpeed' => $input->mcastSpeed, 'mcastSpeed' => $input->mcastSpeed,
'mcastMode' => $input->mcastMode, 'mcastMode' => $input->mcastMode,
'numDisk' => (string) $partitionInfo['numDisk'], 'numDisk' => (string) $partition->getDiskNumber(),
'numPartition' => (string) $partitionInfo['numPartition'], 'numPartition' => (string) $partition->getPartitionNumber(),
]; ];
switch ($input->method){ switch ($input->method){

View File

@ -8,6 +8,7 @@ use App\Dto\Input\DeployImageInput;
use App\Entity\Client; use App\Entity\Client;
use App\Entity\Command; use App\Entity\Command;
use App\Entity\Image; use App\Entity\Image;
use App\Entity\Partition;
use App\Entity\Trace; use App\Entity\Trace;
use App\Model\ClientStatus; use App\Model\ClientStatus;
use App\Model\TraceStatus; use App\Model\TraceStatus;
@ -46,9 +47,12 @@ class DeployImageAction extends AbstractController
/** @var Client $client */ /** @var Client $client */
$client = $input->client->getEntity(); $client = $input->client->getEntity();
/** @var Partition $partition */
$partition = $input->partition->getEntity();
$data = [ $data = [
'dsk' => (string) $partitionInfo['numDisk'], 'dsk' => (string) $partition->getDiskNumber(),
'par' => (string) $partitionInfo['numPartition'], 'par' => (string) $partition->getPartitionNumber(),
'ifs' => "1", 'ifs' => "1",
'idi' => $image->getUuid(), 'idi' => $image->getUuid(),
'nci' => $image->getName(), 'nci' => $image->getName(),

View File

@ -107,6 +107,7 @@ class ClientsController extends AbstractController
$this->entityManager->persist($image); $this->entityManager->persist($image);
$client = $trace->getClient(); $client = $trace->getClient();
$client->setStatus(ClientStatus::OG_LIVE); $client->setStatus(ClientStatus::OG_LIVE);
$this->entityManager->persist($client);
$this->entityManager->persist($trace); $this->entityManager->persist($trace);
$this->entityManager->flush(); $this->entityManager->flush();
$this->logger->info('Image updated. Success.', ['image' => (string) $image->getUuid()]); $this->logger->info('Image updated. Success.', ['image' => (string) $image->getUuid()]);
@ -116,6 +117,8 @@ class ClientsController extends AbstractController
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]); $trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
$image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $data['idi']]); $image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $data['idi']]);
$client = $trace->getClient();
if ($data['res'] === 1) { if ($data['res'] === 1) {
$trace->setStatus(TraceStatus::SUCCESS); $trace->setStatus(TraceStatus::SUCCESS);
$trace->setFinishedAt(new \DateTime()); $trace->setFinishedAt(new \DateTime());
@ -126,6 +129,8 @@ class ClientsController extends AbstractController
$trace->setOutput($data['der']); $trace->setOutput($data['der']);
} }
$client->setStatus(ClientStatus::OG_LIVE);
$this->entityManager->persist($client);
$this->entityManager->persist($image); $this->entityManager->persist($image);
$this->entityManager->persist($trace); $this->entityManager->persist($trace);
$this->entityManager->flush(); $this->entityManager->flush();
@ -159,6 +164,9 @@ class ClientsController extends AbstractController
$softwareEntity->addSoftwareProfile($softwareProfile); $softwareEntity->addSoftwareProfile($softwareProfile);
} }
$image->setSoftwareProfile($softwareProfile);
$this->entityManager->persist($image);
$this->entityManager->persist($softwareProfile); $this->entityManager->persist($softwareProfile);
$this->entityManager->flush(); $this->entityManager->flush();
} }

View File

@ -23,13 +23,13 @@ class GetAction extends AbstractOgBootController
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function __invoke(OgLive $data, HttpClientInterface $httpClient): JsonResponse public function __invoke(OgLive $data): JsonResponse
{ {
if (!$data->getChecksum()) { if (!$data->getChecksum()) {
throw new ValidatorException('Checksum is required'); throw new ValidatorException('Checksum is required');
} }
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum()); $content = $this->createRequest('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
return new JsonResponse(data: $content, status: Response::HTTP_OK); return new JsonResponse(data: $content, status: Response::HTTP_OK);
} }

View File

@ -11,7 +11,6 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController] #[AsController]
class GetCollectionAction extends AbstractOgBootController class GetCollectionAction extends AbstractOgBootController
@ -22,9 +21,9 @@ class GetCollectionAction extends AbstractOgBootController
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function __invoke(HttpClientInterface $httpClient): JsonResponse public function __invoke(): JsonResponse
{ {
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives'); $content = $this->createRequest('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives');
return new JsonResponse(data: $content, status: Response::HTTP_OK); return new JsonResponse(data: $content, status: Response::HTTP_OK);
} }

View File

@ -10,7 +10,6 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController] #[AsController]
class GetDefaultAction extends AbstractOgBootController class GetDefaultAction extends AbstractOgBootController
@ -21,9 +20,9 @@ class GetDefaultAction extends AbstractOgBootController
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function __invoke(HttpClientInterface $httpClient): JsonResponse public function __invoke(): JsonResponse
{ {
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default'); $content = $this->createRequest('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default');
return new JsonResponse(status: Response::HTTP_OK); return new JsonResponse(status: Response::HTTP_OK);
} }

View File

@ -11,7 +11,6 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController] #[AsController]
class GetIsosAction extends AbstractOgBootController class GetIsosAction extends AbstractOgBootController
@ -22,9 +21,9 @@ class GetIsosAction extends AbstractOgBootController
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function __invoke(HttpClientInterface $httpClient): JsonResponse public function __invoke(): JsonResponse
{ {
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/isos'); $content = $this->createRequest('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/isos');
return new JsonResponse(data: $content, status: Response::HTTP_OK); return new JsonResponse(data: $content, status: Response::HTTP_OK);
} }

View File

@ -25,7 +25,7 @@ class InstallAction extends AbstractOgBootController
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse public function __invoke(OgLive $data): JsonResponse
{ {
if (!$data->getDownloadUrl()) { if (!$data->getDownloadUrl()) {
throw new ValidatorException('Download URL is required'); throw new ValidatorException('Download URL is required');
@ -38,11 +38,11 @@ class InstallAction extends AbstractOgBootController
] ]
]; ];
$content = $this->createRequest($httpClient, 'POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/install', $params); $content = $this->createRequest('POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/install', $params);
$data->setStatus(OgLiveStatus::PENDING); $data->setStatus(OgLiveStatus::PENDING);
$entityManager->persist($data); $this->entityManager->persist($data);
$entityManager->flush(); $this->entityManager->flush();
return new JsonResponse(data: $content, status: Response::HTTP_OK); return new JsonResponse(data: $content, status: Response::HTTP_OK);
} }

View File

@ -24,7 +24,7 @@ class SetDefaultAction extends AbstractOgBootController
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse public function __invoke(OgLive $data): JsonResponse
{ {
if (!$data->getChecksum()) { if (!$data->getChecksum()) {
throw new ValidatorException('Checksum URL is required'); throw new ValidatorException('Checksum URL is required');
@ -36,7 +36,7 @@ class SetDefaultAction extends AbstractOgBootController
] ]
]; ];
$content = $this->createRequest($httpClient, 'PUT', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params); $content = $this->createRequest('PUT', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params);
$oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]); $oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]);
@ -46,8 +46,8 @@ class SetDefaultAction extends AbstractOgBootController
} }
$data->setIsDefault(true); $data->setIsDefault(true);
$entityManager->persist($data); $this->entityManager->persist($data);
$entityManager->flush(); $this->entityManager->flush();
return new JsonResponse(status: Response::HTTP_OK); return new JsonResponse(status: Response::HTTP_OK);
} }

View File

@ -26,9 +26,9 @@ class SyncAction extends AbstractOgBootController
* @throws RedirectionExceptionInterface * @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
*/ */
public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse public function __invoke(): JsonResponse
{ {
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl . '/ogboot/v1/oglives'); $content = $this->createRequest('GET', 'http://'.$this->ogBootApiUrl . '/ogboot/v1/oglives');
foreach ($content['message']['installed_ogLives'] as $ogLive) { foreach ($content['message']['installed_ogLives'] as $ogLive) {
$ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['checksum' => $ogLive['id']]); $ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['checksum' => $ogLive['id']]);

View File

@ -25,16 +25,16 @@ class UninstallAction extends AbstractOgBootController
* @throws ClientExceptionInterface * @throws ClientExceptionInterface
* @throws TransportExceptionInterface * @throws TransportExceptionInterface
*/ */
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse public function __invoke(OgLive $data): JsonResponse
{ {
if (!$data->getChecksum()) { if (!$data->getChecksum()) {
throw new ValidatorException('Checksum is required'); throw new ValidatorException('Checksum is required');
} }
$content = $this->createRequest($httpClient, 'DELETE', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum()); $content = $this->createRequest( 'DELETE', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
$entityManager->remove($data); $this->entityManager->remove($data);
$entityManager->flush(); $this->entityManager->flush();
return new JsonResponse(status: Response::HTTP_OK); return new JsonResponse(status: Response::HTTP_OK);
} }

View File

@ -26,7 +26,7 @@ class GetCollectionAction extends AbstractOgBootController
*/ */
public function __invoke(HttpClientInterface $httpClient): JsonResponse public function __invoke(HttpClientInterface $httpClient): JsonResponse
{ {
$content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes'); $content = $this->createRequest('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes');
return new JsonResponse(data: $content, status: Response::HTTP_OK); return new JsonResponse(data: $content, status: Response::HTTP_OK);
} }