diff options
author | Chad Smith <chad.smith@canonical.com> | 2023-05-12 11:29:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-12 11:29:15 -0600 |
commit | 73f34575da4f99a376998516a13c3a79cc640ae3 (patch) | |
tree | 06f396d4fcda64ad8cb4476538b50d524c59a2b9 /cloudinit/cmd/devel/__init__.py | |
parent | 9f8450368c2ae713de0a2308f5d3cb73de5b39f2 (diff) | |
download | cloud-init-git-73f34575da4f99a376998516a13c3a79cc640ae3.tar.gz |
schema: read_cfg_paths call init.fetch to lookup /v/l/c/instance
Fix cloud-init schema --system being unable to find merged
userdata stored at /var/lib/cloud/instance/cloud_config.txt.
Init.paths.get_ipath only has visibility to merged cloud config in
/var/lib/cloud/<instance_id>/cloud-config.txt after fetching the
existing cached datasource which provides instance-id from metadata
in order to determine the unique instance-id which represents the
path to the cloud-config.txt.
To support reuse of read_cfg_paths helper function, add an optional
parameter fetch_existing_datasource which indicates whether reading
the existing datasource is necessary for this helper function.
cloud-init schema --system calls read_cfg_paths providing
fetch_existing_datasource="trust" prior to calls to
paths.get_ipath().
Diffstat (limited to 'cloudinit/cmd/devel/__init__.py')
-rw-r--r--[-rwxr-xr-x] | cloudinit/cmd/devel/__init__.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cloudinit/cmd/devel/__init__.py b/cloudinit/cmd/devel/__init__.py index 9a8f2ebd..357c4ae7 100755..100644 --- a/cloudinit/cmd/devel/__init__.py +++ b/cloudinit/cmd/devel/__init__.py @@ -17,9 +17,17 @@ def addLogHandlerCLI(logger, log_level): return logger -def read_cfg_paths() -> Paths: - """Return a Paths object based on the system configuration on disk.""" +def read_cfg_paths(fetch_existing_datasource: str = "") -> Paths: + """Return a Paths object based on the system configuration on disk. + + :param fetch_existing_datasource: String one of check or trust. Whether to + load the pickled datasource before returning Paths. This is necessary + when using instance paths via Paths.get_ipath method which are only + known from the instance-id metadata in the detected datasource. + """ init = Init(ds_deps=[]) + if fetch_existing_datasource: + init.fetch(existing=fetch_existing_datasource) init.read_cfg() return init.paths |