Fix /image/create execution and response

more_events
Roberto Hueso Gómez 2020-02-05 12:39:04 +01:00 committed by Alvaro Neira Ayuso
parent 834f5cd5c2
commit 680214317e
2 changed files with 12 additions and 7 deletions

View File

@ -151,9 +151,15 @@ def image_create(path, request, ogRest):
partition = request.getPartition() partition = request.getPartition()
name = request.getName() name = request.getName()
repo = request.getRepo() repo = request.getRepo()
cmd_software = f'{OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
f'{partition} {path}'
cmd_create_image = f'{OG_PATH}interfaceAdm/CrearImagen {disk} ' \
f'{partition} {name} {repo}'
try: try:
ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/InventarioSoftware', disk, partition, path], stdout=subprocess.PIPE, shell=True) ogRest.proc = subprocess.Popen([cmd_software],
stdout=subprocess.PIPE,
shell=True)
(output, error) = ogRest.proc.communicate() (output, error) = ogRest.proc.communicate()
except: except:
raise ValueError('Error: Incorrect command value') raise ValueError('Error: Incorrect command value')
@ -162,7 +168,9 @@ def image_create(path, request, ogRest):
return return
try: try:
ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/CrearImagen', disk, partition, name, repo], stdout=subprocess.PIPE, shell=True) ogRest.proc = subprocess.Popen([cmd_create_image],
stdout=subprocess.PIPE,
shell=True)
ogRest.proc.communicate() ogRest.proc.communicate()
except: except:
raise ValueError('Error: Incorrect command value') raise ValueError('Error: Incorrect command value')

View File

@ -113,7 +113,6 @@ class ogThread():
return return
jsonResp = jsonResponse() jsonResp = jsonResponse()
jsonResp.addElement('disk', request.getDisk())
jsonResp.addElement('partition', request.getPartition()) jsonResp.addElement('partition', request.getPartition())
f = open(path, "r") f = open(path, "r")
@ -180,10 +179,8 @@ class ogThread():
jsonResp.addElement('id', request.getId()) jsonResp.addElement('id', request.getId())
jsonResp.addElement('name', request.getName()) jsonResp.addElement('name', request.getName())
jsonResp.addElement('repository', request.getRepo()) jsonResp.addElement('repository', request.getRepo())
f = open(path, "r") with open(path, 'r') as f:
lines = f.readlines() jsonResp.addElement('software', f.read())
f.close()
jsonResp.addElement('software', lines[0])
response = restResponse(ogResponses.OK, jsonResp) response = restResponse(ogResponses.OK, jsonResp)
client.send(response.get()) client.send(response.get())