← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~nathan-house-0/cloud-init/gentoo into lp:cloud-init

 

Nathan House has proposed merging lp:~nathan-house-0/cloud-init/gentoo into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~nathan-house-0/cloud-init/gentoo/+merge/204590

Adds exclude_modules support as a Distro list attribute to prevent modules such as apt-configure handle to run and stacktrace in the logs etc.

Adds gentoo distro class with working basic functionality.  Haven't gone thru all of the modules but a majority are now working as expected. 

Adds gentoo runscript init scripts.
-- 
https://code.launchpad.net/~nathan-house-0/cloud-init/gentoo/+merge/204590
Your team cloud init development team is requested to review the proposed merge of lp:~nathan-house-0/cloud-init/gentoo into lp:cloud-init.
=== modified file 'cloudinit/config/cc_apt_configure.py'
--- cloudinit/config/cc_apt_configure.py	2013-11-19 17:23:44 +0000
+++ cloudinit/config/cc_apt_configure.py	2014-02-03 23:17:12 +0000
@@ -51,6 +51,8 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+    if cloud.distro.is_excluded(name):
+        return
     release = get_release()
     mirrors = find_apt_mirror_info(cloud, cfg)
     if not mirrors or "primary" not in mirrors:

=== modified file 'cloudinit/config/cc_apt_pipelining.py'
--- cloudinit/config/cc_apt_pipelining.py	2012-10-28 02:25:48 +0000
+++ cloudinit/config/cc_apt_pipelining.py	2014-02-03 23:17:12 +0000
@@ -35,7 +35,8 @@
 
 
 def handle(_name, cfg, _cloud, log, _args):
-
+    if _cloud.distro.is_excluded(_name):
+        return
     apt_pipe_value = util.get_cfg_option_str(cfg, "apt_pipelining", False)
     apt_pipe_value_s = str(apt_pipe_value).lower().strip()
 

=== modified file 'cloudinit/config/cc_byobu.py'
--- cloudinit/config/cc_byobu.py	2012-09-28 21:17:42 +0000
+++ cloudinit/config/cc_byobu.py	2014-02-03 23:17:12 +0000
@@ -29,6 +29,7 @@
 
 
 def handle(name, cfg, cloud, log, args):
+
     if len(args) != 0:
         value = args[0]
     else:

=== modified file 'cloudinit/config/cc_ca_certs.py'
--- cloudinit/config/cc_ca_certs.py	2012-12-02 02:46:27 +0000
+++ cloudinit/config/cc_ca_certs.py	2014-02-03 23:17:12 +0000
@@ -79,6 +79,7 @@
     @param args: Any module arguments from cloud.cfg
     """
     # If there isn't a ca-certs section in the configuration don't do anything
+
     if "ca-certs" not in cfg:
         log.debug(("Skipping module named %s,"
                    " no 'ca-certs' key in configuration"), name)

=== modified file 'cloudinit/config/cc_disk_setup.py'
--- cloudinit/config/cc_disk_setup.py	2013-10-04 22:29:12 +0000
+++ cloudinit/config/cc_disk_setup.py	2014-02-03 23:17:12 +0000
@@ -40,6 +40,7 @@
     See doc/examples/cloud-config_disk-setup.txt for documentation on the
     format.
     """
+
     disk_setup = cfg.get("disk_setup")
     if isinstance(disk_setup, dict):
         update_disk_setup_devices(disk_setup, cloud.device_name_to_device)

=== modified file 'cloudinit/config/cc_emit_upstart.py'
--- cloudinit/config/cc_emit_upstart.py	2012-08-22 18:12:32 +0000
+++ cloudinit/config/cc_emit_upstart.py	2014-02-03 23:17:12 +0000
@@ -29,6 +29,8 @@
 
 
 def handle(name, _cfg, cloud, log, args):
+    if cloud.distro.is_excluded(name):
+        return
     event_names = args
     if not event_names:
         # Default to the 'cloud-config'

