From 0411d2bf94c8854f3589213074f40056d026a020 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Thu, 19 Nov 2020 12:44:40 +0100 Subject: #1008 Adapt virtual disk setup JSON format Previous commits updates ogClient and ogServer to support several disks in Linux (ogLive) mode. This changes disk setup JSON format from an object to an array. ogClient in virtual mode also need to satisfy this new format, although it not support several disks. Adapt ogClient virtual mode to satisfy new disk setup JSON format. Old format: "disk_setup": { "disk": 1, "partition": 0, "code": "0", "filesystem": "", "os": "", "size": 32685957, "used_size": 6 }, New format: "disk_setup": [ { "disk": 1, "partition": 0, "code": "0", "filesystem": "", "os": "", "size": 32685957, "used_size": 6 } ], --- src/virtual/ogOperations.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/virtual/ogOperations.py') diff --git a/src/virtual/ogOperations.py b/src/virtual/ogOperations.py index 5e5ee44..60370cb 100644 --- a/src/virtual/ogOperations.py +++ b/src/virtual/ogOperations.py @@ -252,7 +252,9 @@ class OgVirtualOperations: part.pop('virt-drive') for k, v in part.items(): part[k] = str(v) - data['disk_setup'] = {k: str(v) for k, v in data['disk_setup'].items()} + for disk in data['disk_setup']: + for k, v in disk.items(): + disk[k] = str(v) return data def refresh(self, ogRest): @@ -318,13 +320,13 @@ class OgVirtualOperations: total_disk, used_disk, free_disk = shutil.disk_usage("/") free_disk = int(free_disk * self.USABLE_DISK) data = {'serial_number': '', - 'disk_setup': {'disk': 1, + 'disk_setup': [{'disk': 1, 'partition': 0, 'code': '0', 'filesystem': '', 'os': '', 'size': int(free_disk / 1024), - 'used_size': int(100 * used_disk / total_disk)}, + 'used_size': int(100 * used_disk / total_disk)}], 'partition_setup': []} for i in range(4): part_json = {'disk': 1, -- cgit v1.2.3-18-g5258