refs #1973. Linked image to partition
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
parent
7f5ed49f97
commit
6df1057b20
|
@ -294,7 +294,7 @@ services:
|
|||
|
||||
api_platform.filter.trace.search:
|
||||
parent: 'api_platform.doctrine.orm.search_filter'
|
||||
arguments: [ { 'id': 'exact', 'command.id': 'exact', 'client.id': 'exact', status: 'exact' } ]
|
||||
arguments: [ { 'id': 'exact', 'command': 'exact', 'client.id': 'exact', status: 'exact' } ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.trace.order:
|
||||
|
|
|
@ -55,6 +55,7 @@ class DeployImageAction extends AbstractController
|
|||
'method' => $input->method,
|
||||
'client' => $client->getEntity()->getUuid(),
|
||||
'image' => $image->getUuid(),
|
||||
'imageName' => $image->getName(),
|
||||
'numDisk' => (string) $input->diskNumber,
|
||||
'numPartition' => (string) $input->partitionNumber,
|
||||
];
|
||||
|
|
|
@ -161,6 +161,24 @@ class StatusController extends AbstractController
|
|||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->persist($trace);
|
||||
|
||||
if ($data['nfn'] === self::RESTORE_IMAGE) {
|
||||
$partitionData = json_decode(json_encode($trace->getInput()), true);
|
||||
|
||||
$numDisk = (int) $partitionData['numDisk'] ?? null;
|
||||
$numPartition = (int) $partitionData['numPartition'] ?? null;
|
||||
|
||||
$imageImageRepository = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['uuid' => $partitionData['image']]);
|
||||
|
||||
$partition = $this->entityManager->getRepository(Partition::class)
|
||||
->findOneBy(['diskNumber' => $numDisk, 'partitionNumber' => $numPartition, 'client' => $client]);
|
||||
|
||||
if ($partition) {
|
||||
$partition->setImage($imageImageRepository);
|
||||
$this->entityManager->persist($partition);
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ class ImageImageRepositoryOutput extends AbstractOutput
|
|||
public ?ImageOutput $image = null;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public ?ImageRepositoryOutput $imageRepository= null;
|
||||
public ?ImageRepositoryOutput $imageRepository = null;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public string $status;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
#[Groups(['image-image-repository:read', 'image:read', 'partition:read'])]
|
||||
public string $name;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Dto\Output;
|
||||
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\ImageImageRepository;
|
||||
use App\Entity\Partition;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
|
@ -30,6 +31,9 @@ class PartitionOutput extends AbstractOutput
|
|||
#[Groups(['partition:read', 'client:read'])]
|
||||
public ?OperativeSystemOutput $operativeSystem = null;
|
||||
|
||||
#[Groups(['partition:read', 'client:read'])]
|
||||
public ?ImageImageRepositoryOutput $image = null;
|
||||
|
||||
#[Groups(['partition:read', 'client:read'])]
|
||||
public ?int $memoryUsage = null;
|
||||
|
||||
|
@ -43,9 +47,15 @@ class PartitionOutput extends AbstractOutput
|
|||
$this->size = $partition->getSize() / 1024 ;
|
||||
$this->cacheContent = $partition->getCacheContent();
|
||||
$this->filesystem = $partition->getFilesystem();
|
||||
|
||||
if ($partition->getOperativeSystem()) {
|
||||
$this->operativeSystem = new OperativeSystemOutput($partition->getOperativeSystem());
|
||||
}
|
||||
|
||||
if ($partition->getImage()) {
|
||||
$this->image = new ImageImageRepositoryOutput($partition->getImage());
|
||||
}
|
||||
|
||||
$this->memoryUsage = $partition->getMemoryUsage() / 100;
|
||||
}
|
||||
}
|
|
@ -49,10 +49,17 @@ class Image extends AbstractEntity
|
|||
#[ORM\Column(nullable: true)]
|
||||
private ?int $version = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, GitImageRepository>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'image', targetEntity: GitImageRepository::class,cascade: ['persist'], orphanRemoval: true)]
|
||||
private Collection $gitImageRepositories;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->imageImageRepositories = new ArrayCollection();
|
||||
$this->gitImageRepositories = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
|
@ -206,4 +213,34 @@ class Image extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, GitImageRepository>
|
||||
*/
|
||||
public function getGitImageRepositories(): Collection
|
||||
{
|
||||
return $this->gitImageRepositories;
|
||||
}
|
||||
|
||||
public function addGitImageRepository(GitImageRepository $gitImageRepository): static
|
||||
{
|
||||
if (!$this->gitImageRepositories->contains($gitImageRepository)) {
|
||||
$this->gitImageRepositories->add($gitImageRepository);
|
||||
$gitImageRepository->setImage($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeGitImageRepository(GitImageRepository $gitImageRepository): static
|
||||
{
|
||||
if ($this->gitImageRepositories->removeElement($gitImageRepository)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($gitImageRepository->getImage() === $this) {
|
||||
$gitImageRepository->setImage(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class Partition extends AbstractEntity
|
|||
|
||||
#[ORM\ManyToOne(inversedBy: 'partitions')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Image $image = null;
|
||||
private ?ImageImageRepository $image = null;
|
||||
|
||||
public function getDiskNumber(): ?int
|
||||
{
|
||||
|
@ -150,12 +150,12 @@ class Partition extends AbstractEntity
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getImage(): ?Image
|
||||
public function getImage(): ?ImageImageRepository
|
||||
{
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
public function setImage(?Image $image): static
|
||||
public function setImage(?ImageImageRepository $image): static
|
||||
{
|
||||
$this->image = $image;
|
||||
|
||||
|
|
Loading…
Reference in New Issue