summaryrefslogtreecommitdiff
path: root/kvmd/apps/__init__.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-30 06:36:00 +0300
committerDevaev Maxim <[email protected]>2020-09-30 06:36:00 +0300
commit3f9c32e9fc518bf7e94a2507bd2e388de3f6f749 (patch)
tree92921d88e41b08aa3f29ddbb233f5a4bfc3367a7 /kvmd/apps/__init__.py
parent771640a79c437ecc39296faee1c4dedb016d71a2 (diff)
moved otg devices configs to their own section
Diffstat (limited to 'kvmd/apps/__init__.py')
-rw-r--r--kvmd/apps/__init__.py68
1 files changed, 42 insertions, 26 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index a760d188..2473fa72 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -144,6 +144,7 @@ def _init_config(config_path: str, override_options: List[str], **load_flags: bo
try:
tools.merge(raw_config, (raw_config.pop("override", {}) or {}))
tools.merge(raw_config, build_raw_from_options(override_options))
+ _patch_raw(raw_config)
config = make_config(raw_config, scheme)
if _patch_dynamic(raw_config, config, scheme, **load_flags):
@@ -154,6 +155,19 @@ def _init_config(config_path: str, override_options: List[str], **load_flags: bo
raise SystemExit(f"Config error: {err}")
+def _patch_raw(raw_config: Dict) -> None:
+ if isinstance(raw_config.get("otg"), dict):
+ for (old, new) in [
+ ("msd", "msd"),
+ ("acm", "serial"),
+ ("drives", "drives"),
+ ]:
+ if old in raw_config["otg"]:
+ if not isinstance(raw_config["otg"].get("devices"), dict):
+ raw_config["otg"]["devices"] = {}
+ raw_config["otg"]["devices"][new] = raw_config["otg"].pop(old)
+
+
def _patch_dynamic( # pylint: disable=too-many-locals
raw_config: Dict,
config: Section,
@@ -372,36 +386,38 @@ def _get_config_scheme() -> Dict:
"udc": Option("", type=valid_stripped_string),
"init_delay": Option(3.0, type=valid_float_f01),
- "msd": {
- "user": Option("kvmd", type=valid_user),
- "default": {
- "stall": Option(False, type=valid_bool),
- "cdrom": Option(True, type=valid_bool),
- "rw": Option(False, type=valid_bool),
- "removable": Option(True, type=valid_bool),
- "fua": Option(True, type=valid_bool),
+ "devices": {
+ "msd": {
+ "user": Option("kvmd", type=valid_user),
+ "default": {
+ "stall": Option(False, type=valid_bool),
+ "cdrom": Option(True, type=valid_bool),
+ "rw": Option(False, type=valid_bool),
+ "removable": Option(True, type=valid_bool),
+ "fua": Option(True, type=valid_bool),
+ },
},
- },
- "acm": {
- "enabled": Option(False, type=valid_bool),
- },
+ "serial": {
+ "enabled": Option(False, type=valid_bool),
+ },
- "ethernet": {
- "enabled": Option(False, type=valid_bool),
- "host_mac": Option("", type=valid_mac, only_if="enabled"),
- "kvm_mac": Option("", type=valid_mac, only_if="enabled"),
- },
+ "ethernet": {
+ "enabled": Option(False, type=valid_bool),
+ "host_mac": Option("", type=valid_mac, only_if="enabled"),
+ "kvm_mac": Option("", type=valid_mac, only_if="enabled"),
+ },
- "drives": {
- "enabled": Option(False, type=valid_bool),
- "count": Option(1, type=valid_int_f1),
- "default": {
- "stall": Option(False, type=valid_bool),
- "cdrom": Option(False, type=valid_bool),
- "rw": Option(True, type=valid_bool),
- "removable": Option(True, type=valid_bool),
- "fua": Option(True, type=valid_bool),
+ "drives": {
+ "enabled": Option(False, type=valid_bool),
+ "count": Option(1, type=valid_int_f1),
+ "default": {
+ "stall": Option(False, type=valid_bool),
+ "cdrom": Option(False, type=valid_bool),
+ "rw": Option(True, type=valid_bool),
+ "removable": Option(True, type=valid_bool),
+ "fua": Option(True, type=valid_bool),
+ },
},
},
},