summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Packages
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-01-13 08:09:22 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-01-13 08:09:22 -0500
commit238f6446d09ca8e3b7a082876920922ee1eda4d2 (patch)
tree7a59ba455180c9950631334180af64ba68eeadee /src/lib/Server/Plugins/Packages
parent8c9b825595174455242b3b2f6ca96ddcbdcfff2e (diff)
parentb6654dd316f9cd4f6a6673a89cdd48cc1b38b82a (diff)
downloadbcfg2-238f6446d09ca8e3b7a082876920922ee1eda4d2.tar.gz
bcfg2-238f6446d09ca8e3b7a082876920922ee1eda4d2.tar.bz2
bcfg2-238f6446d09ca8e3b7a082876920922ee1eda4d2.zip
merged branch rules_regex
Diffstat (limited to 'src/lib/Server/Plugins/Packages')
-rw-r--r--src/lib/Server/Plugins/Packages/PackagesConfig.py31
-rw-r--r--src/lib/Server/Plugins/Packages/Source.py5
-rw-r--r--src/lib/Server/Plugins/Packages/Yum.py14
-rw-r--r--src/lib/Server/Plugins/Packages/__init__.py31
4 files changed, 23 insertions, 58 deletions
diff --git a/src/lib/Server/Plugins/Packages/PackagesConfig.py b/src/lib/Server/Plugins/Packages/PackagesConfig.py
index d3732bf96..dd39bb495 100644
--- a/src/lib/Server/Plugins/Packages/PackagesConfig.py
+++ b/src/lib/Server/Plugins/Packages/PackagesConfig.py
@@ -1,33 +1,18 @@
-import os
import logging
-from Bcfg2.Bcfg2Py3k import ConfigParser
-from Bcfg2.Server.Plugins.Packages import *
+import Bcfg2.Server.Plugin
logger = logging.getLogger('Packages')
-class PackagesConfig(Bcfg2.Server.Plugin.FileBacked,
- ConfigParser.SafeConfigParser):
- def __init__(self, filename, fam, packages):
- Bcfg2.Server.Plugin.FileBacked.__init__(self, filename)
- ConfigParser.SafeConfigParser.__init__(self)
-
- self.fam = fam
- # packages.conf isn't strictly necessary, so only set a
- # monitor if it exists. if it gets added, that will require a
- # server restart
- if os.path.exists(self.name):
- self.fam.AddMonitor(self.name, self)
-
- self.pkg_obj = packages
-
+class PackagesConfig(Bcfg2.Server.Plugin.SimpleConfig):
+ _required = False
+
def Index(self):
""" Build local data structures """
- for section in self.sections():
- self.remove_section(section)
- self.read(self.name)
- if self.pkg_obj.sources.loaded:
+ Bcfg2.Server.Plugin.SimpleConfig.Index(self)
+
+ if self.plugin.sources.loaded:
# only reload Packages plugin if sources have been loaded.
# otherwise, this is getting called on server startup, and
# we have to wait until all sources have been indexed
# before we can call Packages.Reload()
- self.pkg_obj.Reload()
+ self.plugin.Reload()
diff --git a/src/lib/Server/Plugins/Packages/Source.py b/src/lib/Server/Plugins/Packages/Source.py
index 72c7a4bfd..dbb510053 100644
--- a/src/lib/Server/Plugins/Packages/Source.py
+++ b/src/lib/Server/Plugins/Packages/Source.py
@@ -257,9 +257,8 @@ class Source(object):
if not found_arch:
return False
- if (self.config.has_section("global") and
- self.config.has_option("global", "magic_groups") and
- self.config.getboolean("global", "magic_groups") == False):
+ if self.config.getboolean("global", "magic_groups",
+ default=True) == False:
return True
else:
for group in self.basegroups:
diff --git a/src/lib/Server/Plugins/Packages/Yum.py b/src/lib/Server/Plugins/Packages/Yum.py
index 369b7a7d2..f3cb5a532 100644
--- a/src/lib/Server/Plugins/Packages/Yum.py
+++ b/src/lib/Server/Plugins/Packages/Yum.py
@@ -113,11 +113,8 @@ class YumCollection(Collection):
"%s-yum.conf" % self.cachekey)
self.write_config()
- try:
- self.helper = self.config.get("yum", "helper")
- except ConfigParser.NoOptionError:
- self.helper = "/usr/sbin/bcfg2-yum-helper"
-
+ self.helper = self.config.get("yum", "helper",
+ default="/usr/sbin/bcfg2-yum-helper")
if has_pulp:
_setup_pulp(self.config)
@@ -192,11 +189,8 @@ class YumCollection(Collection):
for key in needkeys:
# figure out the path of the key on the client
- try:
- keydir = self.config.get("global", "gpg_keypath")
- except (ConfigParser.NoOptionError,
- ConfigParser.NoSectionError):
- keydir = "/etc/pki/rpm-gpg"
+ keydir = self.config.get("global", "gpg_keypath",
+ default="/etc/pki/rpm-gpg")
remotekey = os.path.join(keydir, os.path.basename(key))
localkey = os.path.join(self.keypath, os.path.basename(key))
kdata = open(localkey).read()
diff --git a/src/lib/Server/Plugins/Packages/__init__.py b/src/lib/Server/Plugins/Packages/__init__.py
index 9e1ccfa37..b12d633f3 100644
--- a/src/lib/Server/Plugins/Packages/__init__.py
+++ b/src/lib/Server/Plugins/Packages/__init__.py
@@ -39,25 +39,20 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
os.makedirs(self.keypath)
# set up config files
- self.config = PackagesConfig(os.path.join(self.data, "packages.conf"),
- core.fam, self)
+ self.config = PackagesConfig(self)
self.sources = PackagesSources(os.path.join(self.data, "sources.xml"),
self.cachepath, core.fam, self,
self.config)
@property
def disableResolver(self):
- try:
- return self.config.get("global", "resolver").lower() == "disabled"
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- return False
+ return self.config.get("global", "resolver",
+ default="enabled").lower() == "disabled"
@property
def disableMetaData(self):
- try:
- return self.config.get("global", "metadata").lower() == "disabled"
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- return False
+ return self.config.get("global", "metadata",
+ default="enabled").lower() == "disabled"
def create_config(self, entry, metadata):
""" create yum/apt config for the specified host """
@@ -78,13 +73,8 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
entry.set('version', 'auto')
entry.set('type', collection.ptype)
elif entry.tag == 'Path':
- if (self.config.has_section("global") and
- ((self.config.has_option("global", "yum_config") and
- entry.get("name") == self.config.get("global",
- "yum_config")) or
- (self.config.has_option("global", "apt_config") and
- entry.get("name") == self.config.get("global",
- "apt_config")))):
+ if (entry.get("name") == self.config.get("global", "yum_config") or
+ entry.get("name") == self.config.get("global", "apt_config")):
self.create_config(entry, metadata)
def HandlesEntry(self, entry, metadata):
@@ -94,11 +84,8 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
return True
elif entry.tag == 'Path':
# managed entries for yum/apt configs
- if ((self.config.has_option("global", "yum_config") and
- entry.get("name") == self.config.get("global",
- "yum_config")) or
- (self.config.has_option("global", "apt_config") and
- entry.get("name") == self.config.get("global", "apt_config"))):
+ if (entry.get("name") == self.config.get("global", "yum_config") or
+ entry.get("name") == self.config.get("global", "apt_config")):
return True
return False