diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-05-04 10:56:29 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-05-04 11:13:53 -0400 |
commit | 8bc23e6ed36a435cfbab927c64487115efa33bf2 (patch) | |
tree | e96978b7dffa8a7aa703e458d43b50012f2aae06 /src/lib/Server/Plugins/Packages | |
parent | 7f64eae09fc93c37aaf90c511e7db5a56f0ba08a (diff) | |
download | bcfg2-8bc23e6ed36a435cfbab927c64487115efa33bf2.tar.gz bcfg2-8bc23e6ed36a435cfbab927c64487115efa33bf2.tar.bz2 bcfg2-8bc23e6ed36a435cfbab927c64487115efa33bf2.zip |
better support for re-reading packages.conf (and SimpleConfigs in general)
Diffstat (limited to 'src/lib/Server/Plugins/Packages')
-rw-r--r-- | src/lib/Server/Plugins/Packages/PackagesSources.py | 8 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Packages/Yum.py | 27 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/Server/Plugins/Packages/PackagesSources.py b/src/lib/Server/Plugins/Packages/PackagesSources.py index da79c00e9..e03303d30 100644 --- a/src/lib/Server/Plugins/Packages/PackagesSources.py +++ b/src/lib/Server/Plugins/Packages/PackagesSources.py @@ -35,7 +35,6 @@ class PackagesSources(Bcfg2.Server.Plugin.SingleXMLFileBacked, (self.cachepath, err)) self.pkg_obj = packages self.parsed = set() - self.loaded = False def toggle_debug(self): Bcfg2.Server.Plugin.Debuggable.toggle_debug(self) @@ -47,10 +46,13 @@ class PackagesSources(Bcfg2.Server.Plugin.SingleXMLFileBacked, if event.filename != self.name: self.parsed.add(os.path.basename(event.filename)) - if sorted(list(self.parsed)) == sorted(self.extras): + if self.config.loaded and self.loaded: self.logger.info("Reloading Packages plugin") self.pkg_obj.Reload() - self.loaded = True + + @property + def loaded(self): + return sorted(list(self.parsed)) == sorted(self.extras) def Index(self): Bcfg2.Server.Plugin.SingleXMLFileBacked.Index(self) diff --git a/src/lib/Server/Plugins/Packages/Yum.py b/src/lib/Server/Plugins/Packages/Yum.py index 1237c0e9f..be5a68aa1 100644 --- a/src/lib/Server/Plugins/Packages/Yum.py +++ b/src/lib/Server/Plugins/Packages/Yum.py @@ -15,6 +15,7 @@ from Bcfg2.Bcfg2Py3k import StringIO, cPickle, HTTPError, ConfigParser, file from Bcfg2.Server.Plugins.Packages.Collection import Collection from Bcfg2.Server.Plugins.Packages.Source import SourceInitError, Source, \ fetch_url +from Bcfg2.Server.Plugins.Packages.PackagesConfig import PackagesConfig logger = logging.getLogger(__name__) @@ -91,12 +92,9 @@ class YumCollection(Collection): self.keypath = os.path.join(self.basepath, "keys") if len(sources): - config = sources[0].config - self.use_yum = has_yum and config.getboolean("yum", - "use_yum_libraries", - default=False) + self.config = sources[0].config else: - self.use_yum = False + self.config = PackageConfig('Packages') if self.use_yum: self.cachefile = os.path.join(self.cachepath, @@ -110,13 +108,20 @@ class YumCollection(Collection): self.cfgfile = os.path.join(self.configdir, "%s-yum.conf" % self.cachekey) self.write_config() - - self.helper = self.config.get("yum", "helper", - default="/usr/sbin/bcfg2-yum-helper") if has_pulp and self.has_pulp_sources: _setup_pulp(self.config) @property + def helper(self): + return self.config.get("yum", "helper", + default="/usr/sbin/bcfg2-yum-helper") + + @property + def use_yum(self): + return has_yum and self.config.getboolean("yum", "use_yum_libraries", + default=False) + + @property def has_pulp_sources(self): """ see if there are any pulp sources to handle """ for source in self.sources: @@ -492,8 +497,10 @@ class YumSource(Source): self.needed_paths = set() self.file_to_arch = dict() - self.use_yum = has_yum and config.getboolean("yum", "use_yum_libraries", - default=False) + @property + def use_yum(self): + return has_yum and self.config.getboolean("yum", "use_yum_libraries", + default=False) def save_state(self): if not self.use_yum: |