diff options
author | Joshua Harlow <harlowja@gmail.com> | 2013-01-21 19:51:10 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2013-01-21 19:51:10 -0800 |
commit | 079a670b10ba16420dbb87edf2b6846179b552f6 (patch) | |
tree | 2ccdba0196f3d2f370cb030c6cbc6c23f9219d36 /cloudinit/distros/__init__.py | |
parent | e561742aeab1e8090467f0fa304ee06e82e85f2c (diff) | |
parent | 5d4f4df6804995d74e7962f60dcd72b26bcac69b (diff) | |
download | vyos-cloud-init-079a670b10ba16420dbb87edf2b6846179b552f6.tar.gz vyos-cloud-init-079a670b10ba16420dbb87edf2b6846179b552f6.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']
It also provides a mechanism for operating system family templates.
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r-- | cloudinit/distros/__init__.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 38b2f829..5a2092c0 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 |