Removed service. DTO input changes
testing/ogcore-api/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/pr-main Build started... Details

pull/12/head
Manuel Aranda Rosales 2024-10-25 10:57:00 +02:00
parent 6da4997f51
commit 45fd79d2bc
3 changed files with 5 additions and 81 deletions

View File

@ -136,7 +136,7 @@ services:
api_platform.filter.partition.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'usage': 'exact', 'diskNumber': 'exact' } ]
arguments: [ { 'id': 'exact', 'usage': 'exact', 'diskNumber': 'exact', 'client.id': 'exact' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.pxe_template.order:

View File

@ -101,7 +101,10 @@ final class PartitionInput
$partition->setOperativeSystem($this->operativeSystem->getEntity());
}
$partition->setClient($this->client->getEntity());
$partition->setMemoryUsage($this->memoryUsage * 100);
if ($this->memoryUsage) {
$partition->setMemoryUsage($this->memoryUsage * 100);
}
if ($this->image) {
$partition->setImage($this->image->getEntity());

View File

@ -1,79 +0,0 @@
<?php
namespace App\Service\OgBoot\PxeBootFile;
use App\Entity\PxeBootFile;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
readonly class PostService
{
public function __construct(
private string $ogBootApiUrl
)
{
}
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(PxeBootFile $bootFile)
{
$httpClient = HttpClient::create([
'verify_peer' => false, // Ignorar la verificación del certificado SSL
'verify_host' => false, // Ignorar la verificación del nombre del host
]);
foreach ($bootFile->getClients() as $client) {
$data = [
'template_name' => 'pxe_default',
'mac' => $client->getMac(),
'lang' => 'es_ES.UTF_8',
'ip' => $client->getIp(),
'server_ip' => '92.168.2.1',
'router' => $client->getOrganizationalUnit()->getNetworkSettings()->getRouter(),
'netmask' => $client->getOrganizationalUnit()->getNetworkSettings() ? $client->getOrganizationalUnit()->getNetworkSettings()->getNetmask() : '255.255.255.0',
'computer_name' => $client->getName(),
'netiface' => $client->getNetiface(),
'group' => $client->getOrganizationalUnit()->getName(),
'ogrepo' => $client->getRepository() ? $client->getRepository()->getIpAddress() : '192.168.2.1',
'oglive' => '127.0.0.1',
'oglog' => '192.168.2.1',
'ogshare' => '192.168.2.1',
'oglivedir' => 'ogLive',
'ogprof' => 'false',
'hardprofile' => $client->getHardwareProfile() ? $client->getHardwareProfile()->getDescription() : 'default',
'ogntp' => $client->getOrganizationalUnit()->getNetworkSettings()?->getNtp(),
'ogdns' => $client->getOrganizationalUnit()->getNetworkSettings()?->getDns(),
'ogProxy' => $client->getOrganizationalUnit()->getNetworkSettings()?->getProxy(),
'ogunit' => '',
'resolution' => '788'
];
try {
$response = $httpClient->request('POST', $this->ogBootApiUrl.'/ogboot/v1/pxes', [
'headers' => [
'accept' => 'application/json',
'Content-Type' => 'application/json',
],
'json' => $data
]);
} catch (TransportExceptionInterface $e) {
return new JsonResponse( data: $e->getMessage(), status: Response::HTTP_INTERNAL_SERVER_ERROR);
}
return json_decode($response->getContent(), true);
}
return 1;
}
}