summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-04 12:52:31 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-10 17:23:18 +0200
commit595770163a4e4242b6937fc0ded9582d62159793 (patch)
tree6c3ba222b914c63f369d4044fe9d6ecff6b1f197
parentf31e55fea4fd5fca7598f9e20caed50ae04796e5 (diff)
live: add boot entries into /refresh payload
Add 'efi' key into the refresh payload. The value for that key has the following structure: 'efi': { 'entries': [ { "order": 0, "name": "Boot0000", "active": false, "description": "grub" }, { "order": 1, "name": "Boot0001", "active": true, "description": "UEFI: PXE IP4 Realtek PCIe GBE Family Controller" } ] } If the client is not a EFI system it won't add the 'efi' field. If an entry is not in the boot order it won't have the 'order' field.
-rw-r--r--src/live/ogOperations.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 010af05..9c32cce 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -157,6 +157,33 @@ class OgLiveOperations:
'checksum': image_checksum})
return cache_contents
+ def _get_boot_entry_data(self):
+ data = {}
+
+ if not is_uefi_supported():
+ return data
+
+ try:
+ efibootmgr_out = run_efibootmgr_json()
+ except Exception as e:
+ logging.warning(e)
+ return data
+
+ data['entries'] = []
+ for idx, entry_name in enumerate(efibootmgr_out['BootOrder']):
+ entry_name = 'Boot' + entry_name
+ for entry in efibootmgr_out['vars']:
+ if entry['name'] == entry_name:
+ entry['order'] = idx
+ data['entries'].append(entry)
+ break
+
+ for entry in efibootmgr_out['vars']:
+ if not 'order' in entry:
+ data['entries'].append(entry)
+
+ return data
+
def _compute_md5(self, path, bs=2**20):
m = hashlib.md5()
with open(path, 'rb') as f:
@@ -756,6 +783,10 @@ class OgLiveOperations:
json_body['cache'] = self._get_cache_contents()
+ boot_entry_data = self._get_boot_entry_data()
+ if boot_entry_data:
+ json_body['efi'] = boot_entry_data
+
generate_menu(json_body['partition_setup'])
generate_cache_txt()
self._restartBrowser(self._url)