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 | |
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.
-rwxr-xr-x | ec2-init | 2 | ||||
-rwxr-xr-x | ec2-set-defaults.py | 5 | ||||
-rw-r--r-- | ec2init/__init__.py | 33 |
3 files changed, 21 insertions, 19 deletions
@@ -78,8 +78,6 @@ case "$1" in regenerate_ssh_host_keys fi - update-motd - if run_once_ever ec2-defaults then log_daemon_msg "Setting EC2 defaults" diff --git a/ec2-set-defaults.py b/ec2-set-defaults.py index 878d4889..0e0d4843 100755 --- a/ec2-set-defaults.py +++ b/ec2-set-defaults.py @@ -20,6 +20,7 @@ # import subprocess +from Cheetah.Template import Template import ec2init @@ -39,13 +40,13 @@ def apply_locale(locale): subprocess.Popen(['locale-gen', locale]).communicate() subprocess.Popen(['update-locale', locale]).communicate() -def generate_sources_list(self, mirror) +def generate_sources_list(mirror): stdout, stderr = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).communicate() codename = stdout.strip() mp = { 'mirror' : mirror, 'codename' : codename } t = Template(file='/etc/ec2-init/templates/sources.list.tmpl', searchList=[mp]) - f = open(SOURCES_LIST, 'w') + f = open('/etc/apt/sources.list', 'w') f.write(t.respond()) f.close() 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' -} |