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:
Chris Peterson 2024-03-22 16:05:52 -07:00
parent d77bfbe1e0
commit a25f2e03c1
1 changed files with 16 additions and 3 deletions

View File

@ -668,7 +668,19 @@ class SubiquityServer(Application):
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(
"load_autoinstall_config only_early %s file %s",
only_early,
@ -689,8 +701,9 @@ class SubiquityServer(Application):
self.interactive = True
return
with open(self.autoinstall) as fp:
self.autoinstall_config = yaml.safe_load(fp)
self.autoinstall_config = self._read_config(
cfg_path=self.autoinstall, context=context
)
# Check every time
self.interactive = bool(self.autoinstall_config.get("interactive-sections"))