From 6fc476625714c56809eacd0df7634dc24b0a4ba3 Mon Sep 17 00:00:00 2001
From: Scott Moser <smoser@ubuntu.com>
Date: Thu, 27 Oct 2011 15:57:44 -0400
Subject: do not run run-parts if directory has no items

Per bug 857926, on some systems, run-parts will exit failure
if the directory is empty.  On debian/ubuntu, at least of recent vintage,
it exits success.  Its reasonable to just not run it.

LP: #857926
---
 cloudinit/util.py | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'cloudinit')

diff --git a/cloudinit/util.py b/cloudinit/util.py
index 8f50147d..68ce674e 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -134,6 +134,9 @@ def getkeybyid(keyid,keyserver):
 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()
-- 
cgit v1.2.3