From 739e22e929a440a439ef8824893c9b5ada8ac0eb Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sun, 23 Feb 2014 21:14:21 +0100 Subject: [PATCH] Translate release names into codenames. Fixes #15 --- base/bootstrapinfo.py | 4 ++++ base/release-codenames.json | 22 ++++++++++++++++++ common/tasks/network-configuration.json | 27 +++++++++-------------- common/tasks/network.py | 2 +- providers/ec2/tasks/packages-kernels.json | 26 +++++++++------------- providers/ec2/tasks/packages.py | 2 +- 6 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 base/release-codenames.json diff --git a/base/bootstrapinfo.py b/base/bootstrapinfo.py index 2b4bcec..9dfe5c4 100644 --- a/base/bootstrapinfo.py +++ b/base/bootstrapinfo.py @@ -16,6 +16,10 @@ class BootstrapInformation(object): self.apt_mirror = self.manifest.packages.get('mirror', 'http://http.debian.net/debian') + release_codenames_path = os.path.join(os.path.dirname(__file__), 'release-codenames.json') + from common.tools import config_get + self.release_codename = config_get(release_codenames_path, [self.manifest.system['release']]) + class DictClass(dict): def __getattr__(self, name): return self[name] diff --git a/base/release-codenames.json b/base/release-codenames.json new file mode 100644 index 0000000..cac8692 --- /dev/null +++ b/base/release-codenames.json @@ -0,0 +1,22 @@ +{ // This is a mapping of Debian release names to their respective codenames + "unstable": "sid", + "testing": "jessie", + "stable": "wheezy", + "oldstable": "squeeze", + + "jessie": "jessie", + "wheezy": "wheezy", + "squeeze": "squeeze", + + // The following release names are not supported, but included of completeness sake + "lenny": "lenny", + "etch": "etch", + "sarge": "sarge", + "woody": "woody", + "potato": "potato", + "slink": "slink", + "hamm": "hamm", + "bo": "bo", + "rex": "rex", + "buzz": "buzz" +} diff --git a/common/tasks/network-configuration.json b/common/tasks/network-configuration.json index 5a3c533..4e5dce7 100644 --- a/common/tasks/network-configuration.json +++ b/common/tasks/network-configuration.json @@ -1,19 +1,12 @@ +// This is a mapping of Debian release codenames to NIC configurations +// Every item in an array is a line { - "squeeze": [ - "auto lo", - "iface lo inet loopback", - "auto eth0", - "iface eth0 inet dhcp" ], - "wheezy": [ - "auto eth0", - "iface eth0 inet dhcp" ], - "jessie": [ - "auto eth0", - "iface eth0 inet dhcp" ], - "testing": [ - "auto eth0", - "iface eth0 inet dhcp" ], - "unstable": [ - "auto eth0", - "iface eth0 inet dhcp" ] +"squeeze": ["auto lo", + "iface lo inet loopback", + "auto eth0", + "iface eth0 inet dhcp"], +"wheezy": ["auto eth0", + "iface eth0 inet dhcp"], +"jessie": ["auto eth0", + "iface eth0 inet dhcp"] } diff --git a/common/tasks/network.py b/common/tasks/network.py index 3ebdf44..5439718 100644 --- a/common/tasks/network.py +++ b/common/tasks/network.py @@ -31,7 +31,7 @@ class ConfigureNetworkIF(Task): def run(cls, info): network_config_path = os.path.join(os.path.dirname(__file__), 'network-configuration.json') from common.tools import config_get - if_config = config_get(network_config_path, [info.manifest.system['release']]) + if_config = config_get(network_config_path, [info.release_codename]) interfaces_path = os.path.join(info.root, 'etc/network/interfaces') with open(interfaces_path, 'a') as interfaces: diff --git a/providers/ec2/tasks/packages-kernels.json b/providers/ec2/tasks/packages-kernels.json index 6bf1e1c..6d33632 100644 --- a/providers/ec2/tasks/packages-kernels.json +++ b/providers/ec2/tasks/packages-kernels.json @@ -1,18 +1,12 @@ +// This is a mapping of Debian release codenames to processor architectures to kernel packages { - // In squeeze, we need a special kernel flavor for xen - "squeeze": { - "amd64": "linux-image-xen-amd64", - "i386" : "linux-image-xen-686" }, - "wheezy": { - "amd64": "linux-image-amd64", - "i386" : "linux-image-686" }, - "jessie": { - "amd64": "linux-image-amd64", - "i386" : "linux-image-686" }, - "testing": { - "amd64": "linux-image-amd64", - "i386" : "linux-image-686" }, - "unstable": { - "amd64": "linux-image-amd64", - "i386" : "linux-image-686" } +"squeeze": // In squeeze, we need a special kernel flavor for xen + {"i386": "linux-image-xen-686", + "amd64": "linux-image-xen-amd64"}, +"wheezy": + {"i386": "linux-image-686", + "amd64": "linux-image-amd64"}, +"jessie": { + {"i386": "linux-image-686", + "amd64": "linux-image-amd64"}, } diff --git a/providers/ec2/tasks/packages.py b/providers/ec2/tasks/packages.py index ebd49ef..ba2787d 100644 --- a/providers/ec2/tasks/packages.py +++ b/providers/ec2/tasks/packages.py @@ -20,6 +20,6 @@ class DefaultPackages(Task): import os.path kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.json') from common.tools import config_get - kernel_package = config_get(kernel_packages_path, [info.manifest.system['release'], + kernel_package = config_get(kernel_packages_path, [info.release_codename, info.manifest.system['architecture']]) info.packages.add(kernel_package)