summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-11-09 14:34:24 -0600
committerJohn Estabrook <jestabro@vyos.io>2023-11-16 12:53:36 -0600
commitbd701768796d6ebb03ca943faf96d1dbea030edd (patch)
tree44513ae5d8110581926278f541897b8d6a5936e2 /python/vyos
parentfc5dc00a3892fa26d03213854ea5091d6b0c2c18 (diff)
downloadvyos-1x-bd701768796d6ebb03ca943faf96d1dbea030edd.tar.gz
vyos-1x-bd701768796d6ebb03ca943faf96d1dbea030edd.zip
image: T4516: ensure compatibility with legacy RAID 1 installs
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/system/compat.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/python/vyos/system/compat.py b/python/vyos/system/compat.py
index aa9b0b4b5..319c3dabf 100644
--- a/python/vyos/system/compat.py
+++ b/python/vyos/system/compat.py
@@ -86,6 +86,12 @@ def filter_unparsed(grub_path: str) -> str:
return filtered
+def get_search_root(unparsed: str) -> str:
+ unparsed_lines = unparsed.splitlines()
+ search_root = next((x for x in unparsed_lines if 'search' in x), '')
+ return search_root
+
+
def sanitize_boot_opts(boot_opts: str) -> str:
"""Sanitize boot options from console and init
@@ -269,18 +275,21 @@ def grub_cfg_fields(root_dir: str = '') -> dict:
fields = {'default': 0, 'timeout': 5}
# 'default' and 'timeout' from legacy grub.cfg
fields |= grub.vars_read(grub_cfg_main)
+
fields['tools_version'] = SYSTEM_CFG_VER
menu_entries = update_version_list(root_dir)
fields['versions'] = menu_entries
+
default = get_default(menu_entries, root_dir)
if default is not None:
fields['default'] = default
- p = Path('/sys/firmware/efi')
- if p.is_dir():
- fields['efi'] = True
- else:
- fields['efi'] = False
+ modules = grub.modules_read(grub_cfg_main)
+ fields['modules'] = modules
+
+ unparsed = filter_unparsed(grub_cfg_main).splitlines()
+ search_root = next((x for x in unparsed if 'search' in x), '')
+ fields['search_root'] = search_root
return fields