summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorViacheslav <v.gletenko@vyos.io>2025-07-30 12:26:56 +0000
committerViacheslav <v.gletenko@vyos.io>2025-07-30 12:26:56 +0000
commit9724b301a0d44854ef7f334de5aedf727713bc52 (patch)
tree180cf0e273ecf2dd6e334bb86330e7ee7a3e33ec /src
parenta551fa45573ef57858904773d4bcc99dbf553b19 (diff)
downloadvyos-1x-9724b301a0d44854ef7f334de5aedf727713bc52.tar.gz
vyos-1x-9724b301a0d44854ef7f334de5aedf727713bc52.zip
T7668: Fix image update due to None kernel options
If we do not have the system options kernel the update fails Change order for variables `k_cpu_opts` and `k_memory_opts` If we do not have kernel_options set empty dictionary as NoneType object has no attribue `get` ``` >>> kernel_options=None >>> kernel_options.get('cpu', {}) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'NoneType' object has no attribute 'get' >>> >>> >>> kernel_options={} >>> kernel_options.get('cpu', {}) {} >>> ```
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/image_installer.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py
index 8c9d7eddd..2a9830f37 100755
--- a/src/op_mode/image_installer.py
+++ b/src/op_mode/image_installer.py
@@ -494,10 +494,10 @@ def get_cli_kernel_options(config_file: str) -> list:
config = ConfigTree(read_file(config_file))
config_dict = loads(config.to_json())
kernel_options = dict_search('system.option.kernel', config_dict)
- k_cpu_opts = kernel_options.get('cpu', {})
- k_memory_opts = kernel_options.get('memory', {})
if kernel_options is None:
kernel_options = {}
+ k_cpu_opts = kernel_options.get('cpu', {})
+ k_memory_opts = kernel_options.get('memory', {})
cmdline_options = []
# XXX: This code path and if statements must be kept in sync with the Kernel