summaryrefslogtreecommitdiff
path: root/cloudinit/ec2_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/ec2_utils.py')
-rw-r--r--cloudinit/ec2_utils.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/cloudinit/ec2_utils.py b/cloudinit/ec2_utils.py
index 6b2754aa..87644c40 100644
--- a/cloudinit/ec2_utils.py
+++ b/cloudinit/ec2_utils.py
@@ -135,8 +135,9 @@ class MetadataMaterializer(object):
return joined
-def get_instance_userdata(api_version, metadata_address, ssl_details=None):
- ud_url = combine_url(metadata_address, api_version)
+def get_instance_userdata(version='latest', url='http://169.254.169.254',
+ ssl_details=None):
+ ud_url = combine_url(url, version)
ud_url = combine_url(ud_url, 'user-data')
try:
response = util.read_file_or_url(ud_url, ssl_details=ssl_details)
@@ -146,11 +147,13 @@ def get_instance_userdata(api_version, metadata_address, ssl_details=None):
return None
-def get_instance_metadata(api_version, metadata_address, ssl_details=None):
- md_url = combine_url(metadata_address, api_version)
+def get_instance_metadata(version='latest', url='http://169.254.169.254',
+ ssl_details=None, timeout=5, num_retries=5)
+ md_url = combine_url(metadata_address, version)
md_url = combine_url(md_url, 'meta-data')
try:
- response = util.read_file_or_url(md_url, ssl_details=ssl_details)
+ response = util.read_file_or_url(md_url, ssl_details=ssl_details,
+ timeout=timeout, retries=num_retries)
materializer = MetadataMaterializer(str(response), md_url, ssl_details)
return materializer.materialize()
except Exception: