diff options
author | harlowja <harlowja@virtualbox.rhel> | 2013-02-19 22:51:49 -0800 |
---|---|---|
committer | harlowja <harlowja@virtualbox.rhel> | 2013-02-19 22:51:49 -0800 |
commit | 6d40d5b2e3da9577d4a2686444d47125e62817fe (patch) | |
tree | 3dc28b3e6157513aedb4a21fcabf35aaefaf5e1f /cloudinit/sources/DataSourceMAAS.py | |
parent | 6a6a2f7c337e18d84d7031ba60d5adf6a93256fc (diff) | |
download | vyos-cloud-init-6d40d5b2e3da9577d4a2686444d47125e62817fe.tar.gz vyos-cloud-init-6d40d5b2e3da9577d4a2686444d47125e62817fe.zip |
Continue working on integrating requests.
Diffstat (limited to 'cloudinit/sources/DataSourceMAAS.py')
-rw-r--r-- | cloudinit/sources/DataSourceMAAS.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cloudinit/sources/DataSourceMAAS.py b/cloudinit/sources/DataSourceMAAS.py index e187aec9..2de31305 100644 --- a/cloudinit/sources/DataSourceMAAS.py +++ b/cloudinit/sources/DataSourceMAAS.py @@ -25,9 +25,11 @@ import os import time import urllib2 +import requests + from cloudinit import log as logging from cloudinit import sources -from cloudinit import url_helper as uhelp +from cloudinit import url_helper from cloudinit import util LOG = logging.getLogger(__name__) @@ -191,8 +193,8 @@ def read_maas_seed_url(seed_url, header_cb=None, timeout=None, version=MD_VERSION): """ Read the maas datasource at seed_url. - header_cb is a method that should return a headers dictionary that will - be given to urllib2.Request() + - header_cb is a method that should return a headers dictionary for + a given url Expected format of seed_url is are the following files: * <seed_url>/<version>/meta-data/instance-id @@ -220,13 +222,13 @@ def read_maas_seed_url(seed_url, header_cb=None, timeout=None, else: headers = {} try: - resp = uhelp.readurl(url, headers=headers, timeout=timeout) - if resp.ok(): + resp = util.read_file_or_url(url, headers=headers, timeout=timeout) + if resp.ok: md[name] = str(resp) else: LOG.warn(("Fetching from %s resulted in" - " an invalid http code %s"), url, resp.code) - except urllib2.HTTPError as e: + " an invalid http code %s"), url, resp.status_code) + except url_helper.UrlError as e: if e.code != 404: raise return check_seed_contents(md, seed_url) |