Removed service. DTO input changes
parent
6da4997f51
commit
45fd79d2bc
|
@ -136,7 +136,7 @@ services:
|
||||||
|
|
||||||
api_platform.filter.partition.search:
|
api_platform.filter.partition.search:
|
||||||
parent: 'api_platform.doctrine.orm.search_filter'
|
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' ]
|
tags: [ 'api_platform.filter' ]
|
||||||
|
|
||||||
api_platform.filter.pxe_template.order:
|
api_platform.filter.pxe_template.order:
|
||||||
|
|
|
@ -101,7 +101,10 @@ final class PartitionInput
|
||||||
$partition->setOperativeSystem($this->operativeSystem->getEntity());
|
$partition->setOperativeSystem($this->operativeSystem->getEntity());
|
||||||
}
|
}
|
||||||
$partition->setClient($this->client->getEntity());
|
$partition->setClient($this->client->getEntity());
|
||||||
|
|
||||||
|
if ($this->memoryUsage) {
|
||||||
$partition->setMemoryUsage($this->memoryUsage * 100);
|
$partition->setMemoryUsage($this->memoryUsage * 100);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->image) {
|
if ($this->image) {
|
||||||
$partition->setImage($this->image->getEntity());
|
$partition->setImage($this->image->getEntity());
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue