summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-info
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-12 13:43:02 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-15 09:10:21 -0400
commitaf4158afe15a3dc2ce1d98b80836e130b00eac81 (patch)
treed4fbc6699413c94633222e249b6111a48cb0c799 /src/sbin/bcfg2-info
parent1a6160ebeecffc57b5066ebf343188edf6a63eaa (diff)
downloadbcfg2-af4158afe15a3dc2ce1d98b80836e130b00eac81.tar.gz
bcfg2-af4158afe15a3dc2ce1d98b80836e130b00eac81.tar.bz2
bcfg2-af4158afe15a3dc2ce1d98b80836e130b00eac81.zip
bcfg2-info: added probes subcommand to list probes for a client
Diffstat (limited to 'src/sbin/bcfg2-info')
-rwxr-xr-xsrc/sbin/bcfg2-info50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index d16048df0..16e1e8ca1 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -212,8 +212,7 @@ class InfoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore):
def do_quit(self, _):
""" quit|exit - Exit program """
- for plugin in list(self.plugins.values()):
- plugin.shutdown()
+ self.shutdown()
os._exit(0) # pylint: disable=W0212
do_EOF = do_quit
@@ -497,6 +496,42 @@ Bcfg2 client itself.""")
]
print_tabular(output)
+ def do_probes(self, args):
+ """ probes [-p] <hostname> - Get probe list for the given
+ host, in XML (the default) or human-readable pretty (with -p)
+ format"""
+ alist = args.split()
+ pretty = False
+ if '-p' in alist:
+ pretty = True
+ alist.remove('-p')
+ if len(alist) != 1:
+ print 'alist=%s' % alist
+ print(self._get_usage(self.do_probes))
+ return
+ hostname = alist[0]
+ if pretty:
+ probes = []
+ else:
+ probes = lxml.etree.Element('probes')
+ metadata = self.build_metadata(hostname)
+ for plugin in self.plugins_by_type(Bcfg2.Server.Plugin.Probing):
+ for probe in plugin.GetProbes(metadata):
+ probes.append(probe)
+ if pretty:
+ for probe in probes:
+ pname = probe.get("name")
+ print("=" * (len(pname) + 2))
+ print(" %s" % pname)
+ print("=" * (len(pname) + 2))
+ print("")
+ print(probe.text)
+ print("")
+ else:
+ print(lxml.etree.tostring(probes,
+ xml_declaration=False,
+ pretty_print=True).decode('UTF-8'))
+
def do_showentries(self, args):
""" showentries <hostname> <type> - Show abstract
configuration entries for a given host """
@@ -666,10 +701,13 @@ Bcfg2 client itself.""")
display_trace(prof)
def run(self, args): # pylint: disable=W0221
- if args:
- self.onecmd(" ".join(args))
- else:
- self.do_loop()
+ try:
+ if args:
+ self.onecmd(" ".join(args))
+ else:
+ self.do_loop()
+ finally:
+ self.shutdown()
def _daemonize(self):
pass