Updated ogLive API. OgAgent deploy-image fixed bug in partitionInfo
parent
82c42f04f5
commit
e3b5bc202c
|
@ -8,6 +8,7 @@ use App\Dto\Input\DeployImageInput;
|
|||
use App\Entity\Command;
|
||||
use App\Entity\Image;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Entity\Partition;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\DeployMethodTypes;
|
||||
use App\Model\TraceStatus;
|
||||
|
@ -33,7 +34,8 @@ class DeployImageAction extends AbstractController
|
|||
|
||||
public function __invoke(DeployImageInput $input, Image $image): JsonResponse
|
||||
{
|
||||
$partitionInfo = json_decode($image->getPartitionInfo(), true);
|
||||
/** @var Partition $partition */
|
||||
$partition = $input->partition->getEntity();
|
||||
|
||||
$inputData = [
|
||||
'method' => $input->method,
|
||||
|
@ -45,8 +47,8 @@ class DeployImageAction extends AbstractController
|
|||
'mcastPort' => $input->mcastPort,
|
||||
'mcastSpeed' => $input->mcastSpeed,
|
||||
'mcastMode' => $input->mcastMode,
|
||||
'numDisk' => (string) $partitionInfo['numDisk'],
|
||||
'numPartition' => (string) $partitionInfo['numPartition'],
|
||||
'numDisk' => (string) $partition->getDiskNumber(),
|
||||
'numPartition' => (string) $partition->getPartitionNumber(),
|
||||
];
|
||||
|
||||
switch ($input->method){
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Dto\Input\DeployImageInput;
|
|||
use App\Entity\Client;
|
||||
use App\Entity\Command;
|
||||
use App\Entity\Image;
|
||||
use App\Entity\Partition;
|
||||
use App\Entity\Trace;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\TraceStatus;
|
||||
|
@ -46,9 +47,12 @@ class DeployImageAction extends AbstractController
|
|||
/** @var Client $client */
|
||||
$client = $input->client->getEntity();
|
||||
|
||||
/** @var Partition $partition */
|
||||
$partition = $input->partition->getEntity();
|
||||
|
||||
$data = [
|
||||
'dsk' => (string) $partitionInfo['numDisk'],
|
||||
'par' => (string) $partitionInfo['numPartition'],
|
||||
'dsk' => (string) $partition->getDiskNumber(),
|
||||
'par' => (string) $partition->getPartitionNumber(),
|
||||
'ifs' => "1",
|
||||
'idi' => $image->getUuid(),
|
||||
'nci' => $image->getName(),
|
||||
|
|
|
@ -107,6 +107,7 @@ class ClientsController extends AbstractController
|
|||
$this->entityManager->persist($image);
|
||||
$client = $trace->getClient();
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->persist($trace);
|
||||
$this->entityManager->flush();
|
||||
$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']]);
|
||||
$image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $data['idi']]);
|
||||
|
||||
$client = $trace->getClient();
|
||||
|
||||
if ($data['res'] === 1) {
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
|
@ -126,6 +129,8 @@ class ClientsController extends AbstractController
|
|||
$trace->setOutput($data['der']);
|
||||
}
|
||||
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->persist($image);
|
||||
$this->entityManager->persist($trace);
|
||||
$this->entityManager->flush();
|
||||
|
@ -159,6 +164,9 @@ class ClientsController extends AbstractController
|
|||
$softwareEntity->addSoftwareProfile($softwareProfile);
|
||||
}
|
||||
|
||||
$image->setSoftwareProfile($softwareProfile);
|
||||
|
||||
$this->entityManager->persist($image);
|
||||
$this->entityManager->persist($softwareProfile);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ class GetAction extends AbstractOgBootController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(OgLive $data, HttpClientInterface $httpClient): JsonResponse
|
||||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getChecksum()) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
|||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
#[AsController]
|
||||
class GetCollectionAction extends AbstractOgBootController
|
||||
|
@ -22,9 +21,9 @@ class GetCollectionAction extends AbstractOgBootController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @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);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
|||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
#[AsController]
|
||||
class GetDefaultAction extends AbstractOgBootController
|
||||
|
@ -21,9 +20,9 @@ class GetDefaultAction extends AbstractOgBootController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @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);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
|||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
#[AsController]
|
||||
class GetIsosAction extends AbstractOgBootController
|
||||
|
@ -22,9 +21,9 @@ class GetIsosAction extends AbstractOgBootController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @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);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class InstallAction extends AbstractOgBootController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getDownloadUrl()) {
|
||||
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);
|
||||
$entityManager->persist($data);
|
||||
$entityManager->flush();
|
||||
$this->entityManager->persist($data);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class SetDefaultAction extends AbstractOgBootController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getChecksum()) {
|
||||
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]);
|
||||
|
||||
|
@ -46,8 +46,8 @@ class SetDefaultAction extends AbstractOgBootController
|
|||
}
|
||||
|
||||
$data->setIsDefault(true);
|
||||
$entityManager->persist($data);
|
||||
$entityManager->flush();
|
||||
$this->entityManager->persist($data);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ class SyncAction extends AbstractOgBootController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @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) {
|
||||
$ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['checksum' => $ogLive['id']]);
|
||||
|
|
|
@ -25,16 +25,16 @@ class UninstallAction extends AbstractOgBootController
|
|||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
|
||||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getChecksum()) {
|
||||
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);
|
||||
$entityManager->flush();
|
||||
$this->entityManager->remove($data);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class GetCollectionAction extends AbstractOgBootController
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue