summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README20
-rw-r--r--src/lib/Server/Admin/Xcmd.py5
-rw-r--r--src/lib/Server/Core.py11
-rwxr-xr-xsrc/sbin/bcfg2-yum-helper79
4 files changed, 83 insertions, 32 deletions
diff --git a/README b/README
index 7368776a4..7bc3388ce 100644
--- a/README
+++ b/README
@@ -30,18 +30,20 @@ following pages in the Bcfg2 wiki.
Need help
---------
-* FAQ: http://bcfg2.org/wiki/FAQ
-* IRC: #bcfg2 on chat.freenode.net
-* Mailing list: https://lists.mcs.anl.gov/mailman/listinfo/bcfg-dev
-* Bug tracker: http://bcfg2.org/report
+A lot of documentation is available in the Bcfg2 manual and the Bcfg2 wiki.
-Documentation
--------------
+* Documentation: http://docs.bcfg2.org/
+* Wiki: http://bcfg2.org/wiki/
+* FAQ: http://bcfg2.org/wiki/FAQ
+* IRC: #bcfg2 on chat.freenode.net
+* Mailing list: https://lists.mcs.anl.gov/mailman/listinfo/bcfg-dev
-A lot of documentation is available in the Bcfg2 manual and the Bcfg2 wiki.
+Want to help
+-------------
-Wiki: http://bcfg2.org/wiki/
-Manual: http://docs.bcfg2.org/
+* Bug tracker: http://bcfg2.org/report
+* Development: http://docs.bcfg2.org/development/
+* Wiki: http://bcfg2.org/wiki/Contribute
Bcfg2 is licensed under BSD, for more details check COPYING.
diff --git a/src/lib/Server/Admin/Xcmd.py b/src/lib/Server/Admin/Xcmd.py
index 8faf68368..140465468 100644
--- a/src/lib/Server/Admin/Xcmd.py
+++ b/src/lib/Server/Admin/Xcmd.py
@@ -51,5 +51,10 @@ class Xcmd(Bcfg2.Server.Admin.Mode):
return
else:
raise
+ except Bcfg2.Proxy.ProxyError:
+ err = sys.exc_info()[1]
+ print("Proxy Error: %s" % err)
+ return
+
if data != None:
print(data)
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index 05625cf22..38f854f66 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -37,6 +37,14 @@ except:
pass
+def sort_xml(node, key=None):
+ for child in node:
+ sort_xml(child, key)
+
+ sorted_children = sorted(node, key=key)
+ node[:] = sorted_children
+
+
class CoreInitError(Exception):
"""This error is raised when the core cannot be initialized."""
pass
@@ -315,6 +323,9 @@ class Core(Component):
except:
logger.error("error in BindStructure", exc_info=1)
self.validate_goals(meta, config)
+
+ sort_xml(config, key=lambda e: e.get('name'))
+
logger.info("Generated config for %s in %.03f seconds" % \
(client, time.time() - start))
return config
diff --git a/src/sbin/bcfg2-yum-helper b/src/sbin/bcfg2-yum-helper
index 94836d748..4d3ada741 100755
--- a/src/sbin/bcfg2-yum-helper
+++ b/src/sbin/bcfg2-yum-helper
@@ -19,7 +19,26 @@ try:
except ImportError:
import simplejson as json
-logger = logging.getLogger('bcfg2-yum-helper')
+LOGGER = None
+
+def get_logger(verbose=0):
+ """ set up logging according to the verbose level given on the
+ command line """
+ global LOGGER
+ if LOGGER is None:
+ LOGGER = logging.getLogger(sys.argv[0])
+ stderr = logging.StreamHandler()
+ if verbose:
+ level = logging.DEBUG
+ else:
+ level = logging.WARNING
+ LOGGER.setLevel(level)
+ LOGGER.addHandler(stderr)
+ syslog = logging.handlers.SysLogHandler("/dev/log")
+ syslog.setFormatter(logging.Formatter("%(name)s: %(message)s"))
+ LOGGER.addHandler(syslog)
+ return LOGGER
+
class DepSolver(object):
def __init__(self, cfgfile, verbose=1):
@@ -28,8 +47,10 @@ class DepSolver(object):
try:
self.yumbase.preconf.debuglevel = verbose
self.yumbase.preconf.fn = cfgfile
+ self.yumbase._getConfig()
except AttributeError:
self.yumbase._getConfig(cfgfile, debuglevel=verbose)
+ self.logger = get_logger(verbose)
def get_groups(self):
try:
@@ -59,13 +80,14 @@ class DepSolver(object):
matches = self.yumbase.pkgSack.returnNewestByName(name=package)
except yum.Errors.PackageSackError:
if not silent:
- logger.warning("Packages: Package '%s' not found" %
- self.get_package_name(package))
+ self.logger.warning("bcfg2-yum-helper: Package '%s' not found" %
+ self.get_package_name(package))
matches = []
except yum.Errors.RepoError:
err = sys.exc_info()[1]
- logger.error("Packages: Temporary failure loading metadata for "
- "'%s': %s" % (self.get_package_name(package), err))
+ self.logger.error("bcfg2-yum-helper: Temporary failure loading "
+ "metadata for '%s': %s" %
+ (self.get_package_name(package), err))
matches = []
pkgs = self._filter_arch(matches)
@@ -83,8 +105,8 @@ class DepSolver(object):
deps.difference_update([dep for dep in deps
if pkg.checkPrco('provides', dep)])
else:
- logger.error("Packages: No package available: %s" %
- self.get_package_name(package))
+ self.logger.error("bcfg2-yum-helper: No package available: %s" %
+ self.get_package_name(package))
return deps
def get_provides(self, required, all=False, silent=False):
@@ -96,16 +118,16 @@ class DepSolver(object):
self.yumbase.whatProvides(*required).returnNewestByNameArch()
except yum.Errors.NoMoreMirrorsRepoError:
err = sys.exc_info()[1]
- logger.error("Packages: Temporary failure loading metadata for "
- "'%s': %s" %
- (self.get_package_name(required), err))
+ self.logger.error("bcfg2-yum-helper: Temporary failure loading "
+ "metadata for '%s': %s" %
+ (self.get_package_name(required), err))
return []
if prov and not all:
prov = self._filter_provides(required, prov)
elif not prov and not silent:
- logger.error("Packages: No package provides %s" %
- self.get_package_name(required))
+ self.logger.error("bcfg2-yum-helper: No package provides %s" %
+ self.get_package_name(required))
return prov
def get_group(self, group, ptype="default"):
@@ -116,11 +138,12 @@ class DepSolver(object):
if self.yumbase.comps.has_group(group):
group = self.yumbase.comps.return_group(group)
else:
- logger.warning("Packages: '%s' is not a valid group" % group)
+ self.logger.warning("bcfg2-yum-helper: %s is not a valid group"
+ % group)
return []
except yum.Errors.GroupsError:
err = sys.exc_info()[1]
- logger.warning("Packages: %s" % err)
+ self.logger.warning("bcfg2-yum-helper: %s" % err)
return []
if ptype == "default":
@@ -134,7 +157,7 @@ class DepSolver(object):
elif ptype == "optional" or ptype == "all":
return group.packages
else:
- logger.warning("Unknown group package type '%s'" % ptype)
+ self.logger.warning("Unknown group package type '%s'" % ptype)
return []
def _filter_provides(self, package, providers):
@@ -156,7 +179,8 @@ class DepSolver(object):
# provider of perl(lib).
rv = []
for pkg in providers:
- if self.get_package_object(pkg.name) == pkg:
+ found = self.get_package_object(pkg.name)
+ if found == pkg or found.pkgtup == pkg.pkgtup:
rv.append(pkg)
else:
rv = providers
@@ -202,12 +226,19 @@ class DepSolver(object):
if not self.is_package(package):
# try this package out as a requirement
+ self.logger.debug("bcfg2-yum-helper: Adding requirement %s"
+ % package)
requires.add((package, None, (None, None, None)))
continue
packages.add(package)
reqs = set(self.get_deps(package)).difference(satisfied)
if reqs:
+ self.logger.debug("bcfg2-yum-helper: Adding requirements "
+ "for %s: %s" %
+ (package,
+ ",".join([self.get_package_name(r)
+ for r in reqs])))
requires.update(reqs)
reqs_satisfied = set()
@@ -222,8 +253,8 @@ class DepSolver(object):
reqs_satisfied.add(req)
continue
- logger.debug("Packages: Handling requirement '%s'" %
- self.get_package_name(req))
+ self.logger.debug("bcfg2-yum-helper: Handling requirement '%s'"
+ % self.get_package_name(req))
providers = list(set(self.get_provides(req)))
if len(providers) > 1:
# hopefully one of the providing packages is already
@@ -243,10 +274,11 @@ class DepSolver(object):
# final pass, so include them all
if providers:
- logger.debug("Packages: Requirement '%s' satisfied by %s" %
- (self.get_package_name(req),
- ",".join([self.get_package_name(p)
- for p in providers])))
+ self.logger.debug("bcfg2-yum-helper: Requirement '%s' "
+ "satisfied by %s" %
+ (self.get_package_name(req),
+ ",".join([self.get_package_name(p)
+ for p in providers])))
newpkgs = set(providers).difference(packages)
if newpkgs:
for package in newpkgs:
@@ -283,7 +315,7 @@ class DepSolver(object):
# many files were deleted. so useful. thanks, yum.
msg = getattr(self.yumbase, "clean%s" % mdtype)()[1][0]
if not msg.startswith("0 "):
- logger.info("Packages: %s" % msg)
+ self.logger.info("bcfg2-yum-helper: %s" % msg)
def main():
@@ -291,6 +323,7 @@ def main():
parser.add_option("-c", "--config", help="Config file")
parser.add_option("-v", "--verbose", help="Verbosity level", action="count")
(options, args) = parser.parse_args()
+ logger = get_logger(options.verbose)
try:
cmd = args[0]
except IndexError: