#915 Adapt web to use new image/create/basic cmd in REST API
SocketHidra command has been replaced by POST image/create/basic.configfile
parent
8bf781d421
commit
488b14701e
|
@ -31,6 +31,7 @@ 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_CREATE_BASIC_IMAGE', 12);
|
||||
define('OG_CMD_ID_SENDMESSAGE', 16);
|
||||
|
||||
// Recoge parametros de seguimiento
|
||||
|
@ -138,6 +139,9 @@ switch ($idcomando) {
|
|||
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_POWEROFF:
|
||||
poweroff($cadenaip);
|
||||
break;
|
||||
|
@ -217,6 +221,7 @@ if($sw_ejya=='on' || $sw_ejprg=="on" ){
|
|||
$idcomando != OG_CMD_ID_RESTORE_IMAGE &&
|
||||
$idcomando != OG_CMD_ID_SETUP &&
|
||||
$idcomando != OG_CMD_ID_SESSION &&
|
||||
$idcomando != OG_CMD_ID_CREATE_BASIC_IMAGE &&
|
||||
$idcomando != OG_CMD_ID_POWEROFF &&
|
||||
$idcomando != OG_CMD_ID_HARDWARE &&
|
||||
$idcomando != OG_CMD_ID_SOFTWARE &&
|
||||
|
|
|
@ -21,6 +21,7 @@ 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_CMD_CREATE_BASIC_IMAGE', 'image/create/basic');
|
||||
|
||||
define('OG_REST_PARAM_CLIENTS', 'clients');
|
||||
define('OG_REST_PARAM_ADDR', 'addr');
|
||||
|
@ -43,7 +44,15 @@ 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');
|
||||
|
||||
define('OG_REST_PARAM_SYNC_PARAMS', 'sync_params');
|
||||
define('OG_REST_PARAM_SYNC', 'sync');
|
||||
define('OG_REST_PARAM_DIFF', 'diff');
|
||||
define('OG_REST_PARAM_REMOVE', 'remove');
|
||||
define('OG_REST_PARAM_COMPRESS', 'compress');
|
||||
define('OG_REST_PARAM_CLEANUP', 'cleanup');
|
||||
define('OG_REST_PARAM_CACHE', 'cache');
|
||||
define('OG_REST_PARAM_CLEANUP_CACHE', 'cleanup_cache');
|
||||
define('OG_REST_PARAM_REMOVE_DST', 'remove_dst');
|
||||
|
||||
$conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmRepo.cfg');
|
||||
define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['ApiToken']);
|
||||
|
@ -217,6 +226,51 @@ function restore_image($string_ips, $params) {
|
|||
common_request(OG_REST_CMD_RESTORE_IMAGE, POST, $data);
|
||||
}
|
||||
|
||||
function create_basic_image($string_ips, $params) {
|
||||
|
||||
preg_match_all('/(?<=\=)[^\r]*(?=\r)?/', $params, $matches);
|
||||
|
||||
$ips = explode(';',$string_ips);
|
||||
$disk = $matches[0][0];
|
||||
$part = $matches[0][1];
|
||||
$code = $matches[0][2];
|
||||
$image_id = $matches[0][3];
|
||||
$name = $matches[0][4];
|
||||
$repos = $matches[0][5];
|
||||
|
||||
$sync = $matches[0][7]; // Syncronization method
|
||||
|
||||
$diff = $matches[0][8]; // Send the whole file if there are differences
|
||||
$remove = $matches[0][9]; // Delete files at destination that are not at source
|
||||
$compress = $matches[0][10]; // Compress before sending
|
||||
|
||||
$cleanup = $matches[0][11]; // Delete image before creating it
|
||||
$cache = $matches[0][12]; // Copy image to cache
|
||||
$cleanup_cache = $matches[0][13]; // Delete image from cache before copying
|
||||
$remove_dst = $matches[0][14]; // Dont delete files in destination
|
||||
|
||||
$data = array(OG_REST_PARAM_CLIENTS => $ips,
|
||||
OG_REST_PARAM_DISK => $disk,
|
||||
OG_REST_PARAM_PART => $part,
|
||||
OG_REST_PARAM_CODE => $code,
|
||||
OG_REST_PARAM_ID => $image_id,
|
||||
OG_REST_PARAM_NAME => $name,
|
||||
OG_REST_PARAM_REPOS => $repos,
|
||||
OG_REST_PARAM_SYNC_PARAMS => array(
|
||||
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_CREATE_BASIC_IMAGE, POST, $data);
|
||||
}
|
||||
|
||||
function poweroff($string_ips) {
|
||||
|
||||
$ips = explode(';',$string_ips);
|
||||
|
|
Loading…
Reference in New Issue