diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2019-10-01 12:01:20 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-10-01 12:56:10 +0200 |
commit | d233fdbaa88ac6473d38c85dddfd663c67020259 (patch) | |
tree | 135d7f11245d8d4b7ad20b85a928542b9efb0520 /admin/WebConsole/includes | |
parent | fc15dd10ce13f7ea9a4e8fa944ebb857223e77f8 (diff) |
#915: Adapt web to use new image/restore cmd in REST API
SocketHidra restaurar imagen has been replaced by POST image/restore.
Diffstat (limited to 'admin/WebConsole/includes')
-rw-r--r-- | admin/WebConsole/includes/restfunctions.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php index 094a3dfd..0321022f 100644 --- a/admin/WebConsole/includes/restfunctions.php +++ b/admin/WebConsole/includes/restfunctions.php @@ -19,6 +19,7 @@ define('OG_REST_CMD_REFRESH', 'refresh'); 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_PARAM_CLIENTS', 'clients'); define('OG_REST_PARAM_ADDR', 'addr'); @@ -32,6 +33,8 @@ define('OG_REST_PARAM_NAME', 'name'); define('OG_REST_PARAM_REPOS', 'repository'); define('OG_REST_PARAM_ID', 'id'); define('OG_REST_PARAM_CODE', 'code'); +define('OG_REST_PARAM_PROFILE', 'profile'); +define('OG_REST_PARAM_TYPE', 'type'); $conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmRepo.cfg'); define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['ApiToken']); @@ -182,6 +185,29 @@ function create_image($string_ips, $params) { common_request(OG_REST_CMD_CREATE_IMAGE, POST, $data); } +function restore_image($string_ips, $params) { + + preg_match_all('/(?<=\=)(.*?)(?=\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]; + $type = $matches[0][6]; + + $data = array(OG_REST_PARAM_DISK => $disk, OG_REST_PARAM_PART => $part, + OG_REST_PARAM_IMAGE_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_CLIENTS => $ips); + + common_request(OG_REST_CMD_RESTORE_IMAGE, POST, $data); +} + function poweroff($string_ips) { $ips = explode(';',$string_ips); |