Skip to content

Commit

Permalink
cloudinit: log access to combined-cloud-config
Browse files Browse the repository at this point in the history
Co-authored-by: Chad Smith <chad.smith@canonical.com>
  • Loading branch information
dbungert and blackboxsw committed Jul 25, 2023
1 parent 7511198 commit c1d91d6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion subiquity/cloudinit.py
Original file line number Diff line number Diff line change
@@ -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 {}

0 comments on commit c1d91d6

Please sign in to comment.