diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-08-07 14:45:01 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-08-07 14:45:01 -0500 |
commit | 9975e06338bb646dbefe0749f7a8f88974d44d24 (patch) | |
tree | 17b072271f8faa303bbfdde1ff33496cc320ecec /cloudinit/sources/__init__.py | |
parent | 328cc7fbaf4d60b51193fb8c14e52d8c6f3273f2 (diff) | |
parent | 95bfe5d5150e2bf0a26dd1b97578c4fd04152365 (diff) | |
download | vyos-cloud-init-9975e06338bb646dbefe0749f7a8f88974d44d24.tar.gz vyos-cloud-init-9975e06338bb646dbefe0749f7a8f88974d44d24.zip |
Add initial reporting module and events
Diffstat (limited to 'cloudinit/sources/__init__.py')
-rw-r--r-- | cloudinit/sources/__init__.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index a21c08c2..838cd198 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -27,6 +27,7 @@ import six from cloudinit import importer from cloudinit import log as logging +from cloudinit import reporting from cloudinit import type_utils from cloudinit import user_data as ud from cloudinit import util @@ -246,17 +247,25 @@ def normalize_pubkey_data(pubkey_data): return keys -def find_source(sys_cfg, distro, paths, ds_deps, cfg_list, pkg_list): +def find_source(sys_cfg, distro, paths, ds_deps, cfg_list, pkg_list, reporter): ds_list = list_sources(cfg_list, ds_deps, pkg_list) ds_names = [type_utils.obj_name(f) for f in ds_list] - LOG.debug("Searching for data source in: %s", ds_names) - - for cls in ds_list: + mode = "network" if DEP_NETWORK in ds_deps else "local" + LOG.debug("Searching for %s data source in: %s", mode, ds_names) + + for name, cls in zip(ds_names, ds_list): + myrep = reporting.ReportEventStack( + name="search-%s" % name.replace("DataSource", ""), + description="searching for %s data from %s" % (mode, name), + message="no %s data found from %s" % (mode, name), + parent=reporter) try: - LOG.debug("Seeing if we can get any data from %s", cls) - s = cls(sys_cfg, distro, paths) - if s.get_data(): - return (s, type_utils.obj_name(cls)) + with myrep: + LOG.debug("Seeing if we can get any data from %s", cls) + s = cls(sys_cfg, distro, paths) + if s.get_data(): + myrep.message = "found %s data from %s" % (mode, name) + return (s, type_utils.obj_name(cls)) except Exception: util.logexc(LOG, "Getting data from %s failed", cls) |