summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-03-05 16:35:35 -0500
committerScott Moser <smoser@ubuntu.com>2012-03-05 16:35:35 -0500
commit54b593a166c4ac4043615dddc94a941ebc712300 (patch)
treebd4afbf503fb705108b28502aaa8cc9942033294
parent1676825c229e3939ec5b06c494bdcb56d39dddb1 (diff)
downloadvyos-cloud-init-54b593a166c4ac4043615dddc94a941ebc712300.tar.gz
vyos-cloud-init-54b593a166c4ac4043615dddc94a941ebc712300.zip
use builtin runparts rather than system run-parts utility
Because Fedora's run-parts does not accept '--regex' and debian's run-parts skips files with a '.' in the *without* '--regex=.*', we're forced to include our own version of run-parts. LP: #933553
-rw-r--r--cloudinit/util.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index c37f0316..0032c6e0 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -209,16 +209,18 @@ def runparts(dirp, skip_no_exist=True):
if skip_no_exist and not os.path.isdir(dirp):
return
- # per bug 857926, Fedora's run-parts will exit failure on empty dir
- if os.path.isdir(dirp) and os.listdir(dirp) == []:
- return
-
- cmd = ['run-parts', '--regex', '.*', dirp]
- sp = subprocess.Popen(cmd)
- sp.communicate()
- if sp.returncode is not 0:
- raise subprocess.CalledProcessError(sp.returncode, cmd)
- return
+ failed = 0
+ for exe_name in sorted(os.listdir(dirp)):
+ exe_path = os.path.join(dirp, exe_name)
+ if os.path.isfile(exe_path) and os.access(exe_path, os.X_OK):
+ popen = subprocess.Popen([exe_path])
+ popen.communicate()
+ if popen.returncode is not 0:
+ failed += 1
+ sys.stderr.write("failed: %s [%i]\n" %
+ (exe_path, popen.returncode))
+ if failed:
+ raise RuntimeError('runparts: %i failures' % failed)
def subp(args, input_=None):