diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-15 18:01:03 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-15 18:01:03 -0700 |
commit | 508168acb95aee070d493b45656f781a42bdd262 (patch) | |
tree | e816b241c500d99f1289fb6afffb33abb560df99 /cloudinit/sources/__init__.py | |
parent | 36c1da35c2c0cb1b2ee18b7374bc81df8349e3e2 (diff) | |
download | vyos-cloud-init-508168acb95aee070d493b45656f781a42bdd262.tar.gz vyos-cloud-init-508168acb95aee070d493b45656f781a42bdd262.zip |
Complete initial cleanup for refactoring/rework.
Some of the cleanups were the following
1. Using standard (logged) utility functions for sub process work, writing, reading files, and other file system/operating system options
2. Having distrobutions impelement there own subclasses to handle system specifics (if applicable)
3. Having a cloud wrapper that provides just the functionality we want to expose (cloud.py)
4. Using a path class instead of globals for all cloud init paths (it is configured via config)
5. Removal of as much shared global state as possible (there should be none, minus a set of constants)
6. Other various cleanups that remove transforms/handlers/modules from reading/writing/chmoding there own files.
a. They should be using util functions to take advantage of the logging that is now enabled in those util functions (very useful for debugging)
7. Urls being read and checked from a single module that serves this and only this purpose (+1 for code organization)
8. Updates to log whenever a transform decides not to run
9. Ensure whenever a exception is thrown (and possibly captured) that the util.logexc function is called
a. For debugging, tracing this is important to not just drop them on the floor.
10. Code shuffling into utils.py where it makes sense (and where it could serve a benefit for other code now or in the future)
Diffstat (limited to 'cloudinit/sources/__init__.py')
-rw-r--r-- | cloudinit/sources/__init__.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index dfd1fff3..08669f5d 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -39,10 +39,6 @@ class DataSourceNotFoundException(Exception): class DataSource(object): def __init__(self, sys_cfg, distro, paths): - name = util.obj_name(self) - if name.startswith(DS_PREFIX): - name = name[DS_PREFIX:] - self.cfgname = name self.sys_cfg = sys_cfg self.distro = distro self.paths = paths @@ -50,8 +46,11 @@ class DataSource(object): self.userdata = None self.metadata = None self.userdata_raw = None + name = util.obj_name(self) + if name.startswith(DS_PREFIX): + name = name[DS_PREFIX:] self.ds_cfg = util.get_cfg_by_path(self.sys_cfg, - ("datasource", self.cfgname), {}) + ("datasource", name), {}) def get_userdata(self): if self.userdata is None: @@ -112,6 +111,7 @@ class DataSource(object): def get_instance_id(self): if not self.metadata or 'instance-id' not in self.metadata: + # Return a magic not really instance id string return "iid-datasource" return str(self.metadata['instance-id']) @@ -166,7 +166,7 @@ def find_source(sys_cfg, distro, paths, ds_deps, cfg_list, pkg_list): if s.get_data(): return (s, ds) except Exception as e: - LOG.exception("Getting data from %s failed due to %s", ds, e) + util.logexc(LOG, "Getting data from %s failed", ds) msg = "Did not find any data source, searched classes: %s" % (ds_names) raise DataSourceNotFoundException(msg) |