diff options
author | Scott Moser <smoser@ubuntu.com> | 2018-05-17 14:59:54 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-05-17 14:59:54 -0600 |
commit | 30e730f7ca111487d243ba9f40c66df6d7a49953 (patch) | |
tree | 89092257336e04adff50668050f1353857058654 /cloudinit/config/cc_phone_home.py | |
parent | 2dab7046f88e540836498b363c90ad46302a7cc4 (diff) | |
download | vyos-cloud-init-30e730f7ca111487d243ba9f40c66df6d7a49953.tar.gz vyos-cloud-init-30e730f7ca111487d243ba9f40c66df6d7a49953.zip |
read_file_or_url: move to url_helper, fix bug in its FileResponse.
The result of a read_file_or_url on a file and on a url would differ
in behavior.
str(UrlResponse) would return UrlResponse.contents.decode('utf-8')
while
str(FileResponse) would return str(FileResponse.contents)
The difference being "b'foo'" versus "foo".
As part of the general goal of cleaning util, move read_file_or_url
into url_helper.
Diffstat (limited to 'cloudinit/config/cc_phone_home.py')
-rw-r--r-- | cloudinit/config/cc_phone_home.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cloudinit/config/cc_phone_home.py b/cloudinit/config/cc_phone_home.py index 878069b7..3be0d1c1 100644 --- a/cloudinit/config/cc_phone_home.py +++ b/cloudinit/config/cc_phone_home.py @@ -41,6 +41,7 @@ keys to post. Available keys are: """ from cloudinit import templater +from cloudinit import url_helper from cloudinit import util from cloudinit.settings import PER_INSTANCE @@ -136,9 +137,9 @@ def handle(name, cfg, cloud, log, args): } url = templater.render_string(url, url_params) try: - util.read_file_or_url(url, data=real_submit_keys, - retries=tries, sec_between=3, - ssl_details=util.fetch_ssl_details(cloud.paths)) + url_helper.read_file_or_url( + url, data=real_submit_keys, retries=tries, sec_between=3, + ssl_details=util.fetch_ssl_details(cloud.paths)) except Exception: util.logexc(log, "Failed to post phone home data to %s in %s tries", url, tries) |