refs #1693. Convert Image. Experimental commit
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
b9e894f2d0
commit
fca9bb3ae3
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Controller\OgRepository\Image;
|
namespace App\Controller\OgRepository\Image;
|
||||||
|
|
||||||
use App\Controller\OgRepository\AbstractOgRepositoryController;
|
use App\Controller\OgRepository\AbstractOgRepositoryController;
|
||||||
|
use App\Dto\Input\ConvertImageRepositoryInput;
|
||||||
use App\Dto\Input\ImportImageRepositoryInput;
|
use App\Dto\Input\ImportImageRepositoryInput;
|
||||||
use App\Entity\Image;
|
use App\Entity\Image;
|
||||||
use App\Entity\ImageImageRepository;
|
use App\Entity\ImageImageRepository;
|
||||||
|
@ -29,31 +30,10 @@ class ConvertAction extends AbstractOgRepositoryController
|
||||||
* @throws RedirectionExceptionInterface
|
* @throws RedirectionExceptionInterface
|
||||||
* @throws ClientExceptionInterface
|
* @throws ClientExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function __invoke(ImportImageRepositoryInput $input, ImageRepository $repository): JsonResponse
|
public function __invoke(ConvertImageRepositoryInput $input, ImageRepository $repository): JsonResponse
|
||||||
{
|
{
|
||||||
$image = $input->name;
|
$image = $input->name;
|
||||||
|
|
||||||
$params = [
|
|
||||||
'json' => [
|
|
||||||
'filesystem' => 'ext4',
|
|
||||||
'virtual_image' => $image
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->logger->info('Converting image', ['image' => $image]);
|
|
||||||
|
|
||||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/virtual', $params);
|
|
||||||
|
|
||||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
|
||||||
throw new ValidatorException('Error importing image');
|
|
||||||
}
|
|
||||||
|
|
||||||
$inputData = [
|
|
||||||
'imageName' => $image
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->createService->__invoke(null, CommandTypes::CONVERT_IMAGE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
|
||||||
|
|
||||||
$imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['name' => $image]);
|
$imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['name' => $image]);
|
||||||
|
|
||||||
if (!$imageEntity){
|
if (!$imageEntity){
|
||||||
|
@ -73,6 +53,28 @@ class ConvertAction extends AbstractOgRepositoryController
|
||||||
$this->entityManager->persist($imageImageRepositoryEntity);
|
$this->entityManager->persist($imageImageRepositoryEntity);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$this->logger->info('Converting image', ['image' => $image]);
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'json' => [
|
||||||
|
'filesystem' => 'ext4',
|
||||||
|
'virtual_image' => $image
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/virtual', $params);
|
||||||
|
|
||||||
|
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||||
|
throw new ValidatorException('Error converting image');
|
||||||
|
}
|
||||||
|
|
||||||
|
$inputData = [
|
||||||
|
'imageName' => $image,
|
||||||
|
'imageUuid' => $imageImageRepositoryEntity->getUuid(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->createService->__invoke(null, CommandTypes::CONVERT_IMAGE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
||||||
|
|
||||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue