summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-03 15:42:28 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-03 15:43:31 -0400
commitae44f106be38fe5d073260e2edaa3126861d9e6f (patch)
treee57f357489cf4e786bed4614c0f558f147065e1b /src
parent95b5cb0fe306b13ec9788f0e36f5ca02b31b5a79 (diff)
downloadbcfg2-ae44f106be38fe5d073260e2edaa3126861d9e6f.tar.gz
bcfg2-ae44f106be38fe5d073260e2edaa3126861d9e6f.tar.bz2
bcfg2-ae44f106be38fe5d073260e2edaa3126861d9e6f.zip
added buildbundle command to bcfg2-info to render a bundle template
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sbin/bcfg2-info26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index 951a5df58..1a5859cc3 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -24,6 +24,7 @@ import Bcfg2.Logger
import Bcfg2.Options
import Bcfg2.Server.Core
import Bcfg2.Server.Plugins.Metadata
+import Bcfg2.Server.Plugins.SGenshi
import Bcfg2.Server.Plugin
logger = logging.getLogger('bcfg2-info')
@@ -32,6 +33,7 @@ build <hostname> <filename> - Build config for hostname, writing to filename
builddir <hostname> <dirname> - Build config for hostname, writing separate files to dirname
buildall <directory> - Build configs for all clients in directory
buildfile <filename> <hostname> - Build config file for hostname (not written to disk)
+buildbundle <bundle> <hostname> - Render a templated bundle for hostname (not written to disk)
bundles - Print out group/bundle information
clients - Print out client/profile information
config - Print out the configuration of the Bcfg2 server
@@ -272,6 +274,30 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
else:
print('Usage: buildfile filename hostname')
+ def do_buildbundle(self, args):
+ """Render a bundle for client."""
+ if len(args.split()) == 2:
+ bname, client = args.split()
+ try:
+ metadata = self.build_metadata(client)
+ if bname in self.plugins['Bundler'].entries:
+ bundle = self.plugins['Bundler'].entries[bname]
+ if isinstance(bundle,
+ Bcfg2.Server.Plugins.SGenshi.SGenshiTemplateFile):
+ stream = bundle.template.generate(metadata=metadata)
+ print(stream.render("xml"))
+ else:
+ print(bundle.data)
+ else:
+ print("No such bundle %s" % bname)
+ except:
+ err = sys.exc_info()[1]
+ print("Failed to render bundle %s for host %s: %s" % (bname,
+ client,
+ err))
+ else:
+ print('Usage: buildfile filename hostname')
+
def do_bundles(self, _):
"""Print out group/bundle info."""
data = [('Group', 'Bundles')]