diff options
author | Ryan Harper <ryan.harper@canonical.com> | 2020-03-25 09:01:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 10:01:11 -0400 |
commit | 3f6746c6113ec9f691ff7e4f5ed3764d4261373b (patch) | |
tree | c5b64e91b3d3e3b8fd143bf99e835f7b494da031 /cloudinit/util.py | |
parent | c5e949c02a1d5226ae9b1cb39846db19d223c6c2 (diff) | |
download | vyos-cloud-init-3f6746c6113ec9f691ff7e4f5ed3764d4261373b.tar.gz vyos-cloud-init-3f6746c6113ec9f691ff7e4f5ed3764d4261373b.zip |
util: read_cc_from_cmdline handle urlencoded yaml content (#275)
Add support for additional escaping of formatting characters
in the YAML content between the 'cc:' and 'end_cc' tokens. On
s390x legacy terminals the use of square brackets [] are not
available limiting the ability to indicate lists of values in
yaml content. Using #5B and #5D, [ and ] respectively enables
s390x users to pass list yaml content into cloud-init via
command line interface.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 9cc87d7d..89889459 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1048,7 +1048,7 @@ def read_conf_with_confd(cfgfile): def read_conf_from_cmdline(cmdline=None): - # return a dictionary or config on the cmdline or None + # return a dictionary of config on the cmdline or None return load_yaml(read_cc_from_cmdline(cmdline=cmdline)) @@ -1056,11 +1056,12 @@ def read_cc_from_cmdline(cmdline=None): # this should support reading cloud-config information from # the kernel command line. It is intended to support content of the # format: - # cc: <yaml content here> [end_cc] + # cc: <yaml content here|urlencoded yaml content> [end_cc] # this would include: # cc: ssh_import_id: [smoser, kirkland]\\n # cc: ssh_import_id: [smoser, bob]\\nruncmd: [ [ ls, -l ], echo hi ] end_cc # cc:ssh_import_id: [smoser] end_cc cc:runcmd: [ [ ls, -l ] ] end_cc + # cc:ssh_import_id: %5Bsmoser%5D end_cc if cmdline is None: cmdline = get_cmdline() @@ -1075,9 +1076,9 @@ def read_cc_from_cmdline(cmdline=None): end = cmdline.find(tag_end, begin + begin_l) if end < 0: end = clen - tokens.append(cmdline[begin + begin_l:end].lstrip().replace("\\n", - "\n")) - + tokens.append( + parse.unquote( + cmdline[begin + begin_l:end].lstrip()).replace("\\n", "\n")) begin = cmdline.find(tag_begin, end + end_l) return '\n'.join(tokens) |