summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorharlowja <harlowja@virtualbox.rhel>2012-06-22 00:04:07 -0700
committerharlowja <harlowja@virtualbox.rhel>2012-06-22 00:04:07 -0700
commit2a2dc725670f8ff3c6024332302ff9c718ff27f2 (patch)
treebcd8867978b80386c64c457cd8aca00e7fdeab3e
parent264ff30c0f4424fe48d2bd70c71b68bb9e5afc59 (diff)
downloadvyos-cloud-init-2a2dc725670f8ff3c6024332302ff9c718ff27f2.tar.gz
vyos-cloud-init-2a2dc725670f8ff3c6024332302ff9c718ff27f2.zip
1. Return which modules ran from the run module function
2. Use that list in the main binary & adjust related comparisions
-rwxr-xr-xbin/cloud-init16
-rw-r--r--cloudinit/stages.py10
2 files changed, 15 insertions, 11 deletions
diff --git a/bin/cloud-init b/bin/cloud-init
index aff8f967..68c7ba76 100755
--- a/bin/cloud-init
+++ b/bin/cloud-init
@@ -91,8 +91,8 @@ def extract_fns(args):
def run_module_section(mods, action_name, section):
full_section_name = MOD_SECTION_TPL % (section)
- (ran_am, failures) = mods.run_section(full_section_name)
- total_attempted = ran_am + len(failures)
+ (which_ran, failures) = mods.run_section(full_section_name)
+ total_attempted = len(which_ran) + len(failures)
if total_attempted == 0:
msg = ("No '%s' modules to run"
" under section '%s'") % (action_name, full_section_name)
@@ -100,7 +100,8 @@ def run_module_section(mods, action_name, section):
LOG.debug(msg)
return 0
else:
- LOG.debug("Ran %s modules with %s failures", ran_am, len(failures))
+ LOG.debug("Ran %s modules with %s failures",
+ len(which_ran), len(failures))
return len(failures)
@@ -316,16 +317,17 @@ def main_single(name, args):
logging.resetLogging()
logging.setupLogging(mods.cfg)
# Stage 4
- (run_am, failures) = mods.run_single(mod_name,
- mod_args,
- mod_freq)
+ (which_ran, failures) = mods.run_single(mod_name,
+ mod_args,
+ mod_freq)
if failures:
LOG.warn("Ran %s but it failed!", mod_name)
return 1
- elif run_am == 0:
+ elif not which_ran:
LOG.warn("Did not run %s, does it exist?", mod_name)
return 1
else:
+ # Guess it worked
return 0
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index cf5e6924..9481db83 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -517,10 +517,12 @@ class Modules(object):
return mostly_mods
def _run_modules(self, mostly_mods):
- failures = []
d_name = self.init.distro.name
cc = self.init.cloudify()
- am_ran = 0
+ # Return which ones ran
+ # and which ones failed + the exception of why it failed
+ failures = []
+ which_ran = []
for (mod, name, freq, args) in mostly_mods:
try:
# Try the modules frequency, otherwise fallback to a known one
@@ -540,14 +542,14 @@ class Modules(object):
func_args = [name, self.cfg,
cc, config.LOG, args]
# Mark it as having started running
- am_ran += 1
+ which_ran.append(name)
# This name will affect the semaphore name created
run_name = "config-%s" % (name)
cc.run(run_name, mod.handle, func_args, freq=freq)
except Exception as e:
util.logexc(LOG, "Running %s (%s) failed", name, mod)
failures.append((name, e))
- return (am_ran, failures)
+ return (which_ran, failures)
def run_single(self, mod_name, args=None, freq=None):
# Form the users module 'specs'