From 1d7cae39b7f26b9fabbcec707cde9237a9f671fc Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Thu, 12 Aug 2021 16:56:48 +0200 Subject: [PATCH] Activated restart and shutdown in http_system endpoint -> shoud be transferred to system_controller at a later point of time --- cbpi/http_endpoints/http_system.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cbpi/http_endpoints/http_system.py b/cbpi/http_endpoints/http_system.py index 8a05bab..f3366c9 100644 --- a/cbpi/http_endpoints/http_system.py +++ b/cbpi/http_endpoints/http_system.py @@ -1,6 +1,7 @@ from aiohttp import web from cbpi.job.aiohttp import get_scheduler_from_app - +import logging +import os from cbpi.api import request_mapping from cbpi.utils import json_dumps from cbpi import __version__ @@ -84,7 +85,7 @@ class SystemHttpEndpoints: return web.json_response(data=result) @request_mapping("/restart", method="POST", name="RestartServer", auth_required=False) - def restart(self, request): + async def restart(self, request): """ --- description: Restart System - Not implemented @@ -94,10 +95,13 @@ class SystemHttpEndpoints: "200": description: successful operation """ + logging.info("RESTART") + os.system('systemctl reboot') + pass return web.Response(text="NOT IMPLEMENTED") @request_mapping("/shutdown", method="POST", name="ShutdownSerer", auth_required=False) - def shutdown(self, request): + async def shutdown(self, request): """ --- description: Shutdown System - Not implemented @@ -107,4 +111,7 @@ class SystemHttpEndpoints: "200": description: successful operation """ - return web.Response(text="NOT IMPLEMENTED") \ No newline at end of file + logging.info("SHUTDOWN") + os.system('systemctl poweroff') + pass + return web.Response(text="NOT IMPLEMENTED")