summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Info.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Info.py')
-rw-r--r--src/lib/Bcfg2/Server/Info.py51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/lib/Bcfg2/Server/Info.py b/src/lib/Bcfg2/Server/Info.py
index 76da861ba..24d7cc637 100644
--- a/src/lib/Bcfg2/Server/Info.py
+++ b/src/lib/Bcfg2/Server/Info.py
@@ -163,9 +163,10 @@ class Build(InfoCmd):
type=argparse.FileType('w'))]
def run(self, setup):
+ etree = lxml.etree.ElementTree(
+ self.core.BuildConfiguration(setup.hostname))
try:
- lxml.etree.ElementTree(
- self.core.BuildConfiguration(setup.hostname)).write(
+ etree.write(
setup.filename,
encoding='UTF-8', xml_declaration=True,
pretty_print=True)
@@ -367,6 +368,23 @@ class Automatch(InfoCmd):
pretty_print=True).decode('UTF-8'))
+class ExpireCache(InfoCmd):
+ """ Expire the metadata cache """
+
+ options = [
+ Bcfg2.Options.PositionalArgument(
+ "hostname", nargs="*", default=[],
+ help="Expire cache for the given host(s)")]
+
+ def run(self, setup):
+ if setup.clients:
+ for client in self.get_client_list(setup.clients):
+ self.expire_caches_by_type(Bcfg2.Server.Plugin.Metadata,
+ key=client)
+ else:
+ self.expire_caches_by_type(Bcfg2.Server.Plugin.Metadata)
+
+
class Bundles(InfoCmd):
""" Print out group/bundle info """
@@ -572,7 +590,7 @@ class Mappings(InfoCmd):
print_tabular(data)
-class Packageresolve(InfoCmd):
+class PackageResolve(InfoCmd):
""" Resolve packages for the given host"""
options = [Bcfg2.Options.PositionalArgument("hostname"),
@@ -658,20 +676,12 @@ class Shell(InfoCmd):
interactive = False
def run(self, setup):
- loop = True
- while loop:
- try:
- self.core.cmdloop('Welcome to bcfg2-info\n'
- 'Type "help" for more information')
- except SystemExit:
- raise
- except Bcfg2.Server.Plugin.PluginExecutionError:
- continue
- except KeyboardInterrupt:
- print("Ctrl-C pressed, exiting...")
- loop = False
- except:
- self.core.logger.error("Command failure", exc_info=1)
+ try:
+ self.core.cmdloop('Welcome to bcfg2-info\n'
+ 'Type "help" for more information')
+ except KeyboardInterrupt:
+ print("Ctrl-C pressed, exiting...")
+ loop = False
class ProfileTemplates(InfoCmd):
@@ -735,7 +745,7 @@ class ProfileTemplates(InfoCmd):
def stdev(self, nums):
mean = float(sum(nums)) / len(nums)
- return math.sqrt(sum((n - mean)**2 for n in nums) / float(len(nums)))
+ return math.sqrt(sum((n - mean) ** 2 for n in nums) / float(len(nums)))
def run(self, setup):
clients = self.get_client_list(setup.clients)
@@ -762,7 +772,6 @@ class ProfileTemplates(InfoCmd):
std = self.stdev(ptimes)
if mean > 0.01 or median > 0.01 or std > 1 or setup.templates:
tmpltimes.append((tmpl, mean, median, std))
- else:
print("%-50s %-9s %-11s %6s" %
("Template", "Mean Time", "Median Time", "σ"))
for info in reversed(sorted(tmpltimes, key=operator.itemgetter(1))):
@@ -792,7 +801,7 @@ class InfoCore(cmd.Cmd,
cmd.Cmd.__init__(self)
Bcfg2.Server.Core.Core.__init__(self)
Bcfg2.Options.CommandRegistry.__init__(self)
- self.prompt = '> '
+ self.prompt = 'bcfg2-info> '
def get_locals(self):
return locals()
@@ -816,7 +825,7 @@ class InfoCore(cmd.Cmd,
def run(self):
self.load_plugins()
- self.fam.handle_events_in_interval(1)
+ self.block_for_fam_events(handle_events=True)
def _daemonize(self):
pass