cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00650
[Merge] lp:~harlowja/cloud-init/write-files-fetch-from-somewhere into lp:cloud-init
Joshua Harlow has proposed merging lp:~harlowja/cloud-init/write-files-fetch-from-somewhere into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/write-files-fetch-from-somewhere/+merge/254816
--
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/write-files-fetch-from-somewhere into lp:cloud-init.
=== modified file 'cloudinit/config/cc_write_files.py'
--- cloudinit/config/cc_write_files.py 2015-01-26 17:41:04 +0000
+++ cloudinit/config/cc_write_files.py 2015-03-31 19:11:17 +0000
@@ -25,6 +25,13 @@
frequency = PER_INSTANCE
+# Content with these prefix(s) will be read/fetched externally to grab its
+# contents (which will replace any provided contents...)
+READ_EXTERNAL_PREFIXES = [
+ "http://",
+ 'file://',
+ "https://",
+]
DEFAULT_OWNER = "root:root"
DEFAULT_PERMS = 0o644
UNKNOWN_ENC = 'text/plain'
@@ -70,8 +77,18 @@
i + 1, name)
continue
path = os.path.abspath(path)
+ pre_content = f_info.get('content', '')
+ fetch_external = util.is_true(f_info.get('fetch_external', False))
+ if not fetch_external:
+ # See if we should anyway by looking for common prefixes...
+ for p in READ_EXTERNAL_PREFIXES:
+ if pre_content.startswith(p):
+ fetch_external = True
+ break
+ if fetch_external:
+ pre_content = util.read_file_or_url(pre_content)
extractions = canonicalize_extraction(f_info.get('encoding'), log)
- contents = extract_contents(f_info.get('content', ''), extractions)
+ contents = extract_contents(pre_content, extractions)
(u, g) = util.extract_usergroup(f_info.get('owner', DEFAULT_OWNER))
perms = decode_perms(f_info.get('permissions'), DEFAULT_PERMS, log)
util.write_file(path, contents, mode=perms)