diff options
author | Soren Hansen <soren@canonical.com> | 2009-08-11 08:20:55 +0200 |
---|---|---|
committer | Soren Hansen <soren@canonical.com> | 2009-08-11 08:20:55 +0200 |
commit | 6103a0b6567f1a3bdcbac7fd005670676d61ddae (patch) | |
tree | fa127c25cae1ec93d37609dd8d4293708f3a6dab /ec2init | |
parent | d85c3f27482620927de6946e2e8d24c1dc31dfd2 (diff) | |
download | vyos-cloud-init-6103a0b6567f1a3bdcbac7fd005670676d61ddae.tar.gz vyos-cloud-init-6103a0b6567f1a3bdcbac7fd005670676d61ddae.zip |
Remove call to update-motd from the init script. It is Ubuntu specific (and is possibly not even needed there)
Fix a bit of fallout due to code shuffling between EC2Init, ec2-set-apt-sources, and ec2-set-defaults.
Diffstat (limited to 'ec2init')
-rw-r--r-- | ec2init/__init__.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/ec2init/__init__.py b/ec2init/__init__.py index 540b1c13..0288c06e 100644 --- a/ec2init/__init__.py +++ b/ec2init/__init__.py @@ -19,6 +19,7 @@ import os import socket +import time import urllib2 from configobj import ConfigObj @@ -28,6 +29,16 @@ class EC2Init(): api_ver = '2008-02-01' conffile = '/etc/ec2-init/ec2-config.cfg' + location_locale_map = { + 'us' : 'en_US.UTF-8', + 'eu' : 'en_GB.UTF-8' + } + + location_archive_map = { + 'us' : 'http://us.ec2.archive.ubuntu.com/ubuntu', + 'eu' : 'http://eu.ec2.archive.ubuntu.com/ubuntu' + } + def __init__(self): self.meta_data_base_url = 'http://169.254.169.254/%s/meta-data' % self.api_ver self.user_data_base_url = 'http://169.254.169.254/%s/user-data' % self.api_ver @@ -68,7 +79,8 @@ class EC2Init(): return self.get_instance_metadata()['ami-id'] def get_availability_zone(self): - return self.get_instance_metadata()['availability-zone'] + conn = urllib2.urlopen('%s/placement/availability-zone' % self.meta_data_base_url) + return conn.read() def get_hostname(self): hostname = self.get_instance_metadata()['local-hostname'] @@ -76,9 +88,9 @@ class EC2Init(): return hostname def get_mirror_from_availability_zone(self, availability_zone): - if zone.startswith("us"): + if availability_zone.startswith("us"): return 'http://us.ec2.archive.ubuntu.com/ubuntu/' - elif zone.startswith("eu"): + elif availability_zone.startswith("eu"): return 'http://eu.ec2.archive.ubuntu.com/ubuntu/' return 'http://archive.ubuntu.com/ubuntu/' @@ -99,20 +111,11 @@ class EC2Init(): timeout = timeout * 2 return False - def get_location_from_availability_zone(availability_zone): - if availability.startswith('us-'): + def get_location_from_availability_zone(self, availability_zone): + if availability_zone.startswith('us-'): return 'us' - elif availability.startswith('eu-'): + elif availability_zone.startswith('eu-'): return 'eu' raise Exception('Could not determine location') -location_locale_map = { - 'us' : 'en_US.UTF-8', - 'eu' : 'en_GB.UTF-8' -} - -location_archive_map = { - 'us' : 'http://us.ec2.archive.ubuntu.com/ubuntu', - 'eu' : 'http://eu.ec2.archive.ubuntu.com/ubuntu' -} |