summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2018-04-30 08:58:05 +0000
committerramon <ramongomez@us.es>2018-04-30 08:58:05 +0000
commit51863fa7b053fcfa1a176fd7e7f66b175d1f906c (patch)
tree0b269b8c5da06c04a1cdfafba66fe1511e16109a
parentf5a42078cbeb725d4fb2737acf2f8fc59a5a4af1 (diff)
#839: Correción en API REST para RemotePC: permitir sesión ilimitada si parámetro {{{deadLine=0}}}.
git-svn-id: https://opengnsys.es/svn/trunk@5763 a21b9725-9963-47de-94b9-378ad31fedc9
-rw-r--r--admin/WebConsole/rest/opengnsys-api.yml10
-rw-r--r--admin/WebConsole/rest/remotepc.php11
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);