From 69fd9c1714660848714351e95a7f28aee115c723 Mon Sep 17 00:00:00 2001 From: Irina Gómez Date: Tue, 23 Feb 2021 12:21:01 +0100 Subject: #992 REST route /ous/:ouid/labs/:labid/clients/:clntid/init: Fixes that include global variables, required to add the operating system startup to the action queue. This route is defined in swagger. --- admin/WebConsole/rest/opengnsys-api.yml | 29 +++++++++++++++++++++++++++++ admin/WebConsole/rest/remotepc.php | 10 +++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/admin/WebConsole/rest/opengnsys-api.yml b/admin/WebConsole/rest/opengnsys-api.yml index bea6cae2..b63af11a 100644 --- a/admin/WebConsole/rest/opengnsys-api.yml +++ b/admin/WebConsole/rest/opengnsys-api.yml @@ -662,6 +662,35 @@ paths: - server - client - remotepc + /ous/{ouid}/labs/{labid}/clients/{clientid}/init: + post: + description: Send an init operation to a client with an image installed. + parameters: + - $ref: "#/parameters/ouParam" + - $ref: "#/parameters/labParam" + - $ref: "#/parameters/clientParam" + - name: data + in: body + description: Image identificator + required: true + schema: + type: object + properties: + image: + description: Operating System Image Identifier + type: integer + format: int64 + minimum: 0 + required: [ image ] + responses: + "200": + description: Successful response + security: + - apikey: [] + tags: + - server + - client + - remotepc /ous/{ouid}/labs/{labid}/clients/{clientid}/session: post: description: Record session data for a client diff --git a/admin/WebConsole/rest/remotepc.php b/admin/WebConsole/rest/remotepc.php index c3b4fe7c..a7f50d2d 100644 --- a/admin/WebConsole/rest/remotepc.php +++ b/admin/WebConsole/rest/remotepc.php @@ -573,6 +573,12 @@ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/init', 'validateApiKey', function($ouid, $labid, $clntid) use ($app) { global $cmd; global $userid; + global $AMBITO_ORDENADORES; + global $EJECUCION_COMANDO; + global $ACCION_INICIADA; + global $ACCION_FINALIZADA; + global $ACCION_SINRESULTADO; + global $ACCION_FALLIDA; if ($app->settings['debug']) writeRemotepcLog("{$app->request()->getResourceUri()}: Init."); @@ -587,6 +593,7 @@ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/init', 'validateApiKey', // Reading POST parameters in JSON format. $input = json_decode($app->request()->getBody()); $imageid = $input->image ?? 0; + $opts = Array('options' => Array('min_range' => 1)); // Check for int>0 if (filter_var($imageid, FILTER_VALIDATE_INT, $opts) === false) { throw new Exception("Image id. must be positive integer"); } @@ -601,7 +608,7 @@ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/init', 'validateApiKey', // Select data to init a session. $cmd->texto = <<texto = <<