diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2019-11-15 11:42:25 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-11-15 12:39:38 +0100 |
commit | ccb862bed934927bda1fc47841b7857426161744 (patch) | |
tree | e91f8d731cff3a3dfb1a7e091e94a280275f2b90 /admin/WebConsole/comandos | |
parent | 666dd3f44c3e59b00b829abaad441c939a5d9710 (diff) |
#915 Fix duplicated command execution when added to the queue
This patch fixes duplicated command execution by running queue scheduler instead
of directly calling the command's REST API function.
If command is already queued, then execute pending commands. Otherwise,
invoke the OgAdmServer REST API.
Diffstat (limited to 'admin/WebConsole/comandos')
-rw-r--r-- | admin/WebConsole/comandos/gestores/gestor_Comandos.php | 97 |
1 files changed, 52 insertions, 45 deletions
diff --git a/admin/WebConsole/comandos/gestores/gestor_Comandos.php b/admin/WebConsole/comandos/gestores/gestor_Comandos.php index 27b6fab6..e2e239b0 100644 --- a/admin/WebConsole/comandos/gestores/gestor_Comandos.php +++ b/admin/WebConsole/comandos/gestores/gestor_Comandos.php @@ -35,6 +35,53 @@ define('OG_CMD_ID_CREATE_INCREMENTAL_IMAGE', 14); define('OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE', 15); define('OG_CMD_ID_SENDMESSAGE', 16); +function run_command($idcomando, $cadenaip, $atributos) { + switch ($idcomando) { + case OG_CMD_ID_WAKEUP: + include("wakeonlan_repo.php"); + break; + case OG_CMD_ID_SETUP: + setup($cadenaip, $atributos); + break; + case OG_CMD_ID_SESSION: + session($cadenaip, $atributos); + break; + case OG_CMD_ID_CREATE_BASIC_IMAGE: + create_basic_image($cadenaip, $atributos); + break; + case OG_CMD_ID_CREATE_INCREMENTAL_IMAGE: + create_incremental_image($cadenaip, $atributos); + break; + case OG_CMD_ID_RESTORE_BASIC_IMAGE: + restore_basic_image($cadenaip, $atributos); + break; + case OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE: + restore_incremental_image($cadenaip, $atributos); + break; + case OG_CMD_ID_POWEROFF: + poweroff($cadenaip); + break; + case OG_CMD_ID_CREATE_IMAGE: + create_image($cadenaip, $atributos); + break; + case OG_CMD_ID_RESTORE_IMAGE: + restore_image($cadenaip, $atributos); + break; + case OG_CMD_ID_REBOOT: + reboot($cadenaip); + break; + case OG_CMD_ID_HARDWARE: + hardware($cadenaip); + break; + case OG_CMD_ID_SOFTWARE: + software($cadenaip, $atributos); + break; + case OG_CMD_ID_SCRIPT: + shell(3, $cadenaip, $atributos); + break; + } +} + // Recoge parametros de seguimiento $sw_ejya=""; $sw_seguimiento=""; @@ -183,51 +230,11 @@ if($sw_ejya=='on' || $sw_ejprg=="on" ){ $ValorParametros=extrae_parametros($parametros,chr(13),'='); $script=@urldecode($ValorParametros["scp"]); if($sw_ejya=='on'){ - /* PARCHE UHU heredado de la version 1.1.0: Si la accion a realizar es Arrancar incluimos una pagina para arrancar desde el repo */ - switch ($idcomando) { - case OG_CMD_ID_WAKEUP: - include("wakeonlan_repo.php"); - break; - case OG_CMD_ID_SETUP: - setup($cadenaip, $atributos); - break; - case OG_CMD_ID_SESSION: - session($cadenaip, $atributos); - break; - case OG_CMD_ID_CREATE_BASIC_IMAGE: - create_basic_image($cadenaip, $atributos); - break; - case OG_CMD_ID_CREATE_INCREMENTAL_IMAGE: - create_incremental_image($cadenaip, $atributos); - break; - case OG_CMD_ID_RESTORE_BASIC_IMAGE: - restore_basic_image($cadenaip, $atributos); - break; - case OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE: - restore_incremental_image($cadenaip, $atributos); - break; - case OG_CMD_ID_POWEROFF: - poweroff($cadenaip); - break; - case OG_CMD_ID_CREATE_IMAGE: - create_image($cadenaip, $atributos); - break; - case OG_CMD_ID_RESTORE_IMAGE: - restore_image($cadenaip, $atributos); - break; - case OG_CMD_ID_REBOOT: - reboot($cadenaip); - break; - case OG_CMD_ID_HARDWARE: - hardware($cadenaip); - break; - case OG_CMD_ID_SOFTWARE: - software($cadenaip, $atributos); - break; - case OG_CMD_ID_SCRIPT: - shell(3, $cadenaip, $atributos); - break; - } + if ($sw_seguimiento == 1 || $sw_ejprg == "on") + run_schedule($cadenaip); + else + run_command($idcomando, $cadenaip, $atributos); + // En agente nuevo devuelvo siempre correcto $resulhidra = 1; |