diff options
author | Scott Moser <smoser@ubuntu.com> | 2013-04-25 14:03:16 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2013-04-25 14:03:16 -0400 |
commit | 4697c1afcc7d05951f4717a83dad01d2360301c6 (patch) | |
tree | 6d66840f102c71fb7dbd3eafc044cc5e75531d58 /cloudinit/sources/DataSourceMAAS.py | |
parent | 8e97ca8cfaf75edc0b05b0dc2a2ef35c5c82221b (diff) | |
parent | a69c9c8a35b61f69f6e959448af8d0619989589f (diff) | |
download | vyos-cloud-init-4697c1afcc7d05951f4717a83dad01d2360301c6.tar.gz vyos-cloud-init-4697c1afcc7d05951f4717a83dad01d2360301c6.zip |
Fix issue in readurl with requests, support passing through headers_cb
This adds the 'headers_cb' option to pass all the way through to readurl.
It also makes requests for user-data not retry (as a 404 indicates "no
user-data").
LP: #1172742
Diffstat (limited to 'cloudinit/sources/DataSourceMAAS.py')
-rw-r--r-- | cloudinit/sources/DataSourceMAAS.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/cloudinit/sources/DataSourceMAAS.py b/cloudinit/sources/DataSourceMAAS.py index de822924..dfe90bc6 100644 --- a/cloudinit/sources/DataSourceMAAS.py +++ b/cloudinit/sources/DataSourceMAAS.py @@ -218,14 +218,20 @@ def read_maas_seed_url(seed_url, header_cb=None, timeout=None, md = {} for name in file_order: url = files.get(name) - if header_cb: - headers = header_cb(url) + if not header_cb: + def _cb(url): + return {} + header_cb = _cb + + if name == 'user-data': + retries = 0 else: - headers = {} + retries = None + try: ssl_details = util.fetch_ssl_details(paths) - resp = util.read_file_or_url(url, - headers=headers, + resp = util.read_file_or_url(url, retries=retries, + headers_cb=header_cb, timeout=timeout, ssl_details=ssl_details) if resp.ok(): |