diff options
| author | Scott Moser <smoser@ubuntu.com> | 2012-04-05 00:49:11 -0400 |
|---|---|---|
| committer | Scott Moser <smoser@ubuntu.com> | 2012-04-05 00:49:11 -0400 |
| commit | c2a4447527d5e8b2e2999b6f1832577203a64f2a (patch) | |
| tree | aa58108146e35f5ab5d93500c1116bcad12d6ce8 /cloudinit/__init__.py | |
| parent | b39abf5bbe51d62d1ef1dd1e813720eafc1ddc85 (diff) | |
| parent | 6d62fe860f55faf2d7b0b6216c11305e114c5214 (diff) | |
| download | vyos-cloud-init-c2a4447527d5e8b2e2999b6f1832577203a64f2a.tar.gz vyos-cloud-init-c2a4447527d5e8b2e2999b6f1832577203a64f2a.zip | |
Allow a url to cloud-config data to be specified on kernel config line
In order to allow an ephemeral, or otherwise pristine image to
receive some configuration, cloud-init will read a url directed by
the kernel command line and proceed as if its data had previously existed.
For more information, see doc/kernel-cmdline.txt
Diffstat (limited to 'cloudinit/__init__.py')
| -rw-r--r-- | cloudinit/__init__.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py index 6d276d84..85c6fd1b 100644 --- a/cloudinit/__init__.py +++ b/cloudinit/__init__.py @@ -137,7 +137,9 @@ class CloudInit: if ds_deps != None: self.ds_deps = ds_deps + self.sysconfig = sysconfig + self.cfg = self.read_cfg() def read_cfg(self): @@ -639,3 +641,27 @@ class InternalPartHandler: def handle_part(self, data, ctype, filename, payload, frequency): return(self.handler(data, ctype, filename, payload, frequency)) + + +def get_cmdline_url(names=('cloud-config-url', 'url'), + starts="#cloud-config", cmdline=None): + + if cmdline == None: + cmdline = util.get_cmdline() + + data = util.keyval_str_to_dict(cmdline) + url = None + key = None + for key in names: + if key in data: + url = data[key] + break + if url == None: + return (None, None, None) + + contents = util.readurl(url) + + if contents.startswith(starts): + return (key, url, contents) + + return (key, url, None) |
