diff options
author | ctracey <ctracey@craigtracey.com> | 2013-01-15 16:08:43 -0500 |
---|---|---|
committer | ctracey <ctracey@craigtracey.com> | 2013-01-15 16:08:43 -0500 |
commit | 361738c6a9a14e32bd2123828fab8d8b70c6bc3a (patch) | |
tree | 797223a4b37cb8d76f6f6134fb9d399399cb4c99 /cloudinit/distros | |
parent | 0c38be4ae18e08640269e2f45e9243ea4867153c (diff) | |
download | vyos-cloud-init-361738c6a9a14e32bd2123828fab8d8b70c6bc3a.tar.gz vyos-cloud-init-361738c6a9a14e32bd2123828fab8d8b70c6bc3a.zip |
add support for operating system families
often it is convenient to classify a distro as being part of an
operating system family. for instance, file templates may be
identical for both debian and ubuntu, but to support this under
the current templating code, one would need multiple templates for the
same code.
similarly, configuration handlers often fall into the same bucket: the
configuraton is known to work/has been tested on a particular family
of operating systems. right now this is handled with a declaration
like:
distros = ['fedora', 'rhel']
this fix seeks to address both of these issues. it allows for the
simplification of the above line to:
osfamilies = ['redhat']
and provides a mechanism for operating system family templates.
Diffstat (limited to 'cloudinit/distros')
-rw-r--r-- | cloudinit/distros/__init__.py | 16 | ||||
-rw-r--r-- | cloudinit/distros/debian.py | 1 | ||||
-rw-r--r-- | cloudinit/distros/rhel.py | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 38b2f829..ff325b40 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -35,6 +35,11 @@ from cloudinit import util from cloudinit.distros.parsers import hosts +OSFAMILIES = { + 'debian': ['debian', 'ubuntu'], + 'redhat': ['fedora', 'rhel'] +} + LOG = logging.getLogger(__name__) @@ -143,6 +148,16 @@ class Distro(object): def _select_hostname(self, hostname, fqdn): raise NotImplementedError() + @staticmethod + def expand_osfamily(family_list): + distros = [] + for family in family_list: + if not family in OSFAMILIES: + raise ValueError("No distibutions found for osfamily %s" + % (family)) + distros.extend(OSFAMILIES[family]) + return distros + def update_hostname(self, hostname, fqdn, prev_hostname_fn): applying_hostname = hostname @@ -515,7 +530,6 @@ def _get_package_mirror_info(mirror_info, availability_zone=None, return results - def _get_arch_package_mirror_info(package_mirrors, arch): # pull out the specific arch from a 'package_mirrors' config option default = None diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index 7422f4f0..49b73477 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -48,6 +48,7 @@ class Distro(distros.Distro): # calls from repeatly happening (when they # should only happen say once per instance...) self._runner = helpers.Runners(paths) + self.osfamily = 'debian' def apply_locale(self, locale, out_fn=None): if not out_fn: diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index bc0877d5..e65be8d7 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -60,6 +60,7 @@ class Distro(distros.Distro): # calls from repeatly happening (when they # should only happen say once per instance...) self._runner = helpers.Runners(paths) + self.osfamily = 'redhat' def install_packages(self, pkglist): self.package_command('install', pkglist) |