summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/rest/remotepc.php
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2017-11-06 11:43:49 +0000
committerramon <ramongomez@us.es>2017-11-06 11:43:49 +0000
commit23b08a86ad83aab973f9bc85bcb3cd9f5f36dd46 (patch)
tree57ff6eb762b269ced12113c46221468bd6322f28 /admin/WebConsole/rest/remotepc.php
parent50aa7a79f0fc61e84c24bc312ed2a8a1ed38014d (diff)
#708: Cambiar política de asignación a recurso no disponible si {{{deadLine}}} es 0 en ruta REST {{{ous/:ouid/labs/:labid/clients/:clntid/session}}} y corregir errata en mensaje de log.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5498 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/remotepc.php')
-rw-r--r--admin/WebConsole/rest/remotepc.php29
1 files changed, 13 insertions, 16 deletions
diff --git a/admin/WebConsole/rest/remotepc.php b/admin/WebConsole/rest/remotepc.php
index d09d7c2e..030ba37d 100644
--- a/admin/WebConsole/rest/remotepc.php
+++ b/admin/WebConsole/rest/remotepc.php
@@ -365,6 +365,9 @@ $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) {
+ throw new Exception("Resource unavailable");
+ }
} catch (Exception $e) {
// Error message.
$response["message"] = $e->getMessage();
@@ -415,22 +418,16 @@ EOD;
# Add reminder 5 min. before deadline.
$cmd->texto .= " ($clntid, NOW() + INTERVAL $deadLine SECOND - INTERVAL 5 MINUTE, 'popup-5'),";
}
- # Add power off command at deadline time (0=unlimited).
- if ($deadLine > 0) {
- $cmd->texto .= " ($clntid, NOW() + INTERVAL $deadLine SECOND, 'poweroff');";
- if ($cmd->Ejecutar()) {
- // Confirm operation.
- $response = "";
- jsonResponse(200, $response);
- } else {
- // Error message.
- $response["message"] = "Database error";
- jsonResponse(400, $response);
- }
- } else {
- // Unlimited time, do nothing.
+ # Add power off command at deadline time.
+ $cmd->texto .= " ($clntid, NOW() + INTERVAL $deadLine SECOND, 'poweroff');";
+ if ($cmd->Ejecutar()) {
+ // Confirm operation.
$response = "";
jsonResponse(200, $response);
+ } else {
+ // Error message.
+ $response["message"] = "Database error";
+ jsonResponse(400, $response);
}
} else {
// Error message.
@@ -528,10 +525,10 @@ EOD;
$cmd->texto = "COMMIT;";
$cmd->Ejecutar();
// Send a poweroff command to client's OGAgent.
- if ($app->settings['debug'])
- writeRemotepcLog($app->request()->getResourceUri(). ": OGAgent poweroff, url=".$ogagent[$clntip]['url'].".");
$ogagent[$clntip]['url'] = "https://$clntip:8000/opengnsys/poweroff";
$ogagent[$clntip]['header'] = Array("Authorization: ".$agentkey);
+ if ($app->settings['debug'])
+ writeRemotepcLog($app->request()->getResourceUri(). ": OGAgent poweroff, url=".$ogagent[$clntip]['url'].".");
$result = multiRequest($ogagent);
// ... (check response)
//if ($result[$clntip]['code'] != 200) {