diff options
author | Scott Moser <smoser@ubuntu.com> | 2010-09-16 04:41:23 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2010-09-16 04:41:23 -0400 |
commit | 0de2a6740a459d1f74e4f05e688621f2597c7148 (patch) | |
tree | 3cd650fe49ea8cf8800384dda392c1f0d346ece4 /cloudinit | |
parent | 1a29c3d5b10f77a9668576eb49bf9e429166fe5c (diff) | |
download | vyos-cloud-init-0de2a6740a459d1f74e4f05e688621f2597c7148.tar.gz vyos-cloud-init-0de2a6740a459d1f74e4f05e688621f2597c7148.zip |
If instance is in EC2 VPC, then do not use ec2 ubuntu archive (LP: #615545)
VPC instances cannot reach other hosts in EC2 (such as the archives).
In this case, use the default mirror instead.
LP: #615545
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/DataSourceEc2.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/cloudinit/DataSourceEc2.py b/cloudinit/DataSourceEc2.py index 3eacf99a..7a6c9dc9 100644 --- a/cloudinit/DataSourceEc2.py +++ b/cloudinit/DataSourceEc2.py @@ -83,12 +83,17 @@ class DataSourceEc2(DataSource.DataSource): if availability_zone == None: availability_zone = self.get_availability_zone() + fallback = 'http://archive.ubuntu.com/ubuntu/' + + if self.is_vpc(): + return fallback + 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/' + return fallback def wait_for_metadata_service(self, sleeps = 100): @@ -165,3 +170,11 @@ class DataSourceEc2(DataSource.DataSource): cloudinit.log.debug("remapped device name %s => %s" % (found,cand)) return(cand) return ofound + + def is_vpc(self): + # per comment in LP: #615545 + ph="public-hostname"; p4="public-ipv4" + if ((ph not in self.metadata or self.metadata[ph] == "") and + (p4 not in self.metadata or self.metadata[p4] == "")): + return True + return False |