summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/linux/ogOperations.py23
-rw-r--r--src/ogRest.py10
2 files changed, 17 insertions, 16 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py
index 73eb5e1..5459768 100644
--- a/src/linux/ogOperations.py
+++ b/src/linux/ogOperations.py
@@ -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()
diff --git a/src/ogRest.py b/src/ogRest.py
index 6fb0dc0..7606d8b 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -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())