refs #1142 adds new parameter ogcore to pxe endpoints
parent
c694b98603
commit
842e5c9b95
|
|
@ -841,6 +841,7 @@ public function getBootFiles(): JsonResponse
|
||||||
* @OA\Property(property="group", type="string", description="Group (optional)", example="Aula_virtual"),
|
* @OA\Property(property="group", type="string", description="Group (optional)", example="Aula_virtual"),
|
||||||
* @OA\Property(property="ogrepo", type="string", description="Repository IP (optional)", example="192.168.2.1"),
|
* @OA\Property(property="ogrepo", type="string", description="Repository IP (optional)", example="192.168.2.1"),
|
||||||
* @OA\Property(property="oglive", type="string", description="Live server IP (optional)", example="192.168.2.1"),
|
* @OA\Property(property="oglive", type="string", description="Live server IP (optional)", example="192.168.2.1"),
|
||||||
|
* @OA\Property(property="ogcore", type="string", description="Ogcore IP(optional)", example="192.168.2.1"),
|
||||||
* @OA\Property(property="oglog", type="string", description="Log server IP (optional)", example="192.168.2.1"),
|
* @OA\Property(property="oglog", type="string", description="Log server IP (optional)", example="192.168.2.1"),
|
||||||
* @OA\Property(property="ogshare", type="string", description="Share server IP (optional)", example="192.168.2.1"),
|
* @OA\Property(property="ogshare", type="string", description="Share server IP (optional)", example="192.168.2.1"),
|
||||||
* @OA\Property(property="oglivedir", type="string", description="Live directory (optional)", example="ogLive"),
|
* @OA\Property(property="oglivedir", type="string", description="Live directory (optional)", example="ogLive"),
|
||||||
|
|
@ -876,7 +877,7 @@ public function getBootFiles(): JsonResponse
|
||||||
// Ruta donde están alojados los archivos de arranque
|
// Ruta donde están alojados los archivos de arranque
|
||||||
$directory = '/opt/ogboot/tftpboot/ipxe_scripts';
|
$directory = '/opt/ogboot/tftpboot/ipxe_scripts';
|
||||||
|
|
||||||
// Generar el nombre del archivo basado en la dirección MAC
|
// Validar y formatear la dirección MAC
|
||||||
$mac = $this->validateAndFormatMac($mac ?? null);
|
$mac = $this->validateAndFormatMac($mac ?? null);
|
||||||
$fileName = "01-" . $mac;
|
$fileName = "01-" . $mac;
|
||||||
$filePath = "$directory/$fileName";
|
$filePath = "$directory/$fileName";
|
||||||
|
|
@ -903,23 +904,37 @@ public function getBootFiles(): JsonResponse
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Leer el contenido del archivo
|
||||||
$content = file_get_contents($realFilePath);
|
$content = file_get_contents($realFilePath);
|
||||||
$templateName = 'unknown'; // Valor por defecto si no se encuentra la plantilla
|
if ($content === false) {
|
||||||
$contentLines = explode("\n", $content);
|
return new JsonResponse(
|
||||||
|
['error' => 'FAILED_TO_READ_BOOT_FILE', 'message' => 'Error al leer el archivo de arranque.'],
|
||||||
// Buscar la plantilla utilizada
|
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||||
foreach ($contentLines as $line) {
|
);
|
||||||
if (strpos($line, '#Template:') !== false) {
|
|
||||||
$templateName = trim(str_replace('#Template:', '', $line));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extraer los parámetros del contenido del archivo iPXE
|
// Valores por defecto
|
||||||
preg_match('/set kernelargs (.*)/', $content, $matches);
|
$templateName = 'unknown';
|
||||||
|
$oglivedir = '';
|
||||||
|
$kernelArgs = '';
|
||||||
|
|
||||||
// Si no se encuentran 'kernelargs', podría ser un archivo de arranque por disco
|
// Obtener el nombre de la plantilla
|
||||||
if (!isset($matches[1])) {
|
if (preg_match('/#Template:\s*(.*)/', $content, $matches)) {
|
||||||
|
$templateName = trim($matches[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtener el valor de ISODIR
|
||||||
|
if (preg_match('/set ISODIR\s+(.*)/', $content, $matches)) {
|
||||||
|
$oglivedir = trim($matches[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtener los kernelargs
|
||||||
|
if (preg_match('/set kernelargs\s+(.*)/', $content, $matches)) {
|
||||||
|
$kernelArgs = trim($matches[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si no se encuentran kernelargs, se asume un archivo de arranque por disco
|
||||||
|
if (empty($kernelArgs)) {
|
||||||
return new JsonResponse(
|
return new JsonResponse(
|
||||||
[
|
[
|
||||||
'success' => 'Boot file retrieved successfully',
|
'success' => 'Boot file retrieved successfully',
|
||||||
|
|
@ -934,8 +949,7 @@ public function getBootFiles(): JsonResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsear los argumentos del kernel
|
// Parsear los argumentos del kernel
|
||||||
$kernelargs = $matches[1];
|
parse_str(str_replace(' ', '&', $kernelArgs), $params);
|
||||||
parse_str(str_replace(' ', '&', $kernelargs), $params);
|
|
||||||
|
|
||||||
// Crear la estructura del resultado
|
// Crear la estructura del resultado
|
||||||
$result = [
|
$result = [
|
||||||
|
|
@ -951,9 +965,10 @@ public function getBootFiles(): JsonResponse
|
||||||
'group' => $params['group'] ?? '',
|
'group' => $params['group'] ?? '',
|
||||||
'ogrepo' => $params['ogrepo'] ?? '',
|
'ogrepo' => $params['ogrepo'] ?? '',
|
||||||
'oglive' => $params['oglive'] ?? '',
|
'oglive' => $params['oglive'] ?? '',
|
||||||
|
'ogcore' => $params['ogcore'] ?? '',
|
||||||
'oglog' => $params['oglog'] ?? '',
|
'oglog' => $params['oglog'] ?? '',
|
||||||
'ogshare' => $params['ogshare'] ?? '',
|
'ogshare' => $params['ogshare'] ?? '',
|
||||||
'oglivedir' => $params['oglivedir'] ?? '',
|
'oglivedir' => $oglivedir,
|
||||||
'ogprof' => $params['ogprof'] ?? '',
|
'ogprof' => $params['ogprof'] ?? '',
|
||||||
'hardprofile' => $params['hardprofile'] ?? '',
|
'hardprofile' => $params['hardprofile'] ?? '',
|
||||||
'ogntp' => $params['ogntp'] ?? '',
|
'ogntp' => $params['ogntp'] ?? '',
|
||||||
|
|
@ -971,6 +986,8 @@ public function getBootFiles(): JsonResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/ogboot/v1/pxes", methods={"POST"})
|
* @Route("/ogboot/v1/pxes", methods={"POST"})
|
||||||
|
|
@ -1039,6 +1056,7 @@ public function createBootFile(Request $request): JsonResponse
|
||||||
'netiface' => $data['netiface'] ?? '',
|
'netiface' => $data['netiface'] ?? '',
|
||||||
'group' => $data['group'] ?? '',
|
'group' => $data['group'] ?? '',
|
||||||
'ogrepo' => $data['ogrepo'] ?? '',
|
'ogrepo' => $data['ogrepo'] ?? '',
|
||||||
|
'ogcore' => $data['ogcore'] ?? '',
|
||||||
'oglive' => $data['oglive'] ?? $serverIp,
|
'oglive' => $data['oglive'] ?? $serverIp,
|
||||||
'oglog' => $data['oglog'] ?? $serverIp,
|
'oglog' => $data['oglog'] ?? $serverIp,
|
||||||
'ogshare' => $data['ogshare'] ?? $serverIp,
|
'ogshare' => $data['ogshare'] ?? $serverIp,
|
||||||
|
|
@ -1072,6 +1090,7 @@ public function createBootFile(Request $request): JsonResponse
|
||||||
'ip=' . $parameters['ip'] . ':' . $serverIp . ':' . $parameters['router'] . ':' . $parameters['netmask'] . ':' . $parameters['computer_name'] . ':' . $parameters['netiface'] . ':none ' .
|
'ip=' . $parameters['ip'] . ':' . $serverIp . ':' . $parameters['router'] . ':' . $parameters['netmask'] . ':' . $parameters['computer_name'] . ':' . $parameters['netiface'] . ':none ' .
|
||||||
'group=' . str_replace(' ', '_', trim($parameters['group'])) . ' ' .
|
'group=' . str_replace(' ', '_', trim($parameters['group'])) . ' ' .
|
||||||
'ogrepo=' . $parameters['ogrepo'] . ' ' .
|
'ogrepo=' . $parameters['ogrepo'] . ' ' .
|
||||||
|
'ogcore=' . $parameters['ogcore'] . ' ' .
|
||||||
'oglive=' . $parameters['oglive'] . ' ' .
|
'oglive=' . $parameters['oglive'] . ' ' .
|
||||||
'oglog=' . $parameters['oglog'] . ' ' .
|
'oglog=' . $parameters['oglog'] . ' ' .
|
||||||
'ogshare=' . $parameters['ogshare'] . ' ' .
|
'ogshare=' . $parameters['ogshare'] . ' ' .
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue