summaryrefslogtreecommitdiff
path: root/python/vyos/system/compat.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-01-12 10:10:58 -0600
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-01-17 05:34:02 +0000
commit2afd5e5575a42bee4483e093e9611fa3363c8adc (patch)
tree62c525749ed7beb7e89a59a265893edfcb055a11 /python/vyos/system/compat.py
parent6c39a9cb6df6bb56c02583f82d68edc8ef17241d (diff)
downloadvyos-1x-2afd5e5575a42bee4483e093e9611fa3363c8adc.tar.gz
vyos-1x-2afd5e5575a42bee4483e093e9611fa3363c8adc.zip
image-tools: T5923: update system_console.py for new GRUB file structure
Add util function to set serial console speed in accordance with revised GRUB file structure; in keeping with the intentions of the config_mode script, adjust the GRUB var 'console_speed' to only modify ttyS0. (cherry picked from commit 5ceaff2ef970cb9c567ac317bafbffca5b073f4a)
Diffstat (limited to 'python/vyos/system/compat.py')
-rw-r--r--python/vyos/system/compat.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/python/vyos/system/compat.py b/python/vyos/system/compat.py
index 319c3dabf..436da14e8 100644
--- a/python/vyos/system/compat.py
+++ b/python/vyos/system/compat.py
@@ -27,7 +27,7 @@ TMPL_GRUB_COMPAT: str = 'grub/grub_compat.j2'
# define regexes and variables
REGEX_VERSION = r'^menuentry "[^\n]*{\n[^}]*\s+linux /boot/(?P<version>\S+)/[^}]*}'
REGEX_MENUENTRY = r'^menuentry "[^\n]*{\n[^}]*\s+linux /boot/(?P<version>\S+)/vmlinuz (?P<options>[^\n]+)\n[^}]*}'
-REGEX_CONSOLE = r'^.*console=(?P<console_type>[^\s\d]+)(?P<console_num>[\d]+).*$'
+REGEX_CONSOLE = r'^.*console=(?P<console_type>[^\s\d]+)(?P<console_num>[\d]+)(,(?P<console_speed>[\d]+))?.*$'
REGEX_SANIT_CONSOLE = r'\ ?console=[^\s\d]+[\d]+(,\d+)?\ ?'
REGEX_SANIT_INIT = r'\ ?init=\S*\ ?'
REGEX_SANIT_QUIET = r'\ ?quiet\ ?'
@@ -131,6 +131,8 @@ def parse_entry(entry: tuple) -> dict:
# find console type and number
regex_filter = compile(REGEX_CONSOLE)
entry_dict.update(regex_filter.match(entry[1]).groupdict())
+ speed = entry_dict.get('console_speed', None)
+ entry_dict['console_speed'] = speed if speed is not None else '115200'
entry_dict['boot_opts'] = sanitize_boot_opts(entry[1])
return entry_dict
@@ -271,9 +273,11 @@ def grub_cfg_fields(root_dir: str = '') -> dict:
root_dir = disk.find_persistence()
grub_cfg_main = f'{root_dir}/{grub.GRUB_CFG_MAIN}'
+ grub_vars = f'{root_dir}/{grub.CFG_VYOS_VARS}'
- fields = {'default': 0, 'timeout': 5}
- # 'default' and 'timeout' from legacy grub.cfg
+ fields = grub.vars_read(grub_vars)
+ # 'default' and 'timeout' from legacy grub.cfg resets 'default' to
+ # index, rather than uuid
fields |= grub.vars_read(grub_cfg_main)
fields['tools_version'] = SYSTEM_CFG_VER