refs #875 #863 #949 #943 #969 Adds env variable ogcoreIp, changes command script to use the ogcoreIp, changes getTemplate to standardize output, adds pxe endpoint to format mac
parent
8264459a6b
commit
d34f1dd22e
3
.env
3
.env
|
|
@ -15,8 +15,9 @@
|
||||||
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
|
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
|
||||||
|
|
||||||
###> symfony/framework-bundle ###
|
###> symfony/framework-bundle ###
|
||||||
APP_ENV=prod
|
APP_ENV=dev
|
||||||
APP_SECRET=d423d1302b974417d415b10bcde25767
|
APP_SECRET=d423d1302b974417d415b10bcde25767
|
||||||
|
OGCORE_API_URL="https://172.17.8.90:8443"
|
||||||
###< symfony/framework-bundle ###
|
###< symfony/framework-bundle ###
|
||||||
|
|
||||||
###> doctrine/doctrine-bundle ###
|
###> doctrine/doctrine-bundle ###
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ services:
|
||||||
_defaults:
|
_defaults:
|
||||||
autowire: true # Automatically injects dependencies in your services.
|
autowire: true # Automatically injects dependencies in your services.
|
||||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||||
|
bind:
|
||||||
|
$ogCoreApiUrl: '%env(OGCORE_API_URL)%'
|
||||||
|
|
||||||
# makes classes in src/ available to be used as services
|
# makes classes in src/ available to be used as services
|
||||||
# this creates a service per class whose id is the fully-qualified class name
|
# this creates a service per class whose id is the fully-qualified class name
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,9 @@ class OgLiveInstallCommand extends Command
|
||||||
protected static $defaultName = 'oglive:install';
|
protected static $defaultName = 'oglive:install';
|
||||||
private $curlRequestService;
|
private $curlRequestService;
|
||||||
private $httpClient;
|
private $httpClient;
|
||||||
private $params;
|
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
public function __construct(CurlRequestService $curlRequestService, HttpClientInterface $httpClient, ParameterBagInterface $params, LoggerInterface $logger)
|
public function __construct(CurlRequestService $curlRequestService, HttpClientInterface $httpClient, LoggerInterface $logger, protected readonly string $ogCoreApiUrl)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->curlRequestService = $curlRequestService;
|
$this->curlRequestService = $curlRequestService;
|
||||||
|
|
@ -27,8 +26,7 @@ class OgLiveInstallCommand extends Command
|
||||||
'verify_peer' => false, // Ignorar la verificación del certificado SSL
|
'verify_peer' => false, // Ignorar la verificación del certificado SSL
|
||||||
'verify_host' => false, // Ignorar la verificación del nombre del host
|
'verify_host' => false, // Ignorar la verificación del nombre del host
|
||||||
]);
|
]);
|
||||||
$this->params = $params;
|
$this->logger = $logger; // Añadimos el logger
|
||||||
$this->logger = $logger; // Añadimos el logger
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
|
|
@ -94,9 +92,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
$this->logger->info('Installation completed with details', ['installResult' => $installResult]);
|
$this->logger->info('Installation completed with details', ['installResult' => $installResult]);
|
||||||
$this->logger->info('Webhook data to be sent: ', ['webhookData' => $webhookData]);
|
$this->logger->info('Webhook data to be sent: ', ['webhookData' => $webhookData]);
|
||||||
|
|
||||||
// Obtener la URL del webhook desde el archivo .env
|
#$webhookUrl = "https://172.17.8.90:8443/og-lives/install/webhook";
|
||||||
$webhookUrl = "https://172.17.8.90:8443/og-lives/install/webhook";
|
$webhookUrl = "{$this->ogCoreApiUrl}/og-lives/install/webhook";
|
||||||
|
|
||||||
// Log: enviando datos al webhook
|
// Log: enviando datos al webhook
|
||||||
$this->logger->info('Sending data to webhook', ['webhookUrl' => $webhookUrl, 'webhookData' => $webhookData]);
|
$this->logger->info('Sending data to webhook', ['webhookUrl' => $webhookUrl, 'webhookData' => $webhookData]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1163,51 +1163,63 @@ public function createBootFile(Request $request): JsonResponse
|
||||||
return new JsonResponse(['message' => 'El archivo de arranque se eliminó correctamente'], Response::HTTP_OK);
|
return new JsonResponse(['message' => 'El archivo de arranque se eliminó correctamente'], Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/ogboot/v1/pxe-templates", methods={"GET"})
|
||||||
|
* @OA\Get(
|
||||||
|
* path="/ogboot/v1/pxe-templates",
|
||||||
|
* summary="Obtener todas las plantillas PXE",
|
||||||
|
* description="Obtiene una lista de todas las plantillas de arranque PXE disponibles.",
|
||||||
|
* @OA\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="Lista de plantillas de arranque PXE",
|
||||||
|
* @OA\JsonContent(
|
||||||
|
* type="object",
|
||||||
|
* @OA\Property(property="success", type="string", example="Lista de plantillas obtenida con éxito"),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="message",
|
||||||
|
* type="array",
|
||||||
|
* @OA\Items(type="string", example="mi_plantilla.ipxe")
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* ),
|
||||||
|
* @OA\Response(
|
||||||
|
* response=500,
|
||||||
|
* description="Error interno del servidor",
|
||||||
|
* @OA\JsonContent(
|
||||||
|
* type="object",
|
||||||
|
* @OA\Property(property="error", type="string", example="SERVER_ERROR"),
|
||||||
|
* @OA\Property(property="message", type="string", example="Directorio de plantillas no encontrado")
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function getAllTemplates(): JsonResponse
|
||||||
|
{
|
||||||
|
$templateDir = '/opt/ogboot/tftpboot/ipxe_scripts/templates';
|
||||||
|
|
||||||
/**
|
// Verificar si el directorio existe
|
||||||
* @Route("/ogboot/v1/pxe-templates", methods={"GET"})
|
if (!is_dir($templateDir)) {
|
||||||
* @OA\Get(
|
return new JsonResponse(
|
||||||
* path="/ogboot/v1/pxe-templates",
|
['error' => 'SERVER_ERROR', 'message' => 'Directorio de plantillas no encontrado'],
|
||||||
* summary="Obtener todas las plantillas PXE",
|
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||||
* description="Obtiene una lista de todas las plantillas de arranque PXE disponibles.",
|
);
|
||||||
* @OA\Response(
|
|
||||||
* response=200,
|
|
||||||
* description="Lista de plantillas de arranque PXE",
|
|
||||||
* @OA\JsonContent(
|
|
||||||
* type="object",
|
|
||||||
* @OA\Property(
|
|
||||||
* property="templates",
|
|
||||||
* type="array",
|
|
||||||
* @OA\Items(type="string", example="mi_plantilla.ipxe")
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* ),
|
|
||||||
* @OA\Response(
|
|
||||||
* response=500,
|
|
||||||
* description="Error interno del servidor"
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function getAllTemplates(): JsonResponse
|
|
||||||
{
|
|
||||||
$templateDir = '/opt/ogboot/tftpboot/ipxe_scripts/templates';
|
|
||||||
|
|
||||||
// Verificar si el directorio existe
|
|
||||||
if (!is_dir($templateDir)) {
|
|
||||||
return new JsonResponse(['error' => 'Directorio de plantillas no encontrado'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtener la lista de archivos en el directorio
|
|
||||||
$files = scandir($templateDir);
|
|
||||||
|
|
||||||
// Filtrar los archivos válidos (excluir directorios y archivos ocultos)
|
|
||||||
$templates = array_filter($files, function ($file) use ($templateDir) {
|
|
||||||
return !in_array($file, ['.', '..']) && !is_dir($templateDir . '/' . $file);
|
|
||||||
});
|
|
||||||
|
|
||||||
return new JsonResponse(['templates' => array_values($templates)], Response::HTTP_OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtener la lista de archivos en el directorio
|
||||||
|
$files = scandir($templateDir);
|
||||||
|
|
||||||
|
// Filtrar los archivos válidos (excluir directorios y archivos ocultos)
|
||||||
|
$templates = array_filter($files, function ($file) use ($templateDir) {
|
||||||
|
return !in_array($file, ['.', '..']) && !is_dir($templateDir . '/' . $file);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Formatear la respuesta siguiendo el estándar
|
||||||
|
return new JsonResponse(
|
||||||
|
['success' => 'Lista de plantillas obtenida con éxito', 'message' => array_values($templates)],
|
||||||
|
Response::HTTP_OK
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/ogboot/v1/pxe-templates/{templateName}", name="get_template", methods={"GET"})
|
* @Route("/ogboot/v1/pxe-templates/{templateName}", name="get_template", methods={"GET"})
|
||||||
* @OA\Get(
|
* @OA\Get(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue