summaryrefslogtreecommitdiffstats
path: root/src/ogRest.py
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2020-01-02 19:48:14 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commit2fa8aa4ff7deaf92c5b69be0c69fee95ce18ac37 (patch)
tree9c82dcd20ce3ddda5b8a1ba0e7edcbd9e91cba4e /src/ogRest.py
parentf566579f8e79eee8e51bab70eae91d705f2f2d00 (diff)
Add session command to init the opengnsys session
ogAdmClient has a support for initializing the session in the machine. This new command allows the new ogClient to execute the same script to init the session. The arguments will be received from the server as a json message. Format: { "disk" : "0", "partition" : "1"}
Diffstat (limited to 'src/ogRest.py')
-rw-r--r--src/ogRest.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ogRest.py b/src/ogRest.py
index 1e60495..07a5052 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -5,6 +5,8 @@ from enum import Enum
import json
import queue
+from src.HTTPParser import *
+
if platform.system() == 'Linux':
from src.linux import ogOperations
@@ -33,6 +35,11 @@ class ogThread():
def reboot():
ogOperations.reboot()
+ # Process session
+ def procsession(msgqueue, disk, partition):
+ msgqueue.queue.clear()
+ msgqueue.put(ogOperations.procsession(disk, partition))
+
class ogResponses(Enum):
BAD_REQUEST=0
IN_PROGRESS=1
@@ -61,7 +68,9 @@ class ogRest():
msg = msg + '\r\n\r\n'
return msg
- def processOperation(self, op, URI, cmd, client):
+ def processOperation(self, httpparser, client):
+ op = httpparser.getRequestOP()
+ URI = httpparser.getURI()
if ("GET" in op):
if ("probe" in URI):
self.process_probe(client)
@@ -75,7 +84,9 @@ class ogRest():
elif ("reboot" in URI):
self.process_reboot(client)
elif ("shell/run" in URI):
- self.process_shellrun(client, cmd)
+ self.process_shellrun(client, httpparser.getCMD())
+ elif ("session" in URI):
+ self.process_session(client, httpparser.getDisk(), httpparser.getPartition())
else:
client.send(self.getResponse(ogResponses.BAD_REQUEST))
else:
@@ -118,3 +129,7 @@ class ogRest():
else:
jsonResp.addElement('out', self.msgqueue.get())
client.send(self.getResponse(ogResponses.OK, jsonResp))
+
+ def process_session(self, client, disk, partition):
+ threading.Thread(target=ogThread.procsession, args=(self.msgqueue, disk, partition,)).start()
+ client.send(self.getResponse(ogResponses.OK))