summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-04 09:20:34 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-04 11:13:31 -0400
commit78c498c48687feeaf19a6cdca18cc266aa17130f (patch)
tree9baba23237f37ed236586c66282416db7207e1ae
parentdf0261269dfb12308e56bdcd67ed664998c834dd (diff)
downloadbcfg2-78c498c48687feeaf19a6cdca18cc266aa17130f.tar.gz
bcfg2-78c498c48687feeaf19a6cdca18cc266aa17130f.tar.bz2
bcfg2-78c498c48687feeaf19a6cdca18cc266aa17130f.zip
5ea25b9... improved some error messages; only setup pulp connection if there are pulp sources listed
-rw-r--r--src/lib/Server/Plugins/Packages/Yum.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/lib/Server/Plugins/Packages/Yum.py b/src/lib/Server/Plugins/Packages/Yum.py
index e13b28251..1237c0e9f 100644
--- a/src/lib/Server/Plugins/Packages/Yum.py
+++ b/src/lib/Server/Plugins/Packages/Yum.py
@@ -52,23 +52,23 @@ PULPCONFIG = None
def _setup_pulp(config):
global PULPSERVER, PULPCONFIG
if not has_pulp:
- logger.error("Packages: Cannot create Pulp collection: Pulp libraries not "
- "found")
- raise Bcfg2.Server.Plugin.PluginInitError
+ msg = "Packages: Cannot create Pulp collection: Pulp libraries not found"
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginInitError(msg)
if PULPSERVER is None:
try:
username = config.get("pulp", "username")
password = config.get("pulp", "password")
except ConfigParser.NoSectionError:
- logger.error("Packages: No [pulp] section found in Packages/packages.conf")
- raise Bcfg2.Server.Plugin.PluginInitError
+ msg = "Packages: No [pulp] section found in Packages/packages.conf"
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginInitError(msg)
except ConfigParser.NoOptionError:
- err = sys.exc_info()[1]
- logger.error("Packages: Required option not found in "
- "Packages/packages.conf: %s" % err)
- raise Bcfg2.Server.Plugin.PluginInitError
-
+ msg = "Packages: Required option not found in Packages/packages.conf: %s" % sys.exc_info()[1]
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginInitError(msg)
+
PULPCONFIG = ConsumerConfig()
serveropts = PULPCONFIG.server
@@ -113,9 +113,17 @@ class YumCollection(Collection):
self.helper = self.config.get("yum", "helper",
default="/usr/sbin/bcfg2-yum-helper")
- if has_pulp:
+ if has_pulp and self.has_pulp_sources:
_setup_pulp(self.config)
+ @property
+ def has_pulp_sources(self):
+ """ see if there are any pulp sources to handle """
+ for source in self.sources:
+ if source.pulp_id:
+ return True
+ return False
+
def write_config(self):
if not os.path.exists(self.cfgfile):
yumconf = self.get_config(raw=True)
@@ -235,14 +243,7 @@ class YumCollection(Collection):
if keypkg is not None:
independent.append(keypkg)
- # see if there are any pulp sources to handle
- has_pulp_sources = False
- for source in self.sources:
- if source.pulp_id:
- has_pulp_sources = True
- break
-
- if has_pulp_sources:
+ if self.has_pulp_sources:
consumerapi = ConsumerAPI()
consumer = self._get_pulp_consumer(consumerapi=consumerapi)
if consumer is None: