summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-04-21 08:01:16 +0300
committerDevaev Maxim <[email protected]>2020-04-21 08:01:16 +0300
commit05d35d7eb0a30d71a88b7e443ff9755ad0a17bff (patch)
tree0a0b261715a0fb3f3c4d1ccbb2332675eb080701 /kvmd
parent8c904cf4a8e78fc4a688131a9b360085b7bfbf75 (diff)
real ports for extras
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/kvmd/__init__.py3
-rw-r--r--kvmd/apps/kvmd/info.py23
2 files changed, 22 insertions, 4 deletions
diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py
index d21de499..5aa3d687 100644
--- a/kvmd/apps/kvmd/__init__.py
+++ b/kvmd/apps/kvmd/__init__.py
@@ -60,6 +60,7 @@ def main(argv: Optional[List[str]]=None) -> None:
if config.kvmd.msd.type == "otg":
msd_kwargs["gadget"] = config.otg.gadget # XXX: Small crutch to pass gadget name to plugin
+ global_config = config
config = config.kvmd
KvmdServer(
@@ -71,7 +72,7 @@ def main(argv: Optional[List[str]]=None) -> None:
force_internal_users=config.auth.internal.force_users,
enabled=config.auth.enabled,
),
- info_manager=InfoManager(**config.info._unpack()),
+ info_manager=InfoManager(global_config, **config.info._unpack()),
log_reader=LogReader(),
wol=WakeOnLan(**config.wol._unpack()),
diff --git a/kvmd/apps/kvmd/info.py b/kvmd/apps/kvmd/info.py
index 088927e3..fe4a332c 100644
--- a/kvmd/apps/kvmd/info.py
+++ b/kvmd/apps/kvmd/info.py
@@ -30,6 +30,7 @@ import dbus.exceptions
from ...logging import get_logger
+from ...yamlconf import Section
from ...yamlconf.loader import load_yaml_file
from ... import aiotools
@@ -39,10 +40,12 @@ from ... import aiotools
class InfoManager:
def __init__(
self,
+ global_config: Section,
meta_path: str,
extras_path: str,
) -> None:
+ self.__global_config = global_config
self.__meta_path = meta_path
self.__extras_path = extras_path
@@ -57,11 +60,25 @@ class InfoManager:
for app in os.listdir(self.__extras_path):
if app[0] != "." and os.path.isdir(os.path.join(self.__extras_path, app)):
extras[app] = load_yaml_file(os.path.join(self.__extras_path, app, "manifest.yaml"))
- daemon = extras[app].get("daemon", "")
- if isinstance(daemon, str) and daemon.strip():
- extras[app]["enabled"] = self.__is_daemon_enabled(daemon)
+ self.__rewrite_app_daemon(extras[app])
+ self.__rewrite_app_port(extras[app])
return extras
+ def __rewrite_app_daemon(self, extras: Dict) -> None:
+ daemon = extras.get("daemon", "")
+ if isinstance(daemon, str) and daemon.strip():
+ extras["enabled"] = self.__is_daemon_enabled(daemon)
+
+ def __rewrite_app_port(self, extras: Dict) -> None:
+ port_path = extras.get("port", "")
+ if isinstance(port_path, str) and port_path.strip():
+ extras["port"] = 0
+ config = self.__global_config
+ for item in filter(None, map(str.strip, port_path.split("/"))):
+ config = getattr(config, item, None)
+ if isinstance(config, int):
+ extras["port"] = config
+
def __is_daemon_enabled(self, name: str) -> bool:
if not name.startswith(".service"):
name += ".service"