mirror of https://git.48k.eu/ogclient
Catch execution errors during restore image command
This patch allows us to send feedback to the server in case of error during the execution of the command. In case of error, ogClient will send an "Internal Error" http message.more_events
parent
1ced3dd069
commit
a306b8b9d8
|
@ -74,5 +74,9 @@ def procirestore(httpparser):
|
|||
profile = httpparser.getProfile()
|
||||
cid = httpparser.getId()
|
||||
|
||||
try:
|
||||
result = subprocess.check_output([OG_PATH + 'interfaceAdm/RestaurarImagen', disk, partition, name, repo, ctype], shell=True)
|
||||
except:
|
||||
raise ValueError('Error: Incorrect command value')
|
||||
|
||||
return result.decode('utf-8')
|
||||
|
|
|
@ -106,9 +106,14 @@ class ogThread():
|
|||
ogOperations.procsetup(httpparser)
|
||||
|
||||
# Process image restore
|
||||
def procirestore(msgqueue, httpparser):
|
||||
msgqueue.queue.clear()
|
||||
msgqueue.put(ogOperations.procirestore(httpparser))
|
||||
def procirestore(httpparser):
|
||||
try:
|
||||
ogOperations.procirestore(httpparser)
|
||||
except ValueError as err:
|
||||
client.send(restResponse.getResponse(ogResponses.INTERNAL_ERR))
|
||||
return
|
||||
|
||||
client.send(restResponse.getResponse(ogResponses.OK))
|
||||
|
||||
class ogResponses(Enum):
|
||||
BAD_REQUEST=0
|
||||
|
@ -211,5 +216,4 @@ class ogRest():
|
|||
client.send(restResponse.getResponse(ogResponses.OK))
|
||||
|
||||
def process_irestore(self, client, httpparser):
|
||||
threading.Thread(target=ogThread.procirestore, args=(self.msgqueue, httpparser,)).start()
|
||||
client.send(restResponse.getResponse(ogResponses.OK))
|
||||
threading.Thread(target=ogThread.procirestore, args=(client, httpparser,)).start()
|
||||
|
|
Loading…
Reference in New Issue