diff options
author | Johann Queuniet <jqueuniet@users.noreply.github.com> | 2020-09-18 18:02:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-18 14:02:15 -0400 |
commit | 6b5c306b537aafeded249fc82a3317fba8214508 (patch) | |
tree | dd84ba783caca4c5cc76fd8899ada25759a6d65b /cloudinit/util.py | |
parent | 5fc34d81a002f6ca0706f5285ee15b919c3d8d2e (diff) | |
download | vyos-cloud-init-6b5c306b537aafeded249fc82a3317fba8214508.tar.gz vyos-cloud-init-6b5c306b537aafeded249fc82a3317fba8214508.zip |
Add vendor-data support to seedfrom parameter for NoCloud and OVF (#570)
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 64142f23..e47f1cf6 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -761,8 +761,9 @@ def del_dir(path): # 'meta-data' entries def read_optional_seed(fill, base="", ext="", timeout=5): try: - (md, ud) = read_seeded(base, ext, timeout) + (md, ud, vd) = read_seeded(base, ext, timeout) fill['user-data'] = ud + fill['vendor-data'] = vd fill['meta-data'] = md return True except url_helper.UrlError as e: @@ -840,9 +841,11 @@ def load_yaml(blob, default=None, allowed=(dict,)): def read_seeded(base="", ext="", timeout=5, retries=10, file_retries=0): if base.find("%s") >= 0: ud_url = base % ("user-data" + ext) + vd_url = base % ("vendor-data" + ext) md_url = base % ("meta-data" + ext) else: ud_url = "%s%s%s" % (base, "user-data", ext) + vd_url = "%s%s%s" % (base, "vendor-data", ext) md_url = "%s%s%s" % (base, "meta-data", ext) md_resp = url_helper.read_file_or_url(md_url, timeout=timeout, @@ -857,7 +860,19 @@ def read_seeded(base="", ext="", timeout=5, retries=10, file_retries=0): if ud_resp.ok(): ud = ud_resp.contents - return (md, ud) + vd = None + try: + vd_resp = url_helper.read_file_or_url(vd_url, timeout=timeout, + retries=retries) + except url_helper.UrlError as e: + LOG.debug("Error in vendor-data response: %s", e) + else: + if vd_resp.ok(): + vd = vd_resp.contents + else: + LOG.debug("Error in vendor-data response") + + return (md, ud, vd) def read_conf_d(confd): |