summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-03-02 15:56:15 -0500
committerScott Moser <smoser@ubuntu.com>2015-03-02 15:56:15 -0500
commita934ae9543ccc9c13fbdedddcc04fa82853a7ec2 (patch)
treeb206a17a678b109ca259f3a18b9c41563dfbf8fd /cloudinit/util.py
parentb2af44fb22719dc353bd867c2648e0dd5b2eec19 (diff)
downloadvyos-cloud-init-a934ae9543ccc9c13fbdedddcc04fa82853a7ec2.tar.gz
vyos-cloud-init-a934ae9543ccc9c13fbdedddcc04fa82853a7ec2.zip
get_cmdline_url: fix in python3 when calling
get_cmdline_url was passing a string to response.contents.startswith() where response.contents is now bytes. this changes it to convert input to text, and also to default to text.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 039aa3f2..cc20305c 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -970,7 +970,7 @@ def get_fqdn_from_hosts(hostname, filename="/etc/hosts"):
def get_cmdline_url(names=('cloud-config-url', 'url'),
- starts="#cloud-config", cmdline=None):
+ starts=b"#cloud-config", cmdline=None):
if cmdline is None:
cmdline = get_cmdline()
@@ -986,6 +986,8 @@ def get_cmdline_url(names=('cloud-config-url', 'url'),
return (None, None, None)
resp = read_file_or_url(url)
+ # allow callers to pass starts as text when comparing to bytes contents
+ starts = encode_text(starts)
if resp.ok() and resp.contents.startswith(starts):
return (key, url, resp.contents)