summaryrefslogtreecommitdiffstats
path: root/src/ogRest.py
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2020-01-03 11:33:25 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commitcc11d8f38f6a2f9dd46904272808bb25dac042b8 (patch)
treed960a847ec3bef69e2fd4e91ec06f05e23a1ae76 /src/ogRest.py
parentefbe8a7960f5a6f92134fc8b0f4c946a7664a5f0 (diff)
Add restore/image command for restoring images on the machine
ogAdmClient has a support to restore image on the machine. This new command allows the new ogClient to execute the same script to restore the images on the machine. The json format sent from the server must be: { "disk" : "1", "partition" : "1", "name" : "test",\ "repository" : "192.168.56.10", "type" : "UNICAST", "profile": "1", "id": "1"}
Diffstat (limited to 'src/ogRest.py')
-rw-r--r--src/ogRest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ogRest.py b/src/ogRest.py
index 43e3920..7efd7ea 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -54,6 +54,11 @@ class ogThread():
def procsetup(msgqueue, disk, cache, cachesize, partlist):
ogOperations.procsetup(disk, cache, cachesize, partlist)
+ # Process image restore
+ def procirestore(msgqueue, disk, partition, name, repo, ctype, profile, cid):
+ msgqueue.queue.clear()
+ msgqueue.put(ogOperations.procirestore(disk, partition, name, repo, ctype, profile, cid))
+
class ogResponses(Enum):
BAD_REQUEST=0
IN_PROGRESS=1
@@ -109,6 +114,11 @@ class ogRest():
self.process_software(client, httpparser.getDisk(), httpparser.getPartition())
elif ("setup" in URI):
self.process_setup(client, httpparser.getDisk(), httpparser.getCache(), httpparser.getCacheSize(), httpparser.getPartitionSetup())
+ elif ("image/restore" in URI):
+ self.process_irestore(client, httpparser.getDisk(),
+ httpparser.getPartition(), httpparser.getName(),
+ httpparser.getRepo(), httpparser.getType(),
+ httpparser.getProfile(), httpparser.getId())
else:
client.send(self.getResponse(ogResponses.BAD_REQUEST))
else:
@@ -172,3 +182,7 @@ class ogRest():
def process_setup(self, client, disk, cache, cachesize, partlist):
threading.Thread(target=ogThread.procsetup, args=(self.msgqueue, disk, cache, cachesize, partlist,)).start()
client.send(self.getResponse(ogResponses.OK))
+
+ def process_irestore(self, client, disk, partition, name, repo, ctype, profile, cid):
+ threading.Thread(target=ogThread.procirestore, args=(self.msgqueue, disk, partition, name, repo, ctype, profile, cid,)).start()
+ client.send(self.getResponse(ogResponses.OK))