summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg2-info12
-rwxr-xr-xsrc/sbin/bcfg2-reports3
-rwxr-xr-xsrc/sbin/bcfg2-test1
-rwxr-xr-xsrc/sbin/bcfg2-yum-helper36
4 files changed, 21 insertions, 31 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index 462d41398..ac4c3af13 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -120,7 +120,6 @@ class InfoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore):
Bcfg2.Server.Core.BaseCore.__init__(self, setup=setup)
self.prompt = '> '
self.cont = True
- self.fam.handle_events_in_interval(4)
def _get_client_list(self, hostglobs):
""" given a host glob, get a list of clients that match it """
@@ -458,9 +457,7 @@ Bcfg2 client itself.""")
def do_clients(self, _):
""" clients - Print out client/profile info """
data = [('Client', 'Profile')]
- clist = self.metadata.clients
- clist.sort()
- for client in clist:
+ for client in sorted(self.metadata.list_clients()):
imd = self.metadata.get_initial_metadata(client)
data.append((client, imd.profile))
print_tabular(data)
@@ -606,7 +603,7 @@ Bcfg2 client itself.""")
# Dump all mappings unless type specified
data = [('Plugin', 'Type', 'Name')]
arglen = len(args.split())
- for generator in self.generators:
+ for generator in self.plugins_by_type(Bcfg2.Server.Plugin.Generator):
if arglen == 0:
etypes = list(generator.Entries.keys())
else:
@@ -712,6 +709,8 @@ Bcfg2 client itself.""")
def run(self, args): # pylint: disable=W0221
try:
+ self.load_plugins()
+ self.fam.handle_events_in_interval(1)
if args:
self.onecmd(" ".join(args))
else:
@@ -753,8 +752,7 @@ def main():
optinfo = dict(profile=Bcfg2.Options.CORE_PROFILE,
interactive=Bcfg2.Options.INTERACTIVE,
interpreter=Bcfg2.Options.INTERPRETER)
- optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS)
- optinfo.update(Bcfg2.Options.SERVER_COMMON_OPTIONS)
+ optinfo.update(Bcfg2.Options.INFO_COMMON_OPTIONS)
setup = Bcfg2.Options.OptionParser(optinfo)
setup.hm = "\n".join([" bcfg2-info [options] [command <command args>]",
"Options:",
diff --git a/src/sbin/bcfg2-reports b/src/sbin/bcfg2-reports
index 2c4a918be..bb45e0009 100755
--- a/src/sbin/bcfg2-reports
+++ b/src/sbin/bcfg2-reports
@@ -233,7 +233,8 @@ def main():
try:
entries = [l.strip().split(":")
for l in open(options.file)]
- except IOError, err:
+ except IOError:
+ err = sys.exc_info()[1]
print("Cannot read entries from %s: %s" % (options.file,
err))
return 2
diff --git a/src/sbin/bcfg2-test b/src/sbin/bcfg2-test
index 6eaf0cc33..c33143a04 100755
--- a/src/sbin/bcfg2-test
+++ b/src/sbin/bcfg2-test
@@ -155,6 +155,7 @@ class ClientTest(TestCase):
def get_core(setup):
""" Get a server core, with events handled """
core = Bcfg2.Server.Core.BaseCore(setup)
+ core.load_plugins()
core.fam.handle_events_in_interval(0.1)
return core
diff --git a/src/sbin/bcfg2-yum-helper b/src/sbin/bcfg2-yum-helper
index 7e5c03fd5..7dbdad16b 100755
--- a/src/sbin/bcfg2-yum-helper
+++ b/src/sbin/bcfg2-yum-helper
@@ -9,33 +9,13 @@ import os
import sys
import yum
import logging
+import Bcfg2.Logger
from optparse import OptionParser
try:
import json
except ImportError:
import simplejson as json
-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
-
def pkg_to_tuple(package):
""" json doesn't distinguish between tuples and lists, but yum
@@ -76,7 +56,7 @@ class DepSolver(object):
except AttributeError:
self.yumbase._getConfig(cfgfile, debuglevel=verbose)
# pylint: enable=E1121,W0212
- self.logger = get_logger(verbose)
+ self.logger = logging.getLogger(self.__class__.__name__)
self._groups = None
def get_groups(self):
@@ -220,7 +200,17 @@ def main():
parser.add_option("-v", "--verbose", help="Verbosity level",
action="count")
(options, args) = parser.parse_args()
- logger = get_logger(options.verbose)
+
+ if options.verbose:
+ level = logging.DEBUG
+ clevel = logging.DEBUG
+ else:
+ level = logging.WARNING
+ clevel = logging.INFO
+ Bcfg2.Logger.setup_logging('bcfg2-yum-helper', to_syslog=True,
+ to_console=clevel, level=level)
+ logger = logging.getLogger('bcfg2-yum-helper')
+
try:
cmd = args[0]
except IndexError: