diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-06-29 20:06:32 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-06-29 20:06:32 -0400 |
commit | d95662579c59f8866721483e2b2c8b4ca0099eae (patch) | |
tree | a6be3eeba78db4fd063d933bd75acf27e5b2900f /cloudinit/distros | |
parent | cc23412d7a4841667179d70571689bb41a167d32 (diff) | |
download | vyos-cloud-init-d95662579c59f8866721483e2b2c8b4ca0099eae.tar.gz vyos-cloud-init-d95662579c59f8866721483e2b2c8b4ca0099eae.zip |
add update_package_sources to distro class
Previously update_package_sources was a private class
(_update_package_sources). The apt_update_upgrade class called it.
It does make sense that things would want to call this independently
of installing packages. Therefore, expose it as a non hidden method.
Diffstat (limited to 'cloudinit/distros')
-rw-r--r-- | cloudinit/distros/__init__.py | 4 | ||||
-rw-r--r-- | cloudinit/distros/debian.py | 4 | ||||
-rw-r--r-- | cloudinit/distros/rhel.py | 10 |
3 files changed, 16 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index c324ddf6..da4d0180 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -71,6 +71,10 @@ class Distro(object): def package_command(self, cmd, args=None): raise NotImplementedError() + @abc.abstractmethod + def update_package_sources(self): + raise NotImplementedError() + def get_package_mirror(self): return self.get_option('package_mirror') diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index 3a0cae19..3247d7ce 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -53,7 +53,7 @@ class Distro(distros.Distro): util.write_file(out_fn, "\n".join(contents)) def install_packages(self, pkglist): - self._update_package_sources() + self.update_package_sources() self.package_command('install', pkglist) def _write_network(self, settings): @@ -144,6 +144,6 @@ class Distro(distros.Distro): # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, env=e, capture=False) - def _update_package_sources(self): + def update_package_sources(self): self._runner.run("update-sources", self.package_command, ["update"], freq=PER_INSTANCE) diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index 87d5b7a8..342d4c79 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -26,6 +26,8 @@ from cloudinit import distros from cloudinit import log as logging from cloudinit import util +from cloudinit.settings import PER_INSTANCE + LOG = logging.getLogger(__name__) NETWORK_FN_TPL = '/etc/sysconfig/network-scripts/ifcfg-%s' @@ -57,6 +59,10 @@ 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.package_command('install', pkglist) @@ -199,6 +205,10 @@ class Distro(distros.Distro): # 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, + ["update"], freq=PER_INSTANCE) + # This class helps adjust the configobj # writing to ensure that when writing a k/v |