summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-04 12:15:06 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-04 12:15:06 -0400
commitd94a58c5718d6e886ea1a2daff14f3939916be47 (patch)
treea7104b72f0661ebcd6aca7f2c1229d4fc65756c0
parent8bc23e6ed36a435cfbab927c64487115efa33bf2 (diff)
downloadbcfg2-d94a58c5718d6e886ea1a2daff14f3939916be47.tar.gz
bcfg2-d94a58c5718d6e886ea1a2daff14f3939916be47.tar.bz2
bcfg2-d94a58c5718d6e886ea1a2daff14f3939916be47.zip
check for bcfg2-yum-helper in $PATH first
-rw-r--r--doc/server/plugins/generators/packages.txt9
-rw-r--r--src/lib/Server/Plugins/Packages/Yum.py18
2 files changed, 21 insertions, 6 deletions
diff --git a/doc/server/plugins/generators/packages.txt b/doc/server/plugins/generators/packages.txt
index 900162aaa..1eeab4f8b 100644
--- a/doc/server/plugins/generators/packages.txt
+++ b/doc/server/plugins/generators/packages.txt
@@ -433,10 +433,11 @@ Configuring the Yum Helper
Due to poor memory management by the Yum API, the long-lived
bcfg2-server process uses an external short-lived helper,
``bcfg2-yum-helper``, to do the actual Yum API calls for native yum
-library support. By default, Bcfg2 looks for this helper at
-``/usr/sbin/bcfg2-yum-helper``. If you have installed the helper
-elsewhere, you will need to configure that location with the
-``helper`` option in the ``[yum]`` section, e.g.::
+library support. By default, Bcfg2 looks for this helper in
+``$PATH``, or, failing that, at ``/usr/sbin/bcfg2-yum-helper``. If
+you have installed the helper elsewhere, you will need to configure
+that location with the ``helper`` option in the ``[yum]`` section,
+e.g.::
[yum]
use_yum_libraries = 1
diff --git a/src/lib/Server/Plugins/Packages/Yum.py b/src/lib/Server/Plugins/Packages/Yum.py
index be5a68aa1..9ce462c78 100644
--- a/src/lib/Server/Plugins/Packages/Yum.py
+++ b/src/lib/Server/Plugins/Packages/Yum.py
@@ -111,10 +111,24 @@ class YumCollection(Collection):
if has_pulp and self.has_pulp_sources:
_setup_pulp(self.config)
+ self._helper = None
+
@property
def helper(self):
- return self.config.get("yum", "helper",
- default="/usr/sbin/bcfg2-yum-helper")
+ try:
+ return self.config.get("yum", "helper")
+ except:
+ pass
+
+ if not self._helper:
+ # first see if bcfg2-yum-helper is in PATH
+ try:
+ Popen(['bcfg2-yum-helper'],
+ stdin=PIPE, stdout=PIPE, stderr=PIPE).wait()
+ self._helper = 'bcfg2-yum-helper'
+ except OSError:
+ self._helper = "/usr/sbin/bcfg2-yum-helper"
+ return self._helper
@property
def use_yum(self):