summaryrefslogtreecommitdiff
path: root/cloudinit/user_data.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2017-11-21 11:43:26 -0700
committerChad Smith <chad.smith@canonical.com>2017-11-21 11:43:26 -0700
commit5b974bbab161e6cd73751bf27b7741f6b0d19051 (patch)
treef634411a9b12b2e36ff8beefbec39dad21cd45ea /cloudinit/user_data.py
parentc9c7ff70f55ee024dd54336f07ba52acec1f6929 (diff)
parent7624348712b4502f0085d30c05b34dce3f2ceeae (diff)
downloadvyos-cloud-init-5b974bbab161e6cd73751bf27b7741f6b0d19051.tar.gz
vyos-cloud-init-5b974bbab161e6cd73751bf27b7741f6b0d19051.zip
merge from 7624348712b4502f0085d30c05b34dce3f2ceeae at 17.1-41-g76243487
Diffstat (limited to 'cloudinit/user_data.py')
-rw-r--r--cloudinit/user_data.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py
index 88cb7f84..cc55daf8 100644
--- a/cloudinit/user_data.py
+++ b/cloudinit/user_data.py
@@ -19,6 +19,7 @@ import six
from cloudinit import handlers
from cloudinit import log as logging
+from cloudinit.url_helper import UrlError
from cloudinit import util
LOG = logging.getLogger(__name__)
@@ -222,16 +223,28 @@ class UserDataProcessor(object):
if include_once_on and os.path.isfile(include_once_fn):
content = util.load_file(include_once_fn)
else:
- resp = util.read_file_or_url(include_url,
- ssl_details=self.ssl_details)
- if include_once_on and resp.ok():
- util.write_file(include_once_fn, resp.contents, mode=0o600)
- if resp.ok():
- content = resp.contents
- else:
- LOG.warning(("Fetching from %s resulted in"
- " a invalid http code of %s"),
- include_url, resp.code)
+ try:
+ resp = util.read_file_or_url(include_url,
+ ssl_details=self.ssl_details)
+ if include_once_on and resp.ok():
+ util.write_file(include_once_fn, resp.contents,
+ mode=0o600)
+ if resp.ok():
+ content = resp.contents
+ else:
+ LOG.warning(("Fetching from %s resulted in"
+ " a invalid http code of %s"),
+ include_url, resp.code)
+ except UrlError as urle:
+ message = str(urle)
+ # Older versions of requests.exceptions.HTTPError may not
+ # include the errant url. Append it for clarity in logs.
+ if include_url not in message:
+ message += ' for url: {0}'.format(include_url)
+ LOG.warning(message)
+ except IOError as ioe:
+ LOG.warning("Fetching from %s resulted in %s",
+ include_url, ioe)
if content is not None:
new_msg = convert_string(content)