summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/HTTPParser.py14
-rw-r--r--src/linux/ogOperations.py4
-rw-r--r--src/ogClient.py2
-rw-r--r--src/ogRest.py19
4 files changed, 36 insertions, 3 deletions
diff --git a/src/HTTPParser.py b/src/HTTPParser.py
index 912a7cf..1a3d7be 100644
--- a/src/HTTPParser.py
+++ b/src/HTTPParser.py
@@ -13,6 +13,8 @@ class HTTPParser:
self.operation = None
self.URI = None
self.cmd = None
+ self.partition = None
+ self.disk = None
def parser(self,data):
self.requestLine, self.headersAlone = data.split('\n', 1)
@@ -43,6 +45,12 @@ class HTTPParser:
if "run" in cmd:
self.cmd = jsoncmd["run"]
+ if "disk" in cmd:
+ self.disk = jsoncmd["disk"]
+
+ if "partition" in cmd:
+ self.partition = jsoncmd["partition"]
+
def getHeaderLine(self):
return self.headersAlone
@@ -69,3 +77,9 @@ class HTTPParser:
def getCMD(self):
return self.cmd
+
+ def getDisk(self):
+ return self.disk
+
+ def getPartition(self):
+ return self.partition
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py
index 147944f..34ba400 100644
--- a/src/linux/ogOperations.py
+++ b/src/linux/ogOperations.py
@@ -23,3 +23,7 @@ def execCMD(cmd):
raise ValueError('Error: Incorrect command value')
return result.decode('utf-8')
+
+def procsession(disk, partition):
+ result = subprocess.check_output([OG_PATH + 'interfaceAdm/IniciarSesion', disk, partition], shell=True)
+ return result.decode('utf-8')
diff --git a/src/ogClient.py b/src/ogClient.py
index 6aceeaa..4f04e56 100644
--- a/src/ogClient.py
+++ b/src/ogClient.py
@@ -89,7 +89,7 @@ class ogClient:
if self.trailer and len(self.data) >= self.content_len:
httpparser.parser(self.data)
- self.ogrest.processOperation(httpparser.getRequestOP(), httpparser.getURI(), httpparser.getCMD(), self)
+ self.ogrest.processOperation(httpparser, self)
# Cleanup state information from request
self.data = ""
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))