cloudinit: log access to combined-cloud-config

Co-authored-by: Chad Smith <chad.smith@canonical.com>
This commit is contained in:
Dan Bungert 2023-07-24 17:43:21 -06:00
parent 751119866e
commit c1d91d6b99
1 changed files with 9 additions and 1 deletions

View File

@ -1,12 +1,20 @@
"""Shared cloudinit utility functions"""
import json
import logging
log = logging.getLogger("subiquity.cloudinit")
def get_host_combined_cloud_config() -> dict:
"""Return the host system /run/cloud-init/combined-cloud-config.json"""
try:
with open("/run/cloud-init/combined-cloud-config.json") as fp:
return json.load(fp)
config = json.load(fp)
log.debug(
"Loaded cloud config from /run/cloud-init/combined-cloud-config.json"
)
return config
except (IOError, OSError, AttributeError, json.decoder.JSONDecodeError):
log.debug("Failed to load combined-cloud-config")
return {}