From 51863fa7b053fcfa1a176fd7e7f66b175d1f906c Mon Sep 17 00:00:00 2001 From: ramon Date: Mon, 30 Apr 2018 08:58:05 +0000 Subject: #839: Correción en API REST para RemotePC: permitir sesión ilimitada si parámetro {{{deadLine=0}}}. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://opengnsys.es/svn/trunk@5763 a21b9725-9963-47de-94b9-378ad31fedc9 --- admin/WebConsole/rest/opengnsys-api.yml | 10 ++++++---- admin/WebConsole/rest/remotepc.php | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/admin/WebConsole/rest/opengnsys-api.yml b/admin/WebConsole/rest/opengnsys-api.yml index 0c9575a2..fcd4961f 100644 --- a/admin/WebConsole/rest/opengnsys-api.yml +++ b/admin/WebConsole/rest/opengnsys-api.yml @@ -668,10 +668,12 @@ paths: schema: type: object properties: - logoutAt: - description: Time to send a logout operation to the client - type: string - format: date-time + deadLine: + description: Maximum session time, in seconds (0 for unlimited) + type: integer + format: int64 + minimum: 0 + required: [ deadLine ] responses: "200": description: Successful response diff --git a/admin/WebConsole/rest/remotepc.php b/admin/WebConsole/rest/remotepc.php index 98166391..39224636 100644 --- a/admin/WebConsole/rest/remotepc.php +++ b/admin/WebConsole/rest/remotepc.php @@ -340,7 +340,7 @@ EOD; /* * @brief Store session time (in sec). * @note Route: /ous/:ouid/labs/:labid/clients/:clntid/session, Method: POST - * @param int deadLine maximum time session (in seconds) + * @param int deadLine maximum session time, in seconds (0 for unlimited) * @warning Parameters will be stored in a new "remotepc" table. */ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/session', 'validateApiKey', @@ -365,7 +365,7 @@ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/session', 'validateApiKey', if (filter_var($deadLine, FILTER_VALIDATE_INT) === false) { throw new Exception("Deadline must be integer"); } - if ($deadLine <= 0) { + if ($deadLine < 0) { throw new Exception("Resource unavailable"); } } catch (Exception $e) { @@ -420,11 +420,12 @@ EOD; } # Add power off command at deadline time. $cmd->texto .= " ($clntid, NOW() + INTERVAL $deadLine SECOND, 'poweroff');"; - if ($cmd->Ejecutar()) { + if ($deadLine == 0 or $cmd->Ejecutar()) { // Confirm operation. + $cmd->texto = ""; $response = ""; jsonResponse(200, $response); - } else { + } else { // Error message. $response["message"] = "Database error"; jsonResponse(400, $response); @@ -434,7 +435,7 @@ EOD; $response["message"] = "Client is not reserved"; jsonResponse(400, $response); } - } else { + } else { // Error message. $response["message"] = "Client does not exist"; jsonResponse(404, $response); -- cgit v1.2.3-18-g5258