summaryrefslogtreecommitdiff
path: root/cloudinit/DataSourceEc2.py
diff options
context:
space:
mode:
authorkeyz182 <keyz182@gmail.com>2011-05-25 11:48:41 +0100
committerkeyz182 <keyz182@gmail.com>2011-05-25 11:48:41 +0100
commit25dc96dafb3ea94d4f798990bcf26825855f899b (patch)
treeab9dcb7677e13b61bb4a5531271a996a7511c5c9 /cloudinit/DataSourceEc2.py
parent707a01fb1af5c8c493b021b782d73d01cd018ae4 (diff)
downloadvyos-cloud-init-25dc96dafb3ea94d4f798990bcf26825855f899b.tar.gz
vyos-cloud-init-25dc96dafb3ea94d4f798990bcf26825855f899b.zip
Modified to reflect changes suggested by Scott Moser
Diffstat (limited to 'cloudinit/DataSourceEc2.py')
-rw-r--r--cloudinit/DataSourceEc2.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/cloudinit/DataSourceEc2.py b/cloudinit/DataSourceEc2.py
index 38284463..2bf7ea8c 100644
--- a/cloudinit/DataSourceEc2.py
+++ b/cloudinit/DataSourceEc2.py
@@ -47,8 +47,8 @@ class DataSourceEc2(DataSource.DataSource):
try:
if not self.wait_for_metadata_service():
return False
- self.userdata_raw = boto_utils.get_instance_userdata(metadata_address,self.api_ver)
- self.metadata = boto_utils.get_instance_metadata(metadata_address,self.api_ver)
+ self.userdata_raw = boto_utils.get_instance_userdata(self.api_ver,None,metadata_address)
+ self.metadata = boto_utils.get_instance_metadata(self.api_ver,metadata_address)
return True
except Exception as e:
print e
@@ -101,27 +101,33 @@ class DataSourceEc2(DataSource.DataSource):
log.warn("Failed to get timeout, using %s" % timeout)
sleeptime = 1
- addresslist = ['169.254.169.254', "instance-data:8773"]
+ addresslist = [['169.254.169.254',80], ["instance-data",8773]]
starttime = time.time()
for x in range(sleeps):
for address in addresslist:
- url="http://%s/%s/meta-data/instance-id" % (address,self.api_ver)
+ host="http://%s:%i/" % (address[0],address[1])
+ url="%s%s/meta-data/instance-id" % (host,self.api_ver)
+
# given 100 sleeps, this ends up total sleep time of 1050 sec
sleeptime=int(x/5)+1
-
+
+
reason = ""
try:
+ socket.getaddrinfo(address[0],address[1])
req = urllib2.Request(url)
resp = urllib2.urlopen(req, timeout=timeout)
if resp.read() != "":
- metadata_address = address
+ metadata_address = host
return True
reason = "empty data [%s]" % resp.getcode()
except urllib2.HTTPError as e:
reason = "http error [%s]" % e.code
except urllib2.URLError as e:
reason = "url error [%s]" % e.reason
+ except socket.gaierror as e:
+ reason = "url error [%s]" % e
if x == 0:
log.warning("waiting for metadata service at %s\n" % url)