summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-16 12:33:31 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-16 12:33:31 -0700
commit1a803c9f1f55095e1cf69bd4ca12bda0299b64b4 (patch)
tree83fcc4b9b8a4b14135a33793753c8fff82d910c9 /cloudinit
parent75b46cc80c6a9ab65c3c7f430ffaa4157d0db369 (diff)
downloadvyos-cloud-init-1a803c9f1f55095e1cf69bd4ca12bda0299b64b4.tar.gz
vyos-cloud-init-1a803c9f1f55095e1cf69bd4ca12bda0299b64b4.zip
Have the top level distro class take paths instead of a runner.
This allows the following: 1. Let the ubuntu subclass construct its own runner with those paths (since not every subclass may want it) Adjust the base class + subclass to reflect this, adjust stages as well to reflect the constructor changes.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/__init__.py4
-rw-r--r--cloudinit/distros/ubuntu.py8
-rw-r--r--cloudinit/stages.py12
3 files changed, 15 insertions, 9 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index e85e702e..0ee7f06b 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -42,8 +42,8 @@ class Distro(object):
__metaclass__ = abc.ABCMeta
- def __init__(self, name, cfg, runner):
- self._runner = runner
+ def __init__(self, name, cfg, paths):
+ self._paths = paths
self._cfg = cfg
self.name = name
diff --git a/cloudinit/distros/ubuntu.py b/cloudinit/distros/ubuntu.py
index ad12400a..9b743b55 100644
--- a/cloudinit/distros/ubuntu.py
+++ b/cloudinit/distros/ubuntu.py
@@ -23,6 +23,7 @@
import os
from cloudinit import distros
+from cloudinit import helpers
from cloudinit import log as logging
from cloudinit import util
@@ -33,6 +34,13 @@ LOG = logging.getLogger(__name__)
class Distro(distros.Distro):
+ 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)
+
def install_packages(self, pkglist):
self._update_package_sources()
self._apt_get('install', pkglist)
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index 9d8ff2bb..8fa9d6d3 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -77,13 +77,11 @@ class Init(object):
def distro(self):
if not self._distro:
# Try to find the right class to use
- d_cfg = self._extract_cfg('system')
- distro_name = d_cfg.pop('distro', 'ubuntu')
- distro_cls = distros.fetch(distro_name)
- LOG.debug("Using distro class %s", distro_cls)
- distro = distro_cls(distro_name, d_cfg,
- helpers.Runners(self.paths))
- self._distro = distro
+ scfg = self._extract_cfg('system')
+ name = scfg.pop('distro', 'ubuntu')
+ cls = distros.fetch(name)
+ LOG.debug("Using distro class %s", cls)
+ self._distro = cls(name, scfg, self.paths)
return self._distro
@property