diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-11 17:15:16 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-11 17:15:16 -0700 |
commit | 82243cdf875cd7d8b2fbd962fa92ab139c653043 (patch) | |
tree | caba00c8d793656422cb845793e77fc06f669590 /cloudinit/handlers/__init__.py | |
parent | 3b964024040bed3c217b6d4f043af55d0dbc5469 (diff) | |
download | vyos-cloud-init-82243cdf875cd7d8b2fbd962fa92ab139c653043.tar.gz vyos-cloud-init-82243cdf875cd7d8b2fbd962fa92ab139c653043.zip |
Removing distro specifics from here, as well as running functionality (which is now elsewhere).
Diffstat (limited to 'cloudinit/handlers/__init__.py')
-rw-r--r-- | cloudinit/handlers/__init__.py | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py index ae74b683..5d70ac43 100644 --- a/cloudinit/handlers/__init__.py +++ b/cloudinit/handlers/__init__.py @@ -36,7 +36,6 @@ LOG = logging.getLogger(__name__) DEF_HANDLER_VERSION = 1 DEF_FREQ = PER_INSTANCE -HANDLER_TPL = "cc_%s" # reads a cloudconfig module list, returns @@ -198,41 +197,6 @@ def redirect_output(outfmt, errfmt, o_out=sys.stdout, o_err=sys.stderr): return -def run_per_instance(name, func, args, clear_on_fail=False): - semfile = "%s/%s" % (cloudinit.get_ipath_cur("data"), name) - if os.path.exists(semfile): - return - - util.write_file(semfile, str(time.time())) - try: - func(*args) - except: - if clear_on_fail: - os.unlink(semfile) - raise - - -# apt_get top level command (install, update...), and args to pass it -def apt_get(tlc, args=None): - if args is None: - args = [] - e = os.environ.copy() - e['DEBIAN_FRONTEND'] = 'noninteractive' - cmd = ['apt-get', '--option', 'Dpkg::Options::=--force-confold', - '--assume-yes', tlc] - cmd.extend(args) - subprocess.check_call(cmd, env=e) - - -def update_package_sources(): - run_per_instance("update-sources", apt_get, ("update",)) - - -def install_packages(pkglist): - update_package_sources() - apt_get("install", pkglist) - - def form_module_name(name): canon_name = name.replace("-", "_") if canon_name.endswith(".py"): @@ -240,7 +204,9 @@ def form_module_name(name): canon_name = canon_name.strip() if not canon_name: return None - return HANDLER_TPL % (canon_name) + if not canon_name.startswith("cc_"): + canon_name = 'cc_%s' % (canon_name) + return canon_name def fixup_module(mod): |