Fix /setup execution and response

more_events
Roberto Hueso Gómez 2020-01-31 13:19:41 +01:00 committed by Alvaro Neira Ayuso
parent e96e187825
commit 2934773d88
2 changed files with 17 additions and 16 deletions

View File

@ -107,20 +107,27 @@ def setup(request, ogRest):
cachesize = request.getCacheSize()
partlist = request.getPartitionSetup()
listConfigs = []
cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!'
for part in partlist:
cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!par=' + part["partition"] + '*cpt='+part["code"] + '*sfi=' + part['filesystem'] + '*tam=' + part['size'] + '*ope=' + part['format'] + '%'
cfg += 'par=' + part["partition"] + '*cpt='+part["code"] + \
'*sfi=' + part['filesystem'] + '*tam=' + \
part['size'] + '*ope=' + part['format'] + '%'
if ogRest.terminated:
break
try:
ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], stdout=subprocess.PIPE, shell=True)
(output, error) = ogRest.proc.communicate()
except:
continue
cmd = OG_PATH + 'interfaceAdm/Configurar' + " " + disk + " " + cfg
try:
ogRest.proc = subprocess.Popen([cmd],
stdout=subprocess.PIPE,
shell=True)
(output, error) = ogRest.proc.communicate()
except:
raise ValueError('Error: Incorrect command value')
result = subprocess.check_output([OG_PATH + 'interfaceAdm/getConfiguration'], shell=True)
return parseGetConf(result.decode('utf-8'))[1]
cmd_get_conf = OG_PATH + 'interfaceAdm/getConfiguration'
result = subprocess.check_output([cmd_get_conf], shell=True)
return parseGetConf(result.decode('utf-8'))
def image_restore(request, ogRest):
disk = request.getDisk()

View File

@ -142,20 +142,14 @@ class ogThread():
client.send(response.get())
def setup(client, request, ogRest):
listconfig = []
try:
listconfig = ogOperations.setup(request, ogRest)
out = ogOperations.setup(request, ogRest)
except ValueError as err:
response = restResponse(ogResponses.INTERNAL_ERR)
client.send(response.get())
return
jsonResp = jsonResponse()
jsonResp.addElement('disk', request.getDisk())
jsonResp.addElement('cache', request.getCache())
jsonResp.addElement('cache_size', request.getCacheSize())
jsonResp.addElement('partition_setup', listconfig)
jsonResp = jsonResponse(out)
response = restResponse(ogResponses.OK, jsonResp)
client.send(response.get())