summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2019-10-07 10:57:24 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2019-10-07 11:15:36 +0200
commitc857bed55d2e7a4dad019ccc2d9a21b64fd73e40 (patch)
tree717d9cd3645778b6e4dadb4ae4ed53f3e9ebe216
parent8b1c92b1acf5b10b5dda9829de4773b4a1590dc7 (diff)
Adapt web to use new image/setup cmd in REST API
SocketHidra configurar has been replaced by POST image/setup.
-rw-r--r--admin/WebConsole/comandos/gestores/gestor_Comandos.php5
-rw-r--r--admin/WebConsole/includes/restfunctions.php53
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 b320d9cd..8ed77d01 100644
--- a/admin/WebConsole/comandos/gestores/gestor_Comandos.php
+++ b/admin/WebConsole/comandos/gestores/gestor_Comandos.php
@@ -30,6 +30,7 @@ define('OG_CMD_ID_HARDWARE', 6);
define('OG_CMD_ID_SOFTWARE', 7);
define("OG_CMD_ID_SCRIPT", 8);
define('OG_CMD_ID_SESSION', 9);
+define('OG_CMD_ID_SETUP', 10);
define('OG_CMD_ID_SENDMESSAGE', 16);
// Recoge parametros de seguimiento
@@ -131,6 +132,9 @@ 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;
@@ -211,6 +215,7 @@ if($sw_ejya=='on' || $sw_ejprg=="on" ){
$idcomando != OG_CMD_ID_WAKEUP &&
$idcomando != OG_CMD_ID_CREATE_IMAGE &&
$idcomando != OG_CMD_ID_RESTORE_IMAGE &&
+ $idcomando != OG_CMD_ID_SETUP &&
$idcomando != OG_CMD_ID_SESSION &&
$idcomando != OG_CMD_ID_POWEROFF &&
$idcomando != OG_CMD_ID_HARDWARE &&
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php
index 3f71eff6..7a56a1e7 100644
--- a/admin/WebConsole/includes/restfunctions.php
+++ b/admin/WebConsole/includes/restfunctions.php
@@ -20,6 +20,7 @@ define('OG_REST_CMD_HARDWARE', 'hardware');
define('OG_REST_CMD_SOFTWARE', 'software');
define('OG_REST_CMD_CREATE_IMAGE', 'image/create');
define('OG_REST_CMD_RESTORE_IMAGE', 'image/restore');
+define('OG_REST_CMD_SETUP', 'image/setup');
define('OG_REST_PARAM_CLIENTS', 'clients');
define('OG_REST_PARAM_ADDR', 'addr');
@@ -35,6 +36,14 @@ define('OG_REST_PARAM_ID', 'id');
define('OG_REST_PARAM_CODE', 'code');
define('OG_REST_PARAM_PROFILE', 'profile');
define('OG_REST_PARAM_TYPE', 'type');
+define('OG_REST_PARAM_CACHE', 'cache');
+define('OG_REST_PARAM_CACHE_SIZE', 'cache_size');
+define('OG_REST_PARAM_CODE', 'code');
+define('OG_REST_PARAM_FILE_SYSTEM', 'filesystem');
+define('OG_REST_PARAM_SIZE', 'size');
+define('OG_REST_PARAM_FORMAT', 'format');
+define('OG_REST_PARAM_PARTITION_SETUP', 'partition_setup');
+
$conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmRepo.cfg');
define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['ApiToken']);
@@ -262,6 +271,50 @@ function software($string_ips) {
common_request(OG_REST_CMD_SOFTWARE, POST, $data);
}
+function setup($string_ips, $params) {
+
+ preg_match_all('/(?<=\=)(?!dis)(.*?)((?=\*)|(?=\r)|(?=\!)|(?=\%))/',
+ $params, $matches);
+
+ $ips = explode(';',$string_ips);
+ $disk = $matches[0][0];
+ $cache = $matches[0][2];
+ $cache_size = $matches[0][3];
+ $partition_number = array();
+ $partition_code = array();
+ $file_system = array();
+ $part_size = array();
+ $format = array();
+ for ($x = 0; $x < 4; $x++) {
+ $partition_number[$x] = $matches[0][4 + 5 * $x];
+ $partition_code[$x] = $matches[0][5 + 5 * $x];
+ $file_system[$x] = $matches[0][6 + 5 * $x];
+ $part_size[$x] = $matches[0][7 + 5 * $x];
+ $format[$x] = $matches[0][8 + 5 * $x];
+ }
+
+ $data = array(
+ OG_REST_PARAM_CLIENTS => $ips,
+ OG_REST_PARAM_DISK => $disk,
+ OG_REST_PARAM_CACHE => $cache,
+ OG_REST_PARAM_CACHE_SIZE => $cache_size,
+ OG_REST_PARAM_PARTITION_SETUP => array()
+ );
+
+ for ($i = 0; $i < sizeof($partition_number); $i++) {
+ $partition_setup = array(
+ OG_REST_PARAM_PART => $partition_number[$i],
+ OG_REST_PARAM_CODE => $partition_code[$i],
+ OG_REST_PARAM_FILE_SYSTEM => $file_system[$i],
+ OG_REST_PARAM_SIZE => $part_size[$i],
+ OG_REST_PARAM_FORMAT => $format[$i]
+ );
+ array_push($data[OG_REST_PARAM_PARTITION_SETUP], $partition_setup);
+ }
+
+ common_request(OG_REST_CMD_SETUP, POST, $data);
+}
+
/*
* @function multiRequest.
* @param URLs array (may include header and POST data), cURL options array.