refs #1701. Updated Sync with ogLive. Parse new data

pull/26/head
Manuel Aranda Rosales 2025-03-19 15:44:35 +01:00
parent 1f4a88df0f
commit 5be87008c4
6 changed files with 8 additions and 22 deletions

View File

@ -7,7 +7,7 @@ namespace App\Controller\OgBoot;
use App\Controller\OgBoot\PxeBootFile\PostAction; use App\Controller\OgBoot\PxeBootFile\PostAction;
use App\Service\Trace\CreateService; use App\Service\Trace\CreateService;
use App\Service\Utils\ExtractOgLiveFilenameDateService; use App\Service\Utils\ExtractOgLiveFilenameDateService;
use App\Service\Utils\SymflipyOgLiveFilenameService; use App\Service\Utils\SimplifyOgLiveFilenameService;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\Autowire;
@ -34,7 +34,7 @@ abstract class AbstractOgBootController extends AbstractController
protected readonly EntityManagerInterface $entityManager, protected readonly EntityManagerInterface $entityManager,
protected readonly HttpClientInterface $httpClient, protected readonly HttpClientInterface $httpClient,
protected readonly CreateService $createService, protected readonly CreateService $createService,
protected readonly SymflipyOgLiveFilenameService $symflipyOgLiveFilenameService, protected readonly SimplifyOgLiveFilenameService $simplifyOgLiveFilenameService,
protected readonly ExtractOgLiveFilenameDateService $extractOgLiveFilenameDateService, protected readonly ExtractOgLiveFilenameDateService $extractOgLiveFilenameDateService,
) )
{ {

View File

@ -30,7 +30,7 @@ class GetIsosAction extends AbstractOgBootController
} }
$isos = array_map(function ($iso) { $isos = array_map(function ($iso) {
$filename = $this->symflipyOgLiveFilenameService->__invoke($iso['filename']); $filename = $this->simplifyOgLiveFilenameService->__invoke($iso['filename']);
return [ return [
'id' => $iso['id'], 'id' => $iso['id'],

View File

@ -49,7 +49,7 @@ class InstallAction extends AbstractOgBootController
$this->createService->__invoke(null, CommandTypes::INSTALL_OGLIVE, TraceStatus::IN_PROGRESS, 'InstallOgLive_'.$data->getUuid(), $inputData); $this->createService->__invoke(null, CommandTypes::INSTALL_OGLIVE, TraceStatus::IN_PROGRESS, 'InstallOgLive_'.$data->getUuid(), $inputData);
$data->setName($this->symflipyOgLiveFilenameService->__invoke($data->getFilename())); $data->setName($this->simplifyOgLiveFilenameService->__invoke($data->getFilename()));
$data->setDate(new \DateTime()); $data->setDate(new \DateTime());
$data->setStatus(OgLiveStatus::PENDING); $data->setStatus(OgLiveStatus::PENDING);
$this->entityManager->persist($data); $this->entityManager->persist($data);

View File

@ -76,7 +76,7 @@ class SyncAction extends AbstractOgBootController
*/ */
private function extracted(OgLive $ogLiveEntity, mixed $ogLive): void private function extracted(OgLive $ogLiveEntity, mixed $ogLive): void
{ {
$ogLiveEntity->setName($this->symflipyOgLiveFilenameService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory']))); $ogLiveEntity->setName($this->simplifyOgLiveFilenameService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory'])));
$ogLiveEntity->setDate(new \DateTime($this->extractOgLiveFilenameDateService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory'])))); $ogLiveEntity->setDate(new \DateTime($this->extractOgLiveFilenameDateService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory']))));
$ogLiveEntity->setInstalled(true); $ogLiveEntity->setInstalled(true);
$ogLiveEntity->setArchitecture($ogLive['architecture']); $ogLiveEntity->setArchitecture($ogLive['architecture']);

View File

@ -8,6 +8,7 @@ use App\Entity\Trace;
use App\Model\OgLiveStatus; use App\Model\OgLiveStatus;
use App\Model\TraceStatus; use App\Model\TraceStatus;
use App\Service\Utils\ExtractOgLiveFilenameDateService; use App\Service\Utils\ExtractOgLiveFilenameDateService;
use App\Service\Utils\SimplifyOgLiveFilenameService;
use App\Service\Utils\SymflipyOgLiveFilenameService; use App\Service\Utils\SymflipyOgLiveFilenameService;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -34,7 +35,7 @@ class InstallOgLiveResponseAction extends AbstractController
public function __construct( public function __construct(
protected readonly EntityManagerInterface $entityManager, protected readonly EntityManagerInterface $entityManager,
protected readonly LoggerInterface $logger, protected readonly LoggerInterface $logger,
protected readonly SymflipyOgLiveFilenameService $symflipyOgLiveFilenameService, protected readonly SimplifyOgLiveFilenameService $simplifyOgLiveFilenameService,
protected readonly ExtractOgLiveFilenameDateService $extractOgLiveFilenameDateService, protected readonly ExtractOgLiveFilenameDateService $extractOgLiveFilenameDateService,
) )
{ {
@ -93,7 +94,7 @@ class InstallOgLiveResponseAction extends AbstractController
private function updateOgLive (OgLive $ogLive, mixed $details, string $status): void private function updateOgLive (OgLive $ogLive, mixed $details, string $status): void
{ {
if ( is_array($details) && $status === self::OG_LIVE_INSTALL_SUCCESS) { if ( is_array($details) && $status === self::OG_LIVE_INSTALL_SUCCESS) {
$ogLive->setName($this->symflipyOgLiveFilenameService->__invoke($details['directory'])); $ogLive->setName($this->simplifyOgLiveFilenameService->__invoke($details['directory']));
$ogLive->setDate(new \DateTime($this->extractOgLiveFilenameDateService->__invoke($details['directory']))); $ogLive->setDate(new \DateTime($this->extractOgLiveFilenameDateService->__invoke($details['directory'])));
$ogLive->setFilename(str_replace(self::OG_BOOT_DIRECTORY, '', $details['directory'])); $ogLive->setFilename(str_replace(self::OG_BOOT_DIRECTORY, '', $details['directory']));
$ogLive->setInstalled(true); $ogLive->setInstalled(true);

View File

@ -1,15 +0,0 @@
<?php
namespace App\Service\Utils;
class SymflipyOgLiveFilenameService
{
public function __invoke(string $filename): string
{
if (preg_match('/^(.+)-r\d+\.[a-f0-9]+_(\d{8})(?:\.iso)?$/', $filename, $matches)) {
return "{$matches[1]}-{$matches[2]}";
}
return $filename;
}
}