From 45fd79d2bc3c49a5b48bf63aeb80142fa6a8bab8 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Fri, 25 Oct 2024 10:57:00 +0200 Subject: [PATCH] Removed service. DTO input changes --- config/services/api_platform.yaml | 2 +- src/Dto/Input/PartitionInput.php | 5 +- .../OgBoot/PxeBootFile/PostService.php | 79 ------------------- 3 files changed, 5 insertions(+), 81 deletions(-) delete mode 100644 src/Service/OgBoot/PxeBootFile/PostService.php diff --git a/config/services/api_platform.yaml b/config/services/api_platform.yaml index 96d9926..b5f7b49 100644 --- a/config/services/api_platform.yaml +++ b/config/services/api_platform.yaml @@ -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: diff --git a/src/Dto/Input/PartitionInput.php b/src/Dto/Input/PartitionInput.php index 635149f..2e7d366 100644 --- a/src/Dto/Input/PartitionInput.php +++ b/src/Dto/Input/PartitionInput.php @@ -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()); diff --git a/src/Service/OgBoot/PxeBootFile/PostService.php b/src/Service/OgBoot/PxeBootFile/PostService.php deleted file mode 100644 index 17ebe2e..0000000 --- a/src/Service/OgBoot/PxeBootFile/PostService.php +++ /dev/null @@ -1,79 +0,0 @@ - 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; - } -} \ No newline at end of file