summaryrefslogtreecommitdiffstats
path: root/src/linux/ogOperations.py
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-01-31 13:17:24 +0100
committerAlvaro Neira Ayuso <aneira@soleta.eu>2020-02-03 10:15:49 +0100
commite96e187825ad4e03904b23697215a1bb58bfe3f0 (patch)
tree34e00beec791ce297d3f57b692c0a60a3148c311 /src/linux/ogOperations.py
parentf86999da0c150d2a6976ba69a352164b55c52639 (diff)
Fix parseGetConf(...) configuration parsing
This patch also reformats the response to the /refresh command.
Diffstat (limited to 'src/linux/ogOperations.py')
-rw-r--r--src/linux/ogOperations.py43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py
index e41bb86..73eb5e1 100644
--- a/src/linux/ogOperations.py
+++ b/src/linux/ogOperations.py
@@ -12,28 +12,29 @@ import subprocess
OG_PATH = '/opt/opengnsys/'
def parseGetConf(out):
- listConfigs = []
- disk = -1;
-
+ parsed = {'serial_number': '',
+ 'disk_setup': '',
+ 'partition_setup': list()}
configs = out.split('\n')
- configs = filter(None, configs)
- for item in configs:
- i = 0
- json = {}
- val = item.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]
- disk = val[0]
- listConfigs.append(json)
-
- return [disk, listConfigs]
+ for line in configs[:-1]:
+ if 'ser=' in line:
+ parsed['serial_number'] = line.partition('ser=')[2]
+ else:
+ part_setup = {}
+ params = dict(param.split('=') for param in line.split('\t'))
+ # Parse partition configuration.
+ part_setup['disk'] = params['disk']
+ part_setup['partition'] = params['par']
+ part_setup['code'] = params['cpt']
+ part_setup['filesystem'] = params['fsi']
+ part_setup['os'] = params['soi']
+ part_setup['size'] = params['tam']
+ part_setup['used_size'] = params['uso']
+ if part_setup['partition'] == '0':
+ parsed['disk_setup'] = part_setup
+ else:
+ parsed['partition_setup'].append(part_setup)
+ return parsed
def poweroff():
if os.path.exists('/scripts/oginit'):