From eb3fc2c9d1fd7f80976faef581df8e781bed286a Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 13 Jan 2025 10:30:19 +0100 Subject: [PATCH 1/9] refs #1271 fix status that dont allow return status when is not installed oglives --- .../Controller/OgBootController.php | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/OgBootBundle/Controller/OgBootController.php b/src/OgBootBundle/Controller/OgBootController.php index 73556d8..d420e73 100644 --- a/src/OgBootBundle/Controller/OgBootController.php +++ b/src/OgBootBundle/Controller/OgBootController.php @@ -140,11 +140,23 @@ public function getStatus(): Response $ogLiveConfigResult = $ogLiveResponse['output']; $ogLiveExitCode = $ogLiveResponse['exitCode']; + $defaultOglive = null; + $installedOglives = []; + $ogLiveError = null; + if ($ogLiveExitCode !== 0) { - return new JsonResponse( - ['error' => 'FAILED_TO_RETRIEVE_OGLIVE_CONFIGURATION', 'details' => $ogLiveConfigResult['error'] ?? 'Unknown error'], - Response::HTTP_INTERNAL_SERVER_ERROR - ); + // Capturar el error, pero continuar la ejecución + $ogLiveError = [ + 'error' => 'FAILED_TO_RETRIEVE_OGLIVE_CONFIGURATION', + 'details' => $ogLiveConfigResult['error'] ?? 'Unknown error' + ]; + } else { + // Extraer datos si el comando fue exitoso + $defaultOglive = $ogLiveConfigResult['default_oglive'] ?? null; + $installedOglives = $ogLiveConfigResult['installed_ogLives'] ?? []; + if (empty($installedOglives)) { + $installedOglives = ['message' => 'No installed ogLives found']; + } } // Llamar a oglivecli para obtener el estado de los servicios @@ -164,10 +176,7 @@ public function getStatus(): Response $installedOglives = $ogLiveConfigResult['installed_ogLives'] ?? []; if ($defaultOglive === null || empty($installedOglives)) { - return new JsonResponse( - ['error' => 'NOT_FOUND', 'message' => 'No default or installed ogLives found.'], - Response::HTTP_NOT_FOUND - ); + $installedOglives = ['message' => 'No installed ogLives found']; } $response = [ @@ -180,6 +189,11 @@ public function getStatus(): Response ] ]; // Formatear la respuesta final con todos los datos + // Incluir el error de oglive si existe + if ($ogLiveError !== null) { + $response['message']['oglive_error'] = $ogLiveError; + } + return new JsonResponse($response, Response::HTTP_OK); } -- 2.40.1 From d8f9ff5523073d11173ac2bc05f93606ec8401c7 Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 13 Jan 2025 10:31:27 +0100 Subject: [PATCH 2/9] refs #1271 modifies install that dont allow download iso when oglive is already installed --- bin/oglivecli | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/oglivecli b/bin/oglivecli index 35ccc8c..7dd741c 100755 --- a/bin/oglivecli +++ b/bin/oglivecli @@ -139,6 +139,8 @@ function download() { else local download_url="$1" OGLIVEFILE=$(basename "$download_url") + local oglive_name="${OGLIVEFILE%.iso}" # Nombre del ogLive sin la extensión .iso + INSTALLED_PATH="$TFTPDIR/$oglive_name" # Ruta de instalación donde se verifica # Validar que la URL apunte a un archivo ISO. if [[ ! "$OGLIVEFILE" =~ \.iso$ ]]; then @@ -148,6 +150,18 @@ function download() { # Obtener el tamaño de descarga. SOURCELENGTH=$(curl -k --head --retry 5 --retry-delay 5 --max-time 30 "$download_url" | awk -F: '/Content-Length:/ {print $2}') [ -n "$SOURCELENGTH" ] || raiseError download "No se pudo obtener el tamaño del archivo desde \"$download_url\"." + + # Verificar si el ogLive ya está instalado + if [ -d "$INSTALLED_PATH" ]; then + echo "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." + return 0 + fi + # Verificar si el ogLive ya está instalado + echo $INSTALLED_PATH + if [ -d "$INSTALLED_PATH" ]; then + echo "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." + return 0 + fi # Descargar ogLive. TARGETFILE="$DOWNLOADDIR/$OGLIVEFILE" -- 2.40.1 From e097e09617c27bbbb33363017cf088055bf7f394 Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 3 Feb 2025 08:45:12 +0100 Subject: [PATCH 3/9] refs #1272 removes duplicated code --- bin/oglivecli | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bin/oglivecli b/bin/oglivecli index 7dd741c..0a49636 100755 --- a/bin/oglivecli +++ b/bin/oglivecli @@ -156,12 +156,6 @@ function download() { echo "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." return 0 fi - # Verificar si el ogLive ya está instalado - echo $INSTALLED_PATH - if [ -d "$INSTALLED_PATH" ]; then - echo "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." - return 0 - fi # Descargar ogLive. TARGETFILE="$DOWNLOADDIR/$OGLIVEFILE" -- 2.40.1 From 600dff2b2f9bf0edc97c381945b1f170dd248f37 Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 3 Feb 2025 08:49:25 +0100 Subject: [PATCH 4/9] refs #1433 adds port of ogcore to postconf.lib --- client/engine/PostConf.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/engine/PostConf.lib b/client/engine/PostConf.lib index eb5f6eb..4fe47b5 100755 --- a/client/engine/PostConf.lib +++ b/client/engine/PostConf.lib @@ -360,7 +360,7 @@ for AGENTDIR in usr/share/OGAgent "Program Files/OGAgent" "Program Files (x86)/O done [ -n "$CFGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "ogagent.cfg" || return $? # Parchear dirección del servidor OpenGnsys en el fichero de configuración de OGAgent. -sed -i "0,/remote=/ s,remote=.*,remote=https://$(ogGetServerIp)/opengnsys/rest/," "$CFGFILE" +sed -i "0,/remote=/ s,remote=.*,remote=https://$(ogGetServerIp):8443/opengnsys/rest/," "$CFGFILE" } -- 2.40.1 From 56482e843b3e453df069d3bedf0aed1e5bd37af6 Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 3 Feb 2025 08:51:12 +0100 Subject: [PATCH 5/9] refs #1435 adds engine directory to client/engine when ogboot is installed --- installer/ogboot_installer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/installer/ogboot_installer.py b/installer/ogboot_installer.py index eb35053..0e8a357 100755 --- a/installer/ogboot_installer.py +++ b/installer/ogboot_installer.py @@ -459,12 +459,19 @@ def copyClientFiles(): logger.error(f"Error while copying client structure") errstatus = 1 - logger.info(f"Copying OpenGnsys Cloning Engine files.") + logger.info(f"Copying OpenGnsys Cloning Engine files in client library.") os.makedirs(f"{INSTALL_OGBOOT_TARGET}/client/lib/engine/bin", mode=0o775, exist_ok=True) if 0 != subprocess.run (['rsync', '-aH', f'{REPO_DIR}/client/engine/', f'{INSTALL_OGBOOT_TARGET}/client/lib/engine/bin/']).returncode: logger.error(f"Error while copying engine files") errstatus = 1 + logger.info(f"Copying OpenGnsys Cloning Engine files in client engine.") + os.makedirs(f"{INSTALL_OGBOOT_TARGET}/client/engine", mode=0o775, exist_ok=True) + if 0 != subprocess.run (['rsync', '-aH', f'{REPO_DIR}/client/engine/', f'{INSTALL_OGBOOT_TARGET}/client/engine/']).returncode: + logger.error(f"Error while copying engine files") + errstatus = 1 + + # Creación del archivo ogAdmClient.cfg try: template_path = os.path.join(REPO_DIR, "etc/ogAdmClient.cfg.tmpl") -- 2.40.1 From bd2db726db9e82dd962aebf20e919e13243e95a8 Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 3 Feb 2025 13:12:32 +0100 Subject: [PATCH 6/9] refs #1273 add empty array when is not installed oglives --- src/OgBootBundle/Controller/OgBootController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OgBootBundle/Controller/OgBootController.php b/src/OgBootBundle/Controller/OgBootController.php index d420e73..9162daf 100644 --- a/src/OgBootBundle/Controller/OgBootController.php +++ b/src/OgBootBundle/Controller/OgBootController.php @@ -176,7 +176,7 @@ public function getStatus(): Response $installedOglives = $ogLiveConfigResult['installed_ogLives'] ?? []; if ($defaultOglive === null || empty($installedOglives)) { - $installedOglives = ['message' => 'No installed ogLives found']; + $installedOglives = []; } $response = [ -- 2.40.1 From af0305302eb0dcb67edbec79946f8406f5ad82e9 Mon Sep 17 00:00:00 2001 From: lgromero Date: Tue, 25 Feb 2025 07:17:45 +0100 Subject: [PATCH 7/9] refs #1271 changes exception of duplicated install --- bin/oglivecli | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/oglivecli b/bin/oglivecli index 0a49636..7ba70d2 100755 --- a/bin/oglivecli +++ b/bin/oglivecli @@ -153,8 +153,7 @@ function download() { # Verificar si el ogLive ya está instalado if [ -d "$INSTALLED_PATH" ]; then - echo "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." - return 0 + raiseError "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." fi # Descargar ogLive. -- 2.40.1 From 87b9bdc8a452f7913532a42440793b594c97dfec Mon Sep 17 00:00:00 2001 From: lgromero Date: Tue, 25 Feb 2025 07:38:40 +0100 Subject: [PATCH 8/9] refs #1271 adds download raiseexception --- bin/oglivecli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/oglivecli b/bin/oglivecli index 7ba70d2..e0874d7 100755 --- a/bin/oglivecli +++ b/bin/oglivecli @@ -153,7 +153,7 @@ function download() { # Verificar si el ogLive ya está instalado if [ -d "$INSTALLED_PATH" ]; then - raiseError "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." + raiseError download "El ogLive \"$oglive_name\" ya está instalado en \"$INSTALLED_PATH\"." fi # Descargar ogLive. -- 2.40.1 From ecde5a29a71f7c78fe5dd91e598e290a75d41019 Mon Sep 17 00:00:00 2001 From: lgromero Date: Tue, 25 Feb 2025 07:39:54 +0100 Subject: [PATCH 9/9] refs #1271 removes some innecesaries parameters comprobations --- .../Controller/OgBootController.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/OgBootBundle/Controller/OgBootController.php b/src/OgBootBundle/Controller/OgBootController.php index 9162daf..7eea552 100644 --- a/src/OgBootBundle/Controller/OgBootController.php +++ b/src/OgBootBundle/Controller/OgBootController.php @@ -140,7 +140,7 @@ public function getStatus(): Response $ogLiveConfigResult = $ogLiveResponse['output']; $ogLiveExitCode = $ogLiveResponse['exitCode']; - $defaultOglive = null; + $defaultOglive = ""; $installedOglives = []; $ogLiveError = null; @@ -150,13 +150,12 @@ public function getStatus(): Response 'error' => 'FAILED_TO_RETRIEVE_OGLIVE_CONFIGURATION', 'details' => $ogLiveConfigResult['error'] ?? 'Unknown error' ]; + $defaultOglive = ""; + $installedOglives = []; } else { // Extraer datos si el comando fue exitoso - $defaultOglive = $ogLiveConfigResult['default_oglive'] ?? null; + $defaultOglive = $ogLiveConfigResult['default_oglive'] ?? ""; $installedOglives = $ogLiveConfigResult['installed_ogLives'] ?? []; - if (empty($installedOglives)) { - $installedOglives = ['message' => 'No installed ogLives found']; - } } // Llamar a oglivecli para obtener el estado de los servicios @@ -171,14 +170,6 @@ public function getStatus(): Response ); } - // Verificar si las claves 'default_oglive' e 'installed_ogLives' existen en la respuesta de oglivecli - $defaultOglive = $ogLiveConfigResult['default_oglive'] ?? null; - $installedOglives = $ogLiveConfigResult['installed_ogLives'] ?? []; - - if ($defaultOglive === null || empty($installedOglives)) { - $installedOglives = []; - } - $response = [ 'success' => 'Status retrieved successfully', 'message' => [ -- 2.40.1