From 38b57c4ae43e062049d8a2a1a33f9a790a18b327 Mon Sep 17 00:00:00 2001 From: Alvaro Neira Ayuso Date: Tue, 14 Jan 2020 13:02:45 +0100 Subject: Improve setup command response This patch adds a new response support. This way allows us to send a new response message with more information about the partitions already set up. The format of the response is: { "disk" : "1", "cache" : "1", "cache_size" : "0", "partition_setup": [{"partition": "1", "code": "LINUX", "filesystem": "EMPTY", "size": "498688", "format": "0"}...] --- src/linux/ogOperations.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/linux') diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index 1aa454f..3fa636e 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -60,10 +60,31 @@ def procsetup(httpparser): cache = httpparser.getCache() cachesize = httpparser.getCacheSize() partlist = httpparser.getPartitionSetup() + listConfigs = [] for part in partlist: + i = 0 + json = {} cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!par=' + part["partition"] + '*cpt='+part["code"] + '*sfi=' + part['filesystem'] + '*tam=' + part['size'] + '*ope=' + part['format'] + '%' - subprocess.check_output([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], shell=True) + try: + subprocess.check_output([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], shell=True) + except: + continue + + result = subprocess.check_output([OG_PATH + 'interfaceAdm/getConfiguration'], shell=True) + val = result.decode('utf-8').rstrip().split('\t') + while i < len(val): + val[i] = val[i].split('=')[1] + i += 1 + + json['partition'] = val[1] + json['code'] = val[4] + json['filesystem'] = val[2] + json['size'] = val[5] + json['format'] = val[6] + listConfigs.append(json) + + return listConfigs def procirestore(httpparser): disk = httpparser.getDisk() -- cgit v1.2.3-18-g5258