summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2017-12-01 10:04:25 -0700
committerChad Smith <chad.smith@canonical.com>2017-12-01 10:04:25 -0700
commit9824cecf6d644093c5083ab2d550a58d18d207b0 (patch)
tree2a944c65afc7379211ffa6ce0b2f0841bded4c5a /cloudinit/util.py
parentd4dfa39f8c2d6e386303cbe6abb9bb1f804cae5f (diff)
parent7acc9e68fafbbd7c56587aebe752ba6ba8c8a3db (diff)
downloadvyos-cloud-init-9824cecf6d644093c5083ab2d550a58d18d207b0.tar.gz
vyos-cloud-init-9824cecf6d644093c5083ab2d550a58d18d207b0.zip
merge from master at 17.1-46-g7acc9e68
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index e1290aa8..6c014ba5 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2541,4 +2541,26 @@ def load_shell_content(content, add_empty=False, empty_val=None):
return data
+def wait_for_files(flist, maxwait, naplen=.5, log_pre=""):
+ need = set(flist)
+ waited = 0
+ while True:
+ need -= set([f for f in need if os.path.exists(f)])
+ if len(need) == 0:
+ LOG.debug("%sAll files appeared after %s seconds: %s",
+ log_pre, waited, flist)
+ return []
+ if waited == 0:
+ LOG.debug("%sWaiting up to %s seconds for the following files: %s",
+ log_pre, maxwait, flist)
+ if waited + naplen > maxwait:
+ break
+ time.sleep(naplen)
+ waited += naplen
+
+ LOG.debug("%sStill missing files after %s seconds: %s",
+ log_pre, maxwait, need)
+ return need
+
+
# vi: ts=4 expandtab