summaryrefslogtreecommitdiffstats
path: root/src/ogRest.py
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2020-01-16 20:14:40 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commitb5e182f7dd6e99b68de268e52cdc1395d82932ee (patch)
tree2cea53b17d9558dbde34cb34a3d7510bb9198ddf /src/ogRest.py
parentb2fd0b5fffbd60e986eebc03c3a24f06194b4368 (diff)
Add Refresh command
This patch allows us to execute refresh command using ogClient. This command gets all the configuration in our machine and send this information to the server. The format of the message that ogClient will send to the server will be: {"disk": "1", "partition_setup": [{"partition": "1", "code": "LINUX", "filesystem": "NTFS", "size": "498688", "format": "0"}, {"partition": "2", "code": "LINUX", "filesystem": "NTFS", "size": "498688", "format": "0"}, {"partition": "3", "code": "LINUX", "filesystem": "NTFS", "size": "498688", "format": "0"}]}
Diffstat (limited to 'src/ogRest.py')
-rw-r--r--src/ogRest.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ogRest.py b/src/ogRest.py
index 011f77e..dfd2930 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -165,6 +165,20 @@ class ogThread():
jsonResp.addElement('software', lines[0])
client.send(restResponse.getResponse(ogResponses.OK, jsonResp))
+ # Process refresh
+ def procrefresh(client, ogRest):
+ try:
+ out = ogOperations.procrefresh(ogRest)
+ except ValueError as err:
+ client.send(restResponse.getResponse(ogResponses.INTERNAL_ERR))
+ return
+
+ jsonResp = jsonResponse()
+ jsonResp.addElement('disk', out[0])
+ jsonResp.addElement('partition_setup', out[1])
+
+ client.send(restResponse.getResponse(ogResponses.OK, jsonResp))
+
class ogResponses(Enum):
BAD_REQUEST=0
IN_PROGRESS=1
@@ -213,6 +227,8 @@ class ogRest():
self.process_stop(client)
elif ("image/create" in URI):
self.process_icreate(client, httpparser)
+ elif ("refresh" in URI):
+ self.process_refresh(client)
else:
client.send(restResponse.getResponse(ogResponses.BAD_REQUEST))
else:
@@ -271,3 +287,6 @@ class ogRest():
def process_icreate(self, client, httpparser):
path = '/tmp/CSft-' + client.ip + '-' + httpparser.getPartition()
threading.Thread(target=ogThread.procicreate, args=(client, path, httpparser, self,)).start()
+
+ def process_refresh(self, client):
+ threading.Thread(target=ogThread.procrefresh, args=(client, self,)).start()