summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorharlowja <harlowja@virtualbox.rhel>2012-06-17 18:23:24 -0700
committerharlowja <harlowja@virtualbox.rhel>2012-06-17 18:23:24 -0700
commitb6f158b8a55f37d9d2854ff0e566298b85cc0c89 (patch)
tree706d434f19edf151d51072a32c41f3baa26093cc /cloudinit/util.py
parentbc5322d2bc81b2421ae8dfe1bb02fa2fd61fed51 (diff)
downloadvyos-cloud-init-b6f158b8a55f37d9d2854ff0e566298b85cc0c89.tar.gz
vyos-cloud-init-b6f158b8a55f37d9d2854ff0e566298b85cc0c89.zip
1. Add a url response class that urlreading now returns (instead of a tuple).
a. This allows for more properties to be added as needed in the future, instead of being very restrictive. 2. Fix up all uses of the url reading to now use this new response object. 3. Also fixup user data including, such that if no response actual occurs the url content is not further processed.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 11986447..b6fa959b 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -595,14 +595,16 @@ def read_seeded(base="", ext="", timeout=5, retries=10, file_retries=0):
ud_url = "%s%s%s" % (base, "user-data", ext)
md_url = "%s%s%s" % (base, "meta-data", ext)
- (md_str, msc) = read_file_or_url(md_url, timeout, retries, file_retries)
+ md_resp = read_file_or_url(md_url, timeout, retries, file_retries)
md = None
- if md_str and uhelp.ok_http_code(msc):
+ if md_resp.ok():
+ md_str = str(md_resp)
md = load_yaml(md_str, default={})
- (ud_str, usc) = read_file_or_url(ud_url, timeout, retries, file_retries)
+ ud_resp = read_file_or_url(ud_url, timeout, retries, file_retries)
ud = None
- if ud_str and uhelp.ok_http_code(usc):
+ if ud_resp.ok():
+ ud_str = str(ud_resp)
ud = ud_str
return (md, ud)
@@ -769,9 +771,9 @@ def get_cmdline_url(names=None, starts=None, cmdline=None):
if not url:
return (None, None, None)
- (contents, sc) = uhelp.readurl(url)
- if contents.startswith(starts) and uhelp.ok_http_code(sc):
- return (key, url, contents)
+ resp = uhelp.readurl(url)
+ if resp.contents.startswith(starts) and resp.ok():
+ return (key, url, str(resp))
return (key, url, None)