diff options
author | Soren Hansen <soren@canonical.com> | 2009-08-10 21:01:08 +0200 |
---|---|---|
committer | Soren Hansen <soren@canonical.com> | 2009-08-10 21:01:08 +0200 |
commit | fb6561d590b494b25f96489eda89adfad6bd557a (patch) | |
tree | f1bece3a6a6ff653b39d1c95bdaf2e200dc30b37 /ec2-set-defaults.py | |
parent | e822aba1d8ded633f9f5dbea215a0e708c2c4267 (diff) | |
download | vyos-cloud-init-fb6561d590b494b25f96489eda89adfad6bd557a.tar.gz vyos-cloud-init-fb6561d590b494b25f96489eda89adfad6bd557a.zip |
Moved mappings from ec2-set-sources-list to ec2init.
Moved everything else from ec2-set-sources-list to ec2-set-defaults.
Removed call to ec2-set-sources-list from init script.
Removed ec2-set-sources-list.
Diffstat (limited to 'ec2-set-defaults.py')
-rwxr-xr-x | ec2-set-defaults.py | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/ec2-set-defaults.py b/ec2-set-defaults.py index f6d6a038..878d4889 100755 --- a/ec2-set-defaults.py +++ b/ec2-set-defaults.py @@ -3,8 +3,8 @@ # Fetch the availabity zone and create the sources.list # Copyright (C) 2008-2009 Canonical Ltd. # -# Author: Chuck Short <chuck.short@canonical.com> -# Soren Hansen <soren@canonical.com> +# Authors: Chuck Short <chuck.short@canonical.com> +# Soren Hansen <soren@canonical.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3, as @@ -23,31 +23,31 @@ import subprocess import ec2init -def get_location_from_availability_zone(availability_zone): - if availability.startswith('us-'): - return 'us' - elif availability.startswith('eu-'): - return 'eu' - raise Exception('Could not determine location') - -location_archive_map = { - 'us' : 'http://us.ec2.archive.ubuntu.com/ubuntu', - 'eu' : 'http://eu.ec2.archive.ubuntu.com/ubuntu' -} - -location_locale_map = { - 'us' : 'en_US.UTF-8', - 'eu' : 'en_GB.UTF-8' -} - def main(): ec2 = ec2init.EC2Init() - location = get_location_from_availability_zone(ec2.get_availability_zone()) + availability_zone = ec2.get_availability_zone() + location = ec2.get_location_from_availability_zone(availability_zone) + mirror = ec2.get_mirror_from_availability_zone(availability_zone) + + locale = ec2.location_locale_map[location] + apply_locale(locale) + + generate_sources_list(mirror) + +def apply_locale(locale): + subprocess.Popen(['locale-gen', locale]).communicate() + subprocess.Popen(['update-locale', locale]).communicate() + +def generate_sources_list(self, mirror) + stdout, stderr = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).communicate() + codename = stdout.strip() - locale = location_locale_map[location] - subprocess.Popen(['locale-gen', locale]).communicate() - subprocess.Popen(['update-locale', locale]).communicate() + mp = { 'mirror' : mirror, 'codename' : codename } + t = Template(file='/etc/ec2-init/templates/sources.list.tmpl', searchList=[mp]) + f = open(SOURCES_LIST, 'w') + f.write(t.respond()) + f.close() if __name__ == '__main__': main() |