mirror of https://git.48k.eu/ogclient
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.master
parent
f31e55fea4
commit
595770163a
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue