server: refactor reading in autoinstall
Factor out reading the autoinstall data from the loading function. Also add context logging to both the loading and reading functions.
This commit is contained in:
parent
d77bfbe1e0
commit
a25f2e03c1
|
@ -668,7 +668,19 @@ class SubiquityServer(Application):
|
||||||
context=ctx,
|
context=ctx,
|
||||||
)
|
)
|
||||||
|
|
||||||
def load_autoinstall_config(self, *, only_early):
|
@with_context(name="read_config")
|
||||||
|
def _read_config(self, *, cfg_path: str, context: Context) -> dict[str, Any]:
|
||||||
|
with open(cfg_path) as fp:
|
||||||
|
config: dict[str, Any] = yaml.safe_load(fp)
|
||||||
|
|
||||||
|
autoinstall_config: dict[str, Any] = dict()
|
||||||
|
|
||||||
|
autoinstall_config = config
|
||||||
|
|
||||||
|
return autoinstall_config
|
||||||
|
|
||||||
|
@with_context()
|
||||||
|
def load_autoinstall_config(self, *, only_early, context):
|
||||||
log.debug(
|
log.debug(
|
||||||
"load_autoinstall_config only_early %s file %s",
|
"load_autoinstall_config only_early %s file %s",
|
||||||
only_early,
|
only_early,
|
||||||
|
@ -689,8 +701,9 @@ class SubiquityServer(Application):
|
||||||
self.interactive = True
|
self.interactive = True
|
||||||
return
|
return
|
||||||
|
|
||||||
with open(self.autoinstall) as fp:
|
self.autoinstall_config = self._read_config(
|
||||||
self.autoinstall_config = yaml.safe_load(fp)
|
cfg_path=self.autoinstall, context=context
|
||||||
|
)
|
||||||
|
|
||||||
# Check every time
|
# Check every time
|
||||||
self.interactive = bool(self.autoinstall_config.get("interactive-sections"))
|
self.interactive = bool(self.autoinstall_config.get("interactive-sections"))
|
||||||
|
|
Loading…
Reference in New Issue