refs #1692. Import Image. Changes
testing/ogcore-api/pipeline/head This commit looks good Details

pull/26/head
Manuel Aranda Rosales 2025-03-11 17:37:44 +01:00
parent 350dcd1d24
commit 7c37bd418a
1 changed files with 21 additions and 20 deletions

View File

@ -33,26 +33,6 @@ class ImportAction extends AbstractOgRepositoryController
{
$image = $input->name;
$params = [
'json' => [
'image' => $image.'.img'
]
];
$this->logger->info('Creating aux files', ['image' => $image]);
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/torrentsum', $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::CREATE_IMAGE_AUX_FILE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
$imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['name' => $image]);
if (!$imageEntity){
@ -70,6 +50,27 @@ class ImportAction extends AbstractOgRepositoryController
throw new ValidatorException('This image already exists in this repository');
}
$params = [
'json' => [
'image' => $image.'.img'
]
];
$this->logger->info('Creating aux files', ['image' => $image]);
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/torrentsum', $params);
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
throw new ValidatorException('Error importing image');
}
$inputData = [
'imageName' => $image,
'imageUuid' => $imageImageRepositoryEntity->getUuid(),
];
$this->createService->__invoke(null, CommandTypes::CREATE_IMAGE_AUX_FILE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData);
$imageImageRepositoryEntity = new ImageImageRepository();
$imageImageRepositoryEntity->setStatus(ImageStatus::AUX_FILES_PENDING);
$imageImageRepositoryEntity->setImage($imageEntity);