diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2019-10-10 18:38:59 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-10-11 11:57:08 +0200 |
commit | 0ff87c2b7b3e37ca9ff5f72e74a20d0019ad5e87 (patch) | |
tree | 090dbeb68f2be6e5291665b256f8ce62522a3313 /admin | |
parent | 55adaee1d8dccee067f2e1fd7bf1d7e299e1e388 (diff) |
#915 Adapt web to use new image/restore/incremental cmd in REST API
SocketHidra command has been replaced by POST image/restore/incremental.
Diffstat (limited to 'admin')
-rw-r--r-- | admin/WebConsole/comandos/gestores/gestor_Comandos.php | 5 | ||||
-rw-r--r-- | admin/WebConsole/includes/restfunctions.php | 53 |
2 files changed, 58 insertions, 0 deletions
diff --git a/admin/WebConsole/comandos/gestores/gestor_Comandos.php b/admin/WebConsole/comandos/gestores/gestor_Comandos.php index 70b3019d..150fde69 100644 --- a/admin/WebConsole/comandos/gestores/gestor_Comandos.php +++ b/admin/WebConsole/comandos/gestores/gestor_Comandos.php @@ -34,6 +34,7 @@ define('OG_CMD_ID_SETUP', 10); define('OG_CMD_ID_CREATE_BASIC_IMAGE', 12); define('OG_CMD_ID_RESTORE_BASIC_IMAGE', 13); define('OG_CMD_ID_CREATE_INCREMENTAL_IMAGE', 14); +define('OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE', 15); define('OG_CMD_ID_SENDMESSAGE', 16); // Recoge parametros de seguimiento @@ -150,6 +151,9 @@ switch ($idcomando) { 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; @@ -232,6 +236,7 @@ if($sw_ejya=='on' || $sw_ejprg=="on" ){ $idcomando != OG_CMD_ID_CREATE_BASIC_IMAGE && $idcomando != OG_CMD_ID_CREATE_INCREMENTAL_IMAGE && $idcomando != OG_CMD_ID_RESTORE_BASIC_IMAGE && + $idcomando != OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE && $idcomando != OG_CMD_ID_POWEROFF && $idcomando != OG_CMD_ID_HARDWARE && $idcomando != OG_CMD_ID_SOFTWARE && diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php index 285d2ba1..717985dc 100644 --- a/admin/WebConsole/includes/restfunctions.php +++ b/admin/WebConsole/includes/restfunctions.php @@ -24,6 +24,7 @@ define('OG_REST_CMD_SETUP', 'image/setup'); define('OG_REST_CMD_CREATE_BASIC_IMAGE', 'image/create/basic'); define('OG_REST_CMD_CREATE_INCREMENTAL_IMAGE', 'image/create/incremental'); define('OG_REST_CMD_RESTORE_BASIC_IMAGE', 'image/restore/basic'); +define('OG_REST_CMD_RESTORE_INCREMENTAL_IMAGE', 'image/restore/incremental'); define('OG_REST_PARAM_CLIENTS', 'clients'); define('OG_REST_PARAM_ADDR', 'addr'); @@ -374,6 +375,58 @@ function restore_basic_image($string_ips, $params) { common_request(OG_REST_CMD_RESTORE_BASIC_IMAGE, POST, $data); } +function restore_incremental_image($string_ips, $params) { + + preg_match_all('/(?<=\=)[^\r]*(?=\r)?/', $params, $matches); + + $ips = explode(';',$string_ips); + $disk = $matches[0][0]; + $part = $matches[0][1]; + $image_id = $matches[0][2]; + $name = $matches[0][3]; + $repos = $matches[0][4]; + $profile = $matches[0][5]; + $diff_id = $matches[0][6]; + $diff_name = $matches[0][7]; + $path = $matches[0][8]; + $method = $matches[0][9]; + $sync = $matches[0][10]; + $type = $matches[0][11]; + $diff = $matches[0][12]; + $remove = $matches[0][13]; + $compress = $matches[0][14]; + $cleanup = $matches[0][15]; + $cache = $matches[0][16]; + $cleanup_cache = $matches[0][17]; + $remove_dst = $matches[0][18]; + + $data = array(OG_REST_PARAM_CLIENTS => $ips, + OG_REST_PARAM_DISK => $disk, + OG_REST_PARAM_PART => $part, + OG_REST_PARAM_ID => $image_id, + OG_REST_PARAM_NAME => $name, + OG_REST_PARAM_REPOS => $repos, + OG_REST_PARAM_PROFILE => $profile, + OG_REST_PARAM_TYPE => $type, + OG_REST_PARAM_SYNC_PARAMS => array( + OG_REST_PARAM_DIFF_ID => $diff_id, + OG_REST_PARAM_DIFF_NAME => $diff_name, + OG_REST_PARAM_PATH => $path, + OG_REST_PARAM_METHOD => $method, + OG_REST_PARAM_SYNC => $sync, + OG_REST_PARAM_DIFF => $diff, + OG_REST_PARAM_REMOVE => $remove, + OG_REST_PARAM_COMPRESS => $compress, + OG_REST_PARAM_CLEANUP => $cleanup, + OG_REST_PARAM_CACHE => $cache, + OG_REST_PARAM_CLEANUP_CACHE => $cleanup_cache, + OG_REST_PARAM_REMOVE_DST => $remove_dst, + ) + ); + + common_request(OG_REST_CMD_RESTORE_INCREMENTAL_IMAGE, POST, $data); +} + function poweroff($string_ips) { $ips = explode(';',$string_ips); |