mirror of https://git.48k.eu/ogclient
Fix /setup execution and response
parent
e96e187825
commit
2934773d88
|
@ -107,20 +107,27 @@ def setup(request, ogRest):
|
||||||
cachesize = request.getCacheSize()
|
cachesize = request.getCacheSize()
|
||||||
partlist = request.getPartitionSetup()
|
partlist = request.getPartitionSetup()
|
||||||
listConfigs = []
|
listConfigs = []
|
||||||
|
cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!'
|
||||||
|
|
||||||
for part in partlist:
|
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:
|
if ogRest.terminated:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
cmd = OG_PATH + 'interfaceAdm/Configurar' + " " + disk + " " + cfg
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], stdout=subprocess.PIPE, shell=True)
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
shell=True)
|
||||||
(output, error) = ogRest.proc.communicate()
|
(output, error) = ogRest.proc.communicate()
|
||||||
except:
|
except:
|
||||||
continue
|
raise ValueError('Error: Incorrect command value')
|
||||||
|
|
||||||
result = subprocess.check_output([OG_PATH + 'interfaceAdm/getConfiguration'], shell=True)
|
cmd_get_conf = OG_PATH + 'interfaceAdm/getConfiguration'
|
||||||
return parseGetConf(result.decode('utf-8'))[1]
|
result = subprocess.check_output([cmd_get_conf], shell=True)
|
||||||
|
return parseGetConf(result.decode('utf-8'))
|
||||||
|
|
||||||
def image_restore(request, ogRest):
|
def image_restore(request, ogRest):
|
||||||
disk = request.getDisk()
|
disk = request.getDisk()
|
||||||
|
|
|
@ -142,20 +142,14 @@ class ogThread():
|
||||||
client.send(response.get())
|
client.send(response.get())
|
||||||
|
|
||||||
def setup(client, request, ogRest):
|
def setup(client, request, ogRest):
|
||||||
listconfig = []
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
listconfig = ogOperations.setup(request, ogRest)
|
out = ogOperations.setup(request, ogRest)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
response = restResponse(ogResponses.INTERNAL_ERR)
|
response = restResponse(ogResponses.INTERNAL_ERR)
|
||||||
client.send(response.get())
|
client.send(response.get())
|
||||||
return
|
return
|
||||||
|
|
||||||
jsonResp = jsonResponse()
|
jsonResp = jsonResponse(out)
|
||||||
jsonResp.addElement('disk', request.getDisk())
|
|
||||||
jsonResp.addElement('cache', request.getCache())
|
|
||||||
jsonResp.addElement('cache_size', request.getCacheSize())
|
|
||||||
jsonResp.addElement('partition_setup', listconfig)
|
|
||||||
|
|
||||||
response = restResponse(ogResponses.OK, jsonResp)
|
response = restResponse(ogResponses.OK, jsonResp)
|
||||||
client.send(response.get())
|
client.send(response.get())
|
||||||
|
|
Loading…
Reference in New Issue