develop-jenkins
parent
5173dc81f0
commit
7e6a0a2a1b
|
@ -11,8 +11,8 @@ resources:
|
|||
ApiPlatform\Metadata\GetCollection:
|
||||
provider: App\State\Provider\SoftwareProfileProvider
|
||||
filters:
|
||||
- 'api_platform.filter.software.order'
|
||||
- 'api_platform.filter.software.search'
|
||||
- 'api_platform.filter.software_profile.order'
|
||||
- 'api_platform.filter.software_profile.search'
|
||||
|
||||
ApiPlatform\Metadata\Get:
|
||||
provider: App\State\Provider\SoftwareProfileProvider
|
||||
|
|
|
@ -173,6 +173,18 @@ services:
|
|||
arguments: [ { 'id': 'exact', 'name': 'partial', type: 'exact'} ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.software_profile.order:
|
||||
parent: 'api_platform.doctrine.orm.order_filter'
|
||||
arguments:
|
||||
$properties: { 'id': ~, 'description': ~ }
|
||||
$orderParameterName: 'order'
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.software_profile.search:
|
||||
parent: 'api_platform.doctrine.orm.search_filter'
|
||||
arguments: [ { 'id': 'exact', 'description': 'partial' } ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.subnet.order:
|
||||
parent: 'api_platform.doctrine.orm.order_filter'
|
||||
arguments:
|
||||
|
|
|
@ -38,15 +38,13 @@ class InstallOgLiveResponseAction extends AbstractController
|
|||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if ($data === null || !isset($data['message'], $data['ogCoreId'], $data['details'])) {
|
||||
if ($data === null || !isset($data['message'], $data['ogCoreId'], $data['status'])) {
|
||||
return new JsonResponse(['error' => 'Invalid or incomplete JSON data'], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$message = $data['message'];
|
||||
$ogCoreId = $data['ogCoreId'];
|
||||
$details = $data['details'];
|
||||
$status = $data['status'];
|
||||
$result = $status === self::OG_LIVE_INSTALL_SUCCESS ? $details['result'] : [];
|
||||
|
||||
$ogLive = $this->entityManager->getRepository(OgLive::class)->findOneBy(['uuid' => $ogCoreId]);
|
||||
|
||||
|
@ -58,22 +56,22 @@ class InstallOgLiveResponseAction extends AbstractController
|
|||
return new JsonResponse(['error' => 'OgLive is already active'], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$this->updateOgLive($ogLive, $details, $result, $status);
|
||||
$this->updateOgLive($ogLive, $message, $status);
|
||||
|
||||
return new JsonResponse(data: sprintf('OgLive %s updated successfully', $ogLive->getChecksum()), status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
private function updateOgLive (OgLive $ogLive, array $details, array $result, string $status): void
|
||||
private function updateOgLive (OgLive $ogLive, array $details, string $status): void
|
||||
{
|
||||
if ($status === self::OG_LIVE_INSTALL_SUCCESS) {
|
||||
$ogLive->setInstalled(true);
|
||||
$ogLive->setSynchronized(true);
|
||||
$ogLive->setChecksum($result['id']);
|
||||
$ogLive->setDistribution($result['distribution']);
|
||||
$ogLive->setKernel($result['kernel']);
|
||||
$ogLive->setArchitecture($result['architecture']);
|
||||
$ogLive->setRevision($result['revision']);
|
||||
$ogLive->setDirectory($result['directory']);
|
||||
$ogLive->setChecksum($details['id']);
|
||||
$ogLive->setDistribution($details['distribution']);
|
||||
$ogLive->setKernel($details['kernel']);
|
||||
$ogLive->setArchitecture($details['architecture']);
|
||||
$ogLive->setRevision($details['revision']);
|
||||
$ogLive->setDirectory($details['directory']);
|
||||
}
|
||||
|
||||
$ogLive->setStatus($status === self::OG_LIVE_INSTALL_SUCCESS ? OgLiveStatus::ACTIVE : OgLiveStatus::FAILED);
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use App\Dto\Output\ImageOutput;
|
||||
use App\Dto\Output\OperativeSystemOutput;
|
||||
use App\Entity\Partition;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
class PartitionArrayInput
|
||||
{
|
||||
/**
|
||||
* @var PartitionInput[]
|
||||
*/
|
||||
#[Groups(['partition:write'])]
|
||||
#[ApiProperty(description: 'The partitions of the client', example: "[{diskNumber: 1, partitionNumber: 1, partitionCode: 'code', size: 100, cacheContent: 'cache content', filesystem: 'filesystem', operativeSystem: {name: 'Ubuntu'}, client: {name: 'client'}, memoryUsage: 100, image: {name: 'image'}}]")]
|
||||
public ?array $partitions = [];
|
||||
}
|
|
@ -49,7 +49,6 @@ final class PartitionInput
|
|||
#[ApiProperty(description: 'The client of the partition')]
|
||||
public ?ClientOutput $client = null;
|
||||
|
||||
#[Assert\NotNull()]
|
||||
#[Groups(['partition:write'])]
|
||||
#[ApiProperty(description: 'The memory usage of the partition', example: 100)]
|
||||
public ?int $memoryUsage = null;
|
||||
|
@ -97,10 +96,16 @@ final class PartitionInput
|
|||
$partition->setSize($this->size * 100);
|
||||
$partition->setCacheContent($this->cacheContent);
|
||||
$partition->setFilesystem($this->filesystem);
|
||||
$partition->setOperativeSystem($this->operativeSystem->getEntity());
|
||||
|
||||
if ($this->operativeSystem) {
|
||||
$partition->setOperativeSystem($this->operativeSystem->getEntity());
|
||||
}
|
||||
$partition->setClient($this->client->getEntity());
|
||||
$partition->setMemoryUsage($this->memoryUsage * 100);
|
||||
$partition->setImage($this->image->getEntity());
|
||||
|
||||
if ($this->image) {
|
||||
$partition->setImage($this->image->getEntity());
|
||||
}
|
||||
|
||||
return $partition;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Dto\Input;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use App\Dto\Output\OperativeSystemOutput;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\SoftwareProfile;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
@ -21,6 +22,11 @@ final class SoftwareProfileInput
|
|||
#[ApiProperty(description: 'The organizational unit of the software profile')]
|
||||
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
||||
|
||||
#[Groups(['software-profile:write'])]
|
||||
#[ApiProperty(description: 'The operative system of the software profile')]
|
||||
public ?OperativeSystemOutput $operativeSystem = null;
|
||||
|
||||
|
||||
public function __construct(?SoftwareProfile $softwareProfile = null)
|
||||
{
|
||||
if (!$softwareProfile) {
|
||||
|
@ -32,6 +38,10 @@ final class SoftwareProfileInput
|
|||
if($softwareProfile->getOrganizationalUnit()) {
|
||||
$this->organizationalUnit = new OrganizationalUnitOutput($softwareProfile->getOrganizationalUnit());
|
||||
}
|
||||
|
||||
if($softwareProfile->getOperativeSystem()) {
|
||||
$this->operativeSystem = new OperativeSystemOutput($softwareProfile->getOperativeSystem());
|
||||
}
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?SoftwareProfile $softwareProfile = null): SoftwareProfile
|
||||
|
@ -46,6 +56,10 @@ final class SoftwareProfileInput
|
|||
$softwareProfile->setOrganizationalUnit($this->organizationalUnit->getEntity());
|
||||
}
|
||||
|
||||
if ($this->operativeSystem) {
|
||||
$softwareProfile->setOperativeSystem($this->operativeSystem->getEntity());
|
||||
}
|
||||
|
||||
return $softwareProfile;
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ readonly class ImageProvider implements ProviderInterface
|
|||
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||
|
||||
if (!$item) {
|
||||
throw new NotFoundHttpException('Menu not found');
|
||||
throw new NotFoundHttpException('Image not found');
|
||||
}
|
||||
|
||||
return new ImageOutput($item);
|
||||
|
|
Loading…
Reference in New Issue