summaryrefslogtreecommitdiff
path: root/cloudinit/user_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/user_data.py')
-rw-r--r--cloudinit/user_data.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py
index 663f7cda..bf34943d 100644
--- a/cloudinit/user_data.py
+++ b/cloudinit/user_data.py
@@ -121,19 +121,25 @@ class UserDataProcessor(object):
continue
include_once_fn = None
+ content = None
if include_once_on:
include_once_fn = self._get_include_once_filename(include_url)
if include_once_on and os.path.isfile(include_once_fn):
content = util.load_file(include_once_fn)
else:
- (content, st) = url_helper.readurl(include_url)
- if include_once_on and url_helper.ok_http_code(st):
- util.write_file(include_once_fn, content, mode=0600)
- if not url_helper.ok_http_code(st):
- content = ''
-
- new_msg = convert_string(content)
- self._process_msg(new_msg, append_msg)
+ resp = url_helper.readurl(include_url)
+ if include_once_on and resp.ok():
+ util.write_file(include_once_fn, str(resp), mode=0600)
+ if resp.ok():
+ content = str(resp)
+ else:
+ LOG.warn(("Fetching from %s resulted in"
+ " a invalid http code of %s"),
+ include_url, resp.code)
+
+ if content is not None:
+ new_msg = convert_string(content)
+ self._process_msg(new_msg, append_msg)
def _explode_archive(self, archive, append_msg):
entries = util.load_yaml(archive, default=[], allowed=[list, set])