From 8754c21694b5dff69105a0d9b739dd87088626ee Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Mon, 23 Sep 2024 13:08:51 +0200 Subject: src: report used and free partition data in bytes Add "used_size" and "free_size" to the partition data and the cache data. Old response from ogClient for /cache/delete, /cache/fetch and /image/restore: { 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] } New response: { 'cache': { 'used_size': 4520232322423, 'free_size': 48273465287452945, 'images': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] } } --- src/virtual/ogOperations.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/virtual/ogOperations.py') diff --git a/src/virtual/ogOperations.py b/src/virtual/ogOperations.py index 763c126..836967a 100644 --- a/src/virtual/ogOperations.py +++ b/src/virtual/ogOperations.py @@ -286,6 +286,7 @@ class OgVirtualOperations: part['os'] = '' part['size'] = 0 part['used_size'] = 0 + part['free_size'] = 0 part['virt-drive'] = '' continue g = guestfs.GuestFS(python_return_dict=True) @@ -332,7 +333,8 @@ class OgVirtualOperations: 'filesystem': '', 'os': '', 'size': int(free_disk / 1024), - 'used_size': int(100 * used_disk / total_disk)}], + 'used_size': used_disk, + 'free_size': free_disk}], 'partition_setup': []} for i in range(4): part_json = {'disk': 1, @@ -342,6 +344,7 @@ class OgVirtualOperations: 'os': '', 'size': 0, 'used_size': 0, + 'free_size': 0, 'virt-drive': ''} data['partition_setup'].append(part_json) with open(self.OG_PARTITIONS_CFG_PATH, 'w+') as f: -- cgit v1.2.3-18-g5258