=== modified file 'cloudinit/config/cc_growpart.py'
--- cloudinit/config/cc_growpart.py	2014-01-24 20:29:09 +0000
+++ cloudinit/config/cc_growpart.py	2014-02-03 23:17:12 +0000
@@ -255,6 +255,7 @@
 
 
 def handle(_name, cfg, _cloud, log, _args):
+
     if 'growpart' not in cfg:
         log.debug("No 'growpart' entry in cfg.  Using default: %s" %
                   DEFAULT_CONFIG)

=== modified file 'cloudinit/config/cc_grub_dpkg.py'
--- cloudinit/config/cc_grub_dpkg.py	2012-06-23 22:06:26 +0000
+++ cloudinit/config/cc_grub_dpkg.py	2014-02-03 23:17:12 +0000
@@ -26,9 +26,12 @@
 
 
 def handle(_name, cfg, _cloud, log, _args):
+
     idevs = None
     idevs_empty = None
 
+    if _cloud.distro.is_excluded(_name):
+        return
     if "grub-dpkg" in cfg:
         idevs = util.get_cfg_option_str(cfg["grub-dpkg"],
             "grub-pc/install_devices", None)

=== modified file 'cloudinit/config/cc_keys_to_console.py'
--- cloudinit/config/cc_keys_to_console.py	2012-07-02 17:56:22 +0000
+++ cloudinit/config/cc_keys_to_console.py	2014-02-03 23:17:12 +0000
@@ -30,6 +30,8 @@
 
 
 def handle(name, cfg, _cloud, log, _args):
+    if _cloud.distro.is_excluded(name):
+        return
     if not os.path.exists(HELPER_TOOL):
         log.warn(("Unable to activate module %s,"
                   " helper tool not found at %s"), name, HELPER_TOOL)

=== modified file 'cloudinit/config/cc_locale.py'
--- cloudinit/config/cc_locale.py	2012-06-22 02:46:16 +0000
+++ cloudinit/config/cc_locale.py	2014-02-03 23:17:12 +0000
@@ -22,6 +22,7 @@
 
 
 def handle(name, cfg, cloud, log, args):
+
     if len(args) != 0:
         locale = args[0]
     else:

=== modified file 'cloudinit/config/cc_migrator.py'
--- cloudinit/config/cc_migrator.py	2012-11-13 20:25:57 +0000
+++ cloudinit/config/cc_migrator.py	2014-02-03 23:17:12 +0000
@@ -75,6 +75,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     do_migrate = util.get_cfg_option_str(cfg, "migrate", True)
     if not util.translate_bool(do_migrate):
         log.debug("Skipping module named %s, migration disabled", name)

=== modified file 'cloudinit/config/cc_mounts.py'
--- cloudinit/config/cc_mounts.py	2013-10-08 00:08:13 +0000
+++ cloudinit/config/cc_mounts.py	2014-02-03 23:17:12 +0000
@@ -76,6 +76,7 @@
 
 
 def handle(_name, cfg, cloud, log, _args):
+
     # fs_spec, fs_file, fs_vfstype, fs_mntops, fs-freq, fs_passno
     defvals = [None, None, "auto", "defaults,nobootwait", "0", "2"]
     defvals = cfg.get("mount_default_fields", defvals)

=== modified file 'cloudinit/config/cc_package_update_upgrade_install.py'
--- cloudinit/config/cc_package_update_upgrade_install.py	2012-10-17 04:14:51 +0000
+++ cloudinit/config/cc_package_update_upgrade_install.py	2014-02-03 23:17:12 +0000
@@ -49,6 +49,7 @@
 
 
 def handle(_name, cfg, cloud, log, _args):
+
     # Handle the old style + new config names
     update = _multi_cfg_bool_get(cfg, 'apt_update', 'package_update')
     upgrade = _multi_cfg_bool_get(cfg, 'package_upgrade', 'apt_upgrade')

=== modified file 'cloudinit/config/cc_phone_home.py'
--- cloudinit/config/cc_phone_home.py	2013-06-19 06:44:00 +0000
+++ cloudinit/config/cc_phone_home.py	2014-02-03 23:17:12 +0000
@@ -44,6 +44,7 @@
 #  post: [ pub_key_dsa, pub_key_rsa, pub_key_ecdsa, instance_id
 #
 def handle(name, cfg, cloud, log, args):
+
     if len(args) != 0:
         ph_cfg = util.read_conf(args[0])
     else:

=== modified file 'cloudinit/config/cc_puppet.py'
--- cloudinit/config/cc_puppet.py	2013-01-28 02:48:03 +0000
+++ cloudinit/config/cc_puppet.py	2014-02-03 23:17:12 +0000
@@ -49,6 +49,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     # If there isn't a puppet key in the configuration don't do anything
     if 'puppet' not in cfg:
         log.debug(("Skipping module named %s,"

=== modified file 'cloudinit/config/cc_resizefs.py'
--- cloudinit/config/cc_resizefs.py	2014-01-23 20:17:17 +0000
+++ cloudinit/config/cc_resizefs.py	2014-02-03 23:17:12 +0000
@@ -76,6 +76,7 @@
 
 
 def handle(name, cfg, _cloud, log, args):
+
     if len(args) != 0:
         resize_root = args[0]
     else:

=== modified file 'cloudinit/config/cc_resolv_conf.py'
--- cloudinit/config/cc_resolv_conf.py	2013-06-27 11:50:33 +0000
+++ cloudinit/config/cc_resolv_conf.py	2014-02-03 23:17:12 +0000
@@ -92,6 +92,7 @@
     @param log: Pre-initialized Python logger object to use for logging.
     @param args: Any module arguments from cloud.cfg
     """
+
     if "manage_resolv_conf" not in cfg:
         log.debug(("Skipping module named %s,"
                    " no 'manage_resolv_conf' key in configuration"), name)

=== modified file 'cloudinit/config/cc_rightscale_userdata.py'
--- cloudinit/config/cc_rightscale_userdata.py	2013-06-19 06:44:00 +0000
+++ cloudinit/config/cc_rightscale_userdata.py	2014-02-03 23:17:12 +0000
@@ -50,6 +50,7 @@
 
 
 def handle(name, _cfg, cloud, log, _args):
+
     try:
         ud = cloud.get_userdata_raw()
     except:

=== modified file 'cloudinit/config/cc_rsyslog.py'
--- cloudinit/config/cc_rsyslog.py	2012-10-28 02:25:48 +0000
+++ cloudinit/config/cc_rsyslog.py	2014-02-03 23:17:12 +0000
@@ -35,6 +35,7 @@
     #      *.*   @@syslogd.example.com
 
     # process 'rsyslog'
+
     if not 'rsyslog' in cfg:
         log.debug(("Skipping module named %s,"
                    " no 'rsyslog' key in configuration"), name)

=== modified file 'cloudinit/config/cc_salt_minion.py'
--- cloudinit/config/cc_salt_minion.py	2013-01-28 02:48:03 +0000
+++ cloudinit/config/cc_salt_minion.py	2014-02-03 23:17:12 +0000
@@ -22,6 +22,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     # If there isn't a salt key in the configuration don't do anything
     if 'salt_minion' not in cfg:
         log.debug(("Skipping module named %s,"

=== modified file 'cloudinit/config/cc_seed_random.py'
--- cloudinit/config/cc_seed_random.py	2013-09-09 05:36:28 +0000
+++ cloudinit/config/cc_seed_random.py	2014-02-03 23:17:12 +0000
@@ -39,6 +39,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     if not cfg or "random_seed" not in cfg:
         log.debug(("Skipping module named %s, "
                    "no 'random_seed' configuration found"), name)

=== modified file 'cloudinit/config/cc_set_hostname.py'
--- cloudinit/config/cc_set_hostname.py	2013-06-19 06:44:00 +0000
+++ cloudinit/config/cc_set_hostname.py	2014-02-03 23:17:12 +0000
@@ -22,6 +22,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     if util.get_cfg_option_bool(cfg, "preserve_hostname", False):
         log.debug(("Configuration option 'preserve_hostname' is set,"
                     " not setting the hostname in module %s"), name)

=== modified file 'cloudinit/config/cc_set_passwords.py'
--- cloudinit/config/cc_set_passwords.py	2013-07-23 15:45:34 +0000
+++ cloudinit/config/cc_set_passwords.py	2014-02-03 23:17:12 +0000
@@ -36,6 +36,7 @@
 
 
 def handle(_name, cfg, cloud, log, args):
+
     if len(args) != 0:
         # if run from command line, and give args, wipe the chpasswd['list']
         password = args[0]
@@ -136,9 +137,10 @@
         util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines))
 
         try:
-            cmd = ['service']
+            cmd = cloud.distro.init_cmd  # Default service
             cmd.append(cloud.distro.get_option('ssh_svcname', 'ssh'))
             cmd.append('restart')
+            cmd = filter(None, cmd)  # Remove empty arguments
             util.subp(cmd)
             log.debug("Restarted the ssh daemon")
         except:

=== modified file 'cloudinit/config/cc_ssh_authkey_fingerprints.py'
--- cloudinit/config/cc_ssh_authkey_fingerprints.py	2013-09-25 18:59:06 +0000
+++ cloudinit/config/cc_ssh_authkey_fingerprints.py	2014-02-03 23:17:12 +0000
@@ -92,6 +92,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     if 'no_ssh_fingerprints' in cfg:
         log.debug(("Skipping module named %s, "
                    "logging of ssh fingerprints disabled"), name)

=== modified file 'cloudinit/config/cc_timezone.py'
--- cloudinit/config/cc_timezone.py	2012-06-21 16:12:16 +0000
+++ cloudinit/config/cc_timezone.py	2014-02-03 23:17:12 +0000
@@ -26,6 +26,7 @@
 
 
 def handle(name, cfg, cloud, log, args):
+
     if len(args) != 0:
         timezone = args[0]
     else:

=== modified file 'cloudinit/config/cc_update_etc_hosts.py'
--- cloudinit/config/cc_update_etc_hosts.py	2013-01-15 21:34:51 +0000
+++ cloudinit/config/cc_update_etc_hosts.py	2014-02-03 23:17:12 +0000
@@ -27,6 +27,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     manage_hosts = util.get_cfg_option_str(cfg, "manage_etc_hosts", False)
     if util.translate_bool(manage_hosts, addons=['template']):
         (hostname, fqdn) = util.get_hostname_fqdn(cfg, cloud)

=== modified file 'cloudinit/config/cc_update_hostname.py'
--- cloudinit/config/cc_update_hostname.py	2013-06-19 06:44:00 +0000
+++ cloudinit/config/cc_update_hostname.py	2014-02-03 23:17:12 +0000
@@ -27,6 +27,7 @@
 
 
 def handle(name, cfg, cloud, log, _args):
+
     if util.get_cfg_option_bool(cfg, "preserve_hostname", False):
         log.debug(("Configuration option 'preserve_hostname' is set,"
                     " not updating the hostname in module %s"), name)

=== modified file 'cloudinit/config/cc_users_groups.py'
--- cloudinit/config/cc_users_groups.py	2012-09-28 21:21:02 +0000
+++ cloudinit/config/cc_users_groups.py	2014-02-03 23:17:12 +0000
@@ -27,6 +27,7 @@
 
 
 def handle(name, cfg, cloud, _log, _args):
+
     (users, groups) = ds.normalize_users_groups(cfg, cloud.distro)
     for (name, members) in groups.items():
         cloud.distro.create_group(name, members)

=== modified file 'cloudinit/config/cc_yum_add_repo.py'
--- cloudinit/config/cc_yum_add_repo.py	2012-10-17 16:42:22 +0000
+++ cloudinit/config/cc_yum_add_repo.py	2014-02-03 23:17:12 +0000
@@ -58,6 +58,8 @@
 
 
 def handle(name, cfg, _cloud, log, _args):
+    if _cloud.distro.is_excluded(name):
+        return
     repos = cfg.get('yum_repos')
     if not repos:
         log.debug(("Skipping module named %s,"

=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py	2013-12-06 21:25:04 +0000
+++ cloudinit/distros/__init__.py	2014-02-03 23:17:12 +0000
@@ -39,6 +39,7 @@
 OSFAMILIES = {
     'debian': ['debian', 'ubuntu'],
     'redhat': ['fedora', 'rhel'],
+    'gentoo': ['gentoo'],
     'freebsd': ['freebsd'],
     'suse': ['sles']
 }
@@ -53,12 +54,21 @@
     ci_sudoers_fn = "/etc/sudoers.d/90-cloud-init-users"
     hostname_conf_fn = "/etc/hostname"
     tz_zone_dir = "/usr/share/zoneinfo"
+    init_cmd = ['service']  # systemctl, service etc
+    exclude_modules = []
 
     def __init__(self, name, cfg, paths):
         self._paths = paths
         self._cfg = cfg
         self.name = name
 
+    def is_excluded(self, name):
+        if name in self.exclude_modules:
+            distro = getattr(self, name, None) or getattr(self, 'osfamily')
+            LOG.debug(("Skipping module named %s, distro %s excluded"), name,
+                    distro)
+            return True
+
     @abc.abstractmethod
     def install_packages(self, pkglist):
         raise NotImplementedError()

=== added file 'cloudinit/distros/gentoo.py'
--- cloudinit/distros/gentoo.py	1970-01-01 00:00:00 +0000
+++ cloudinit/distros/gentoo.py	2014-02-03 23:17:12 +0000
@@ -0,0 +1,184 @@
+# vi: ts=4 expandtab
+#
+#    Copyright (C) 2014 Rackspace, US Inc.
+#
+#    Author: Nate House <nathan.house@xxxxxxxxxxxxx>
+#
+#    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
+#    published by the Free Software Foundation.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from cloudinit import distros
+from cloudinit import helpers
+from cloudinit import log as logging
+from cloudinit import util
+
+from cloudinit.distros.parsers.hostname import HostnameConf
+
+from cloudinit.settings import PER_INSTANCE
+
+LOG = logging.getLogger(__name__)
+
+
+class Distro(distros.Distro):
+    locale_conf_fn = "/etc/locale.gen"
+    network_conf_fn = "/etc/conf.d/net"
+    tz_conf_fn = "/etc/timezone"
+    tz_local_fn = "/etc/localtime"
+    init_cmd = ['']  # init scripts
+    exclude_modules = [
+        'grub-dpkg',
+        'apt-configure',
+        'apt-pipelining',
+        'yum-add-repo',
+    ]
+
+    def __init__(self, name, cfg, paths):
+        distros.Distro.__init__(self, name, cfg, paths)
+        # This will be used to restrict certain
+        # calls from repeatly happening (when they
+        # should only happen say once per instance...)
+        self._runner = helpers.Runners(paths)
+        self.osfamily = 'gentoo'
+        # Fix sshd restarts
+        cfg['ssh_svcname'] = '/etc/init.d/sshd'
+
+    def apply_locale(self, locale, out_fn=None):
+        if not out_fn:
+            out_fn = self.locale_conf_fn
+        util.subp(['locale-gen', '-G', locale], capture=False)
+        # "" provides trailing newline during join
+        lines = [
+            util.make_header(),
+            'LANG="%s"' % (locale),
+            "",
+        ]
+        util.write_file(out_fn, "\n".join(lines))
+
+    def install_packages(self, pkglist):
+        self.update_package_sources()
+        self.package_command('', pkgs=pkglist)
+
+    def _write_network(self, settings):
+        util.write_file(self.network_conf_fn, settings)
+        return ['all']
+
+    def _bring_up_interface(self, device_name):
+        cmd = ['/etc/init.d/net.%s' % device_name, 'restart']
+        LOG.debug("Attempting to run bring up interface %s using command %s",
+                   device_name, cmd)
+        try:
+            (_out, err) = util.subp(cmd)
+            if len(err):
+                LOG.warn("Running %s resulted in stderr output: %s", cmd, err)
+            return True
+        except util.ProcessExecutionError:
+            util.logexc(LOG, "Running interface command %s failed", cmd)
+            return False
+
+    def _bring_up_interfaces(self, device_names):
+        use_all = False
+        for d in device_names:
+            if d == 'all':
+                use_all = True
+        if use_all:
+            # Grab device names from init scripts
+            cmd = ['ls', '/etc/init.d/net.*']
+            try:
+                (_out, err) = util.subp(cmd)
+                if len(err):
+                    LOG.warn("Running %s resulted in stderr output: %s", cmd,
+                            err)
+            except util.ProcessExecutionError:
+                util.logexc(LOG, "Running interface command %s failed", cmd)
+                return False
+            devices = [x.split('.')[2] for x in _out.split('  ')]
+            return distros.Distro._bring_up_interfaces(self, devices)
+        else:
+            return distros.Distro._bring_up_interfaces(self, device_names)
+
+    def _select_hostname(self, hostname, fqdn):
+        # Prefer the short hostname over the long
+        # fully qualified domain name
+        if not hostname:
+            return fqdn
+        return hostname
+
+    def _write_hostname(self, your_hostname, out_fn):
+        conf = None
+        try:
+            # Try to update the previous one
+            # so lets see if we can read it first.
+            conf = self._read_hostname_conf(out_fn)
+        except IOError:
+            pass
+        if not conf:
+            conf = HostnameConf('')
+        conf.set_hostname(your_hostname)
+        util.write_file(out_fn, str(conf), 0644)
+
+    def _read_system_hostname(self):
+        sys_hostname = self._read_hostname(self.hostname_conf_fn)
+        return (self.hostname_conf_fn, sys_hostname)
+
+    def _read_hostname_conf(self, filename):
+        conf = HostnameConf(util.load_file(filename))
+        conf.parse()
+        return conf
+
+    def _read_hostname(self, filename, default=None):
+        hostname = None
+        try:
+            conf = self._read_hostname_conf(filename)
+            hostname = conf.hostname
+        except IOError:
+            pass
+        if not hostname:
+            return default
+        return hostname
+
+    def set_timezone(self, tz):
+        tz_file = self._find_tz_file(tz)
+        # Note: "" provides trailing newline during join
+        tz_lines = [
+            util.make_header(),
+            str(tz),
+            "",
+        ]
+        util.write_file(self.tz_conf_fn, "\n".join(tz_lines))
+        # This ensures that the correct tz will be used for the system
+        util.copy(tz_file, self.tz_local_fn)
+
+    def package_command(self, command, args=None, pkgs=None):
+        if pkgs is None:
+            pkgs = []
+
+        cmd = ['emerge']
+        # Redirect output
+        cmd.append("--quiet")
+
+        if args and isinstance(args, str):
+            cmd.append(args)
+        elif args and isinstance(args, list):
+            cmd.extend(args)
+
+        if command:
+            cmd.append(command)
+
+        pkglist = util.expand_package_list('%s-%s', pkgs)
+        cmd.extend(pkglist)
+
+        # Allow the output of this to flow outwards (ie not be captured)
+        util.subp(cmd, capture=False)
+
+    def update_package_sources(self):
+        self._runner.run("update-sources", self.package_command,
+                         ["-u", "world", "--quiet"], freq=PER_INSTANCE)

=== added directory 'sysvinit/gentoo'
=== added file 'sysvinit/gentoo/cloud-config'
--- sysvinit/gentoo/cloud-config	1970-01-01 00:00:00 +0000
+++ sysvinit/gentoo/cloud-config	2014-02-03 23:17:12 +0000
@@ -0,0 +1,13 @@
+#!/sbin/runscript
+
+depend() {
+  after cloud-init-local
+  after cloud-init
+  before cloud-final
+  provide cloud-config
+}
+
+start() {
+  cloud-init modules --mode config
+  eend 0
+}

=== added file 'sysvinit/gentoo/cloud-final'
--- sysvinit/gentoo/cloud-final	1970-01-01 00:00:00 +0000
+++ sysvinit/gentoo/cloud-final	2014-02-03 23:17:12 +0000
@@ -0,0 +1,11 @@
+#!/sbin/runscript
+
+depend() {
+  after cloud-config
+  provide cloud-final
+}
+
+start() {
+  cloud-init modules --mode final
+  eend 0
+}

=== added file 'sysvinit/gentoo/cloud-init'
--- sysvinit/gentoo/cloud-init	1970-01-01 00:00:00 +0000
+++ sysvinit/gentoo/cloud-init	2014-02-03 23:17:12 +0000
@@ -0,0 +1,12 @@
+#!/sbin/runscript
+# add depends for network, dns, fs etc
+depend() {
+  after cloud-init-local
+  before cloud-config
+  provide cloud-init
+}
+
+start() {
+  cloud-init init
+  eend 0
+}

=== added file 'sysvinit/gentoo/cloud-init-local'
--- sysvinit/gentoo/cloud-init-local	1970-01-01 00:00:00 +0000
+++ sysvinit/gentoo/cloud-init-local	2014-02-03 23:17:12 +0000
@@ -0,0 +1,11 @@
+#!/sbin/runscript
+
+depend() {
+  before cloud-init
+  provide cloud-init-local
+}
+
+start() {
+  cloud-init init --local
+  eend 0
+}

=== added file 'tests/unittests/test_distros/test_is_excluded.py'
--- tests/unittests/test_distros/test_is_excluded.py	1970-01-01 00:00:00 +0000
+++ tests/unittests/test_distros/test_is_excluded.py	2014-02-03 23:17:12 +0000
@@ -0,0 +1,15 @@
+from cloudinit.distros import gentoo
+import unittest
+
+
+class TestIsExcluded(unittest.TestCase):
+
+    def setUp(self):
+        self.distro = gentoo.Distro('gentoo', {}, None)
+        self.distro.exclude_modules = ['test-module']
+
+    def test_is_excluded_success(self):
+        self.assertEqual(self.distro.is_excluded('test-module'), True)
+
+    def test_is_excluded_fail(self):
+        self.assertEqual(self.distro.is_excluded('missing'), None)

=== modified file 'tests/unittests/test_handler/test_handler_yum_add_repo.py'
--- tests/unittests/test_handler/test_handler_yum_add_repo.py	2012-11-12 19:29:14 +0000
+++ tests/unittests/test_handler/test_handler_yum_add_repo.py	2014-02-03 23:17:12 +0000
@@ -2,6 +2,7 @@
 from cloudinit import util
 
 from cloudinit.config import cc_yum_add_repo
+from cloudinit.distros import rhel
 
 from tests.unittests import helpers
 
@@ -18,6 +19,8 @@
     def setUp(self):
         super(TestConfig, self).setUp()
         self.tmp = self.makeDir(prefix="unittest_")
+        self.cloud = type('', (), {})()
+        self.cloud.distro = rhel.Distro('test', {}, None)
 
     def test_bad_config(self):
         cfg = {
@@ -34,7 +37,7 @@
             },
         }
         self.patchUtils(self.tmp)
-        cc_yum_add_repo.handle('yum_add_repo', cfg, None, LOG, [])
+        cc_yum_add_repo.handle('yum_add_repo', cfg, self.cloud, LOG, [])
         self.assertRaises(IOError, util.load_file,
                           "/etc/yum.repos.d/epel_testing.repo")
 
@@ -52,7 +55,7 @@
             },
         }
         self.patchUtils(self.tmp)
-        cc_yum_add_repo.handle('yum_add_repo', cfg, None, LOG, [])
+        cc_yum_add_repo.handle('yum_add_repo', cfg, self.cloud, LOG, [])
         contents = util.load_file("/etc/yum.repos.d/epel_testing.repo")
         contents = configobj.ConfigObj(StringIO(contents))
         expected = {


Follow ups