Refs #202 modidys controller endpoints and add a bar to tftpboot dir
parent
7a5d2b2c7b
commit
c64ad8cb21
|
@ -43,7 +43,7 @@ PROG=$(basename "$(realpath "$0")") # Program name.
|
|||
OPENGNSYS=/opt/ogboot # OpenGnsys main directory.
|
||||
DOWNLOADDIR=$OPENGNSYS/lib # Directory to store ogLive images.
|
||||
DOWNLOADURL="https://ognproject.evlt.uma.es/trac/downloads" # Download URL.
|
||||
TFTPDIR=$OPENGNSYS/tftpboot # TFTP directory.
|
||||
TFTPDIR=$OPENGNSYS/tftpboot/ # TFTP directory.
|
||||
DEFOGLIVE="ogLive" # Default ogLive directory.
|
||||
MINREL=20190601 # Mininum ogLive compatibility release.
|
||||
INFOFILE=$OPENGNSYS/etc/ogliveinfo.json # Configuration file.
|
||||
|
|
|
@ -68,13 +68,13 @@ Regenerar plantilla - PUT /ogboot/pxe-templates
|
|||
}
|
||||
|
||||
/**
|
||||
* @Route("/ogboot/v1/config", name="getConfig", methods={"GET"})
|
||||
* @Route("/ogboot/v1/status", name="getStatus", methods={"GET"})
|
||||
* @OA\Get(
|
||||
* path="/ogboot/v1/config",
|
||||
* summary="Get ogboot configuration",
|
||||
* path="/ogboot/v1/status",
|
||||
* summary="Get ogboot status",
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Configuration retrieved successfully",
|
||||
* description="Status retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="disk_usage", type="object",
|
||||
|
@ -89,7 +89,7 @@ Regenerar plantilla - PUT /ogboot/pxe-templates
|
|||
* )
|
||||
* )
|
||||
*/
|
||||
public function getConfig(): Response
|
||||
public function getStatus(): Response
|
||||
{
|
||||
// Call oglivecli to get disk usage
|
||||
$diskUsageResult = $this->curlRequestService->callOgLive("disk_usage");
|
||||
|
@ -124,43 +124,6 @@ public function getConfig(): Response
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/ogboot/v1/status", name="status", methods={"GET"})
|
||||
* @OA\Get(
|
||||
* path="/ogboot/v1/status",
|
||||
* summary="Get ogboot status",
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Successful operation",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="message",
|
||||
* type="string",
|
||||
* description="Status message indicating any issues detected"
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=500,
|
||||
* description="Failed to retrieve status"
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function status(): Response
|
||||
{
|
||||
|
||||
# $result = $this->curlRequestService->common_request(OG_REST_CMD_POWEROFF, POST, [OG_REST_PARAM_CLIENTS => $ips]);
|
||||
$result = $this->curlRequestService->callOgLive("check");
|
||||
|
||||
if ($result) {
|
||||
return new Response($result, Response::HTTP_OK);
|
||||
} else {
|
||||
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/ogboot/v1/oglives/isos", name="getDownloadMenu", methods={"GET"})
|
||||
* @OA\Get(
|
||||
|
@ -216,7 +179,7 @@ public function getDownloadMenu(): Response
|
|||
* @OA\Property(
|
||||
* property="id",
|
||||
* type="string",
|
||||
* description="Unique identifier for the ogLive client, generated from linuxISO.sum",
|
||||
* description="Unique identifier for the ogLive client, generated from ogclient.sqfs.sum",
|
||||
* example="9e49a085ba74f97a81bdf9b3d0785094"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
|
@ -287,8 +250,8 @@ public function getOglives(): Response
|
|||
$directory = $entry;
|
||||
$ogLivePath = $directoryPath . $entry;
|
||||
|
||||
// Obtener el ID del archivo linuxISO.sum
|
||||
$sumFile = $ogLivePath . '/linuxISO.sum';
|
||||
// Obtener el ID del archivo ogclient.sqfs.sum
|
||||
$sumFile = $ogLivePath . '/ogclient.sqfs.sum';
|
||||
$id = '';
|
||||
if (file_exists($sumFile)) {
|
||||
$id = trim(file_get_contents($sumFile));
|
||||
|
@ -480,8 +443,8 @@ public function getOglive(string $checksum): Response
|
|||
|
||||
|
||||
/**
|
||||
* @Route("/ogboot/v1/oglives/default", name="setOgliveDefault", methods={"POST"})
|
||||
* @OA\Post(
|
||||
* @Route("/ogboot/v1/oglives/default", name="setOgliveDefault", methods={"PUT"})
|
||||
* @OA\Put(
|
||||
* path="/ogboot/v1/oglives/default",
|
||||
* summary="Set default ogLive client",
|
||||
* @OA\RequestBody(
|
||||
|
@ -589,7 +552,7 @@ public function installOglive(Request $request): Response
|
|||
}
|
||||
|
||||
$isoname = $data['isoname'];
|
||||
$result = $this->curlRequestService->callOgLive("install " . escapeshellarg($isoname));
|
||||
$result = $this->curlRequestService->callOgLive("download " . escapeshellarg($isoname));
|
||||
|
||||
if (is_array($result) && isset($result['success']) && $result['success'] === false) {
|
||||
return new JsonResponse(['error' => 'Failed to install ogLive client', 'details' => $result['error']], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
|
@ -1105,7 +1068,6 @@ public function getBootFile(string $mac): Response
|
|||
|
||||
return new Response($content, Response::HTTP_OK, ['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/ogboot/v1/pxe-templates", methods={"POST"})
|
||||
*
|
||||
|
@ -1160,7 +1122,7 @@ public function getBootFile(string $mac): Response
|
|||
try {
|
||||
file_put_contents($filePath, $contentTemplate);
|
||||
} catch (\Exception $e) {
|
||||
return new Response('Ocurrió un error al crear la plantilla de arranque.', 500);
|
||||
return new Response('Ocurrió un error al crear la plantilla de arranque. ' . $e->getMessage(), 500);
|
||||
}
|
||||
|
||||
return new Response(json_encode([
|
||||
|
|
|
@ -69,7 +69,6 @@ public function callOgLive($parameter)
|
|||
{
|
||||
$socketPath = '/var/run/oglive/oglive_daemon.sock';
|
||||
|
||||
// Registrar el parámetro recibido
|
||||
file_put_contents('/tmp/serviceOglive.log', 'callOgLive called with parameter: ' . $parameter . PHP_EOL, FILE_APPEND);
|
||||
|
||||
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
@ -109,7 +108,6 @@ public function callOgLive($parameter)
|
|||
|
||||
socket_close($socket);
|
||||
|
||||
// Registrar la respuesta en bruto
|
||||
file_put_contents('/tmp/serviceOglive.log', 'Raw response: ' . $response . PHP_EOL, FILE_APPEND);
|
||||
|
||||
if (empty($response)) {
|
||||
|
@ -123,7 +121,6 @@ public function callOgLive($parameter)
|
|||
|
||||
$decodedResponse = json_decode($response, true);
|
||||
|
||||
// Registrar cualquier error de decodificación JSON
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
$error = 'Error al decodificar JSON: ' . json_last_error_msg();
|
||||
file_put_contents('/tmp/serviceOglive.log', 'JSON decode error: ' . $error . PHP_EOL, FILE_APPEND);
|
||||
|
@ -134,7 +131,6 @@ public function callOgLive($parameter)
|
|||
}
|
||||
|
||||
if (isset($decodedResponse['success']) && $decodedResponse['success']) {
|
||||
// Registrar la respuesta decodificada
|
||||
file_put_contents('/tmp/serviceOglive.log', 'Decoded successful response: ' . json_encode($decodedResponse['output']) . PHP_EOL, FILE_APPEND);
|
||||
return $decodedResponse['output'];
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue