Coverage for mlos_bench/mlos_bench/config/environments/os/linux/boot/scripts/local/create_new_grub_cfg.py: 57%
7 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
1#!/usr/bin/env python3
2#
3# Copyright (c) Microsoft Corporation.
4# Licensed under the MIT License.
5#
6"""
7Python script to parse through JSON and create new config file.
9This script will be run in the SCHEDULER. NEW_CFG will need to be copied over to the VM
10(/etc/default/grub.d).
11"""
12import json
14JSON_CONFIG_FILE = "config-boot-time.json"
15NEW_CFG = "zz-mlos-boot-params.cfg"
18def _write_config() -> None:
19 with open(JSON_CONFIG_FILE, "r", encoding="UTF-8") as fh_json, open(
20 NEW_CFG, "w", encoding="UTF-8"
21 ) as fh_config:
22 for key, val in json.load(fh_json).items():
23 fh_config.write(
24 'GRUB_CMDLINE_LINUX_DEFAULT="$' f'{ GRUB_CMDLINE_LINUX_DEFAULT} {key}={val}"\n'
25 )
28if __name__ == "__main__":
29 _write_config()