summaryrefslogtreecommitdiff
path: root/ec2init/__init__.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2009-12-14 16:17:41 -0500
committerScott Moser <smoser@ubuntu.com>2009-12-14 16:17:41 -0500
commit7bc6bbe8c4475151ee196ced344d1f045486bc1f (patch)
tree46e93df233833c5b59700420ae495f7b738e8299 /ec2init/__init__.py
parent2e5e426e406c4b72942020460993e5fb91dcb9b6 (diff)
downloadvyos-cloud-init-7bc6bbe8c4475151ee196ced344d1f045486bc1f.tar.gz
vyos-cloud-init-7bc6bbe8c4475151ee196ced344d1f045486bc1f.zip
sync karmic and trunk
This commit merges lp:~soren/ec2-init/0.5 at rev 67 and lp:ubuntu/lucid at 0.4.999-0ubuntu8
Diffstat (limited to 'ec2init/__init__.py')
-rw-r--r--ec2init/__init__.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/ec2init/__init__.py b/ec2init/__init__.py
index 0f161d7d..3bd1d23e 100644
--- a/ec2init/__init__.py
+++ b/ec2init/__init__.py
@@ -88,12 +88,13 @@ class EC2Init():
return hostname
def get_mirror_from_availability_zone(self, availability_zone):
- if availability_zone.startswith("us"):
- return 'http://us.ec2.archive.ubuntu.com/ubuntu/'
- elif availability_zone.startswith("eu"):
- return 'http://eu.ec2.archive.ubuntu.com/ubuntu/'
-
- return 'http://archive.ubuntu.com/ubuntu/'
+ # availability is like 'us-west-1b' or 'eu-west-1a'
+ try:
+ host="%s.ec2.archive.ubuntu.com" % availability_zone[:-1]
+ socket.getaddrinfo(host, None, 0, socket.SOCK_STREAM)
+ return 'http://%s/ubuntu/' % host
+ except:
+ return 'http://archive.ubuntu.com/ubuntu/'
def wait_for_metadata_service(self):
timeout = 2