From 1c9a13cd968559f89ba6b114c978eeb8c9629bed Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Fri, 21 Jun 2024 14:59:22 +0200 Subject: rest: add cmd field to POST /shell/run echo command that has been run for storage in ogserver, until GET /shell/output is invoked. --- src/live/ogOperations.py | 2 +- src/ogRest.py | 3 ++- src/virtual/ogOperations.py | 2 +- src/windows/ogOperations.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index cadd0af..a3997b3 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -297,7 +297,7 @@ class OgLiveOperations: self.refresh(ogRest) - return (ogRest.proc.returncode, output.decode('utf-8')) + return (ogRest.proc.returncode, " ".join(cmds), output.decode('utf-8')) def session(self, request, ogRest): disk = request.getDisk() diff --git a/src/ogRest.py b/src/ogRest.py index e7b9d95..8e90842 100644 --- a/src/ogRest.py +++ b/src/ogRest.py @@ -92,13 +92,14 @@ class ogThread(): return try: - (retcode, shellout) = ogRest.operations.shellrun(request, ogRest) + (retcode, cmd, shellout) = ogRest.operations.shellrun(request, ogRest) except Exception as e: ogRest.send_internal_server_error(client, exc=e) return if request.getEcho(): json_body = jsonBody() + json_body.add_element('cmd', cmd) json_body.add_element('out', shellout) json_body.add_element('retcode', retcode) response = restResponse(ogResponses.OK, json_body, seq=client.seq) diff --git a/src/virtual/ogOperations.py b/src/virtual/ogOperations.py index 003ec3d..34ba9fd 100644 --- a/src/virtual/ogOperations.py +++ b/src/virtual/ogOperations.py @@ -240,7 +240,7 @@ class OgVirtualOperations: self.poweroff_host() def shellrun(self, request, ogRest): - return (0, "") + return (0, "", "") def session(self, request, ogRest): disk = request.getDisk() diff --git a/src/windows/ogOperations.py b/src/windows/ogOperations.py index bf35bff..d0230eb 100644 --- a/src/windows/ogOperations.py +++ b/src/windows/ogOperations.py @@ -93,7 +93,7 @@ class OgWindowsOperations: if error.stdout: return error.stdout return "{Non zero exit code and empty output}" - return (result.returncode, result.stdout) + return (result.returncode, cmd, result.stdout) def session(self, request, ogRest): raise NotImplementedError -- cgit v1.2.3-18-g5258