Test refactor transferImage
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
88ffad3841
commit
4a76186e97
|
@ -88,7 +88,7 @@ resources:
|
|||
description: Export Image in OgRepository
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\ExportImportImageRepositoryInput
|
||||
input: App\Dto\Input\TransferGlobalImageInput
|
||||
uriTemplate: /image-image-repositories/{uuid}/transfer-image
|
||||
controller: App\Controller\OgRepository\Image\TransferAction
|
||||
|
||||
|
@ -101,6 +101,15 @@ resources:
|
|||
uriTemplate: /image-image-repositories/server/{uuid}/status
|
||||
controller: App\Controller\OgRepository\Image\GetStatusAction
|
||||
|
||||
transfer_global_image_repository:
|
||||
shortName: OgRepository Server
|
||||
description: Transfer Global Image in OgRepository
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: false
|
||||
uriTemplate: /image-image-repositories/server/{uuid}/transfer-global
|
||||
controller: App\Controller\OgRepository\Image\TransferGlobalAction
|
||||
|
||||
properties:
|
||||
App\Entity\ImageImageRepository:
|
||||
id:
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Controller\OgRepository\Image;
|
|||
|
||||
use App\Controller\OgRepository\AbstractOgRepositoryController;
|
||||
use App\Dto\Input\ExportImportImageRepositoryInput;
|
||||
use App\Dto\Input\TransferGlobalImageInput;
|
||||
use App\Entity\Image;
|
||||
use App\Entity\ImageImageRepository;
|
||||
use App\Entity\ImageRepository;
|
||||
|
@ -28,7 +29,7 @@ class TransferAction extends AbstractOgRepositoryController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(ExportImportImageRepositoryInput $input, ImageImageRepository $imageImageRepository): JsonResponse
|
||||
public function __invoke(TransferGlobalImageInput $input, ImageImageRepository $imageImageRepository): JsonResponse
|
||||
{
|
||||
$repositories = $input->repositories;
|
||||
|
||||
|
@ -45,7 +46,7 @@ class TransferAction extends AbstractOgRepositoryController
|
|||
$params = [
|
||||
'json' => [
|
||||
'image' => $image->getName().'.img',
|
||||
'repo_ip' => $image->getClient()->getRepository()->getIp(),
|
||||
'repo_ip' => $imageImageRepository->getRepository()->getIp(),
|
||||
'user' => 'opengnsys',
|
||||
]
|
||||
];
|
||||
|
|
|
@ -21,7 +21,7 @@ use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
|||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
#[AsController]
|
||||
class TransferIsGlobalAction extends AbstractOgRepositoryController
|
||||
class TransferGlobalAction extends AbstractOgRepositoryController
|
||||
{
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
|
@ -29,26 +29,17 @@ class TransferIsGlobalAction extends AbstractOgRepositoryController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(?array $repositories = [], Image $image): JsonResponse
|
||||
public function __invoke(ImageImageRepository $imageImageRepository): JsonResponse
|
||||
{
|
||||
$repositories = $this->entityManager->getRepository(ImageRepository::class)->findAll();
|
||||
|
||||
foreach ($repositories as $repository) {
|
||||
try {
|
||||
$imageImageRepository = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['image' => $image, 'repository' => $repository]);
|
||||
|
||||
if ($imageImageRepository) {
|
||||
$content = $this->createRequest('GET', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/'.$imageImageRepository->getImageFullsum());
|
||||
|
||||
$this->logger->info('Image already exists', ['image' => $imageImageRepository->getImage()->getName(), 'repository' => $repository->getIp()]);
|
||||
continue;
|
||||
}
|
||||
} catch ( \Exception $e) {
|
||||
|
||||
}
|
||||
$image = $imageImageRepository->getImage();
|
||||
|
||||
$params = [
|
||||
'json' => [
|
||||
'image' => $image->getName().'.img',
|
||||
'repo_ip' => $image->getClient()->getRepository()->getIp(),
|
||||
'repo_ip' => $imageImageRepository->getRepository()->getIp(),
|
||||
'user' => 'opengnsys',
|
||||
]
|
||||
];
|
||||
|
@ -64,13 +55,13 @@ class TransferIsGlobalAction extends AbstractOgRepositoryController
|
|||
$inputData = [
|
||||
'imageName' => $image->getName(),
|
||||
'imageUuid' => $image->getUuid(),
|
||||
//'imageImageRepositoryUuid' => $imageImageRepository?->getUuid(),
|
||||
'imageImageRepositoryUuid' => $imageImageRepository?->getUuid(),
|
||||
'repositoryUuid' => $repository->getUuid(),
|
||||
];
|
||||
|
||||
$this->createService->__invoke($image->getClient(), CommandTypes::TRANSFER_IMAGE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
|
||||
|
||||
//$imageImageRepository->setStatus(ImageStatus::TRANSFERRING);
|
||||
$imageImageRepository->setStatus(ImageStatus::TRANSFERRING);
|
||||
$this->entityManager->persist($image);
|
||||
$this->entityManager->flush();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Dto\Output\ImageOutput;
|
||||
use App\Dto\Output\ImageRepositoryOutput;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class TransferGlobalImageInput
|
||||
{
|
||||
/**
|
||||
* @var ImageOutput[]
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['image-image-repository:write'])]
|
||||
public array $repositories = [];
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\EventSubscriber;
|
||||
|
||||
use ApiPlatform\Symfony\EventListener\EventPriorities;
|
||||
use App\Controller\OgRepository\Image\TransferIsGlobalAction;
|
||||
use App\Controller\OgRepository\Image\TransferGlobalAction;
|
||||
use App\Dto\Output\ImageRepositoryOutput;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\Image;
|
||||
|
@ -22,7 +22,7 @@ final readonly class ImageRepositorySubscriber implements EventSubscriberInterfa
|
|||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
private readonly TransferIsGlobalAction $transferIsGlobalAction,
|
||||
private readonly TransferGlobalAction $transferIsGlobalAction,
|
||||
)
|
||||
{
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ use ApiPlatform\State\ProcessorInterface;
|
|||
use ApiPlatform\Validator\ValidatorInterface;
|
||||
use App\Controller\OgAgent\CreateImageAction;
|
||||
use App\Controller\OgRepository\Image\TransferAction;
|
||||
use App\Controller\OgRepository\Image\TransferIsGlobalAction;
|
||||
use App\Dto\Input\ImageInput;
|
||||
use App\Dto\Input\ImageRepositoryInput;
|
||||
use App\Dto\Output\ImageOutput;
|
||||
|
@ -27,7 +26,6 @@ readonly class ImageProcessor implements ProcessorInterface
|
|||
private ImageRepository $imageRepository,
|
||||
private ValidatorInterface $validator,
|
||||
private CreateImageAction $createImageActionController,
|
||||
private TransferIsGlobalAction $transferActionController
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -68,11 +66,6 @@ readonly class ImageProcessor implements ProcessorInterface
|
|||
|
||||
if ($data->source !== 'input') {
|
||||
$response = $this->createImageActionController->__invoke($image);
|
||||
} else {
|
||||
if ($data->isGlobal === true) {
|
||||
$repositories = $this->imageRepositoryRepository->findAll();
|
||||
$this->transferActionController->__invoke($repositories, $image);
|
||||
}
|
||||
}
|
||||
|
||||
$this->imageRepository->save($image);
|
||||
|
|
Loading…
Reference in New Issue