summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-27 08:59:06 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-27 12:12:34 -0500
commit0491d5d4e9bc0dc0b7a9ba8c1696ff825ef804ff (patch)
tree281dd7e2d39532b88cb1d666a9d53e110e2d7267 /src
parentd396ab350ac2beb8548c1ccb132e11ad50a1c7ec (diff)
downloadbcfg2-0491d5d4e9bc0dc0b7a9ba8c1696ff825ef804ff.tar.gz
bcfg2-0491d5d4e9bc0dc0b7a9ba8c1696ff825ef804ff.tar.bz2
bcfg2-0491d5d4e9bc0dc0b7a9ba8c1696ff825ef804ff.zip
fixed bcfg2-info buildbundle to use code from Bundler plugin
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sbin/bcfg2-info44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index acb9e4f44..fa8c89b46 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -27,12 +27,6 @@ try:
except ImportError:
HAS_PROFILE = False
-try:
- from Bcfg2.Server.Plugins.Bundler import BundleTemplateFile
- HAS_GENSHI = True
-except ImportError:
- HAS_GENSHI = False
-
class MockLog(object):
""" Fake logger that just discards all messages in order to mask
@@ -401,28 +395,24 @@ Bcfg2 client itself.""")
def do_buildbundle(self, args):
""" buildbundle <bundle> <hostname> - Render a templated
bundle for hostname (not written to disk) """
- 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 (HAS_GENSHI and
- isinstance(bundle,
- BundleTemplateFile)):
- stream = bundle.template.generate(metadata=metadata)
- print(stream.render("xml"))
- else:
- print(bundle.data)
- else:
- print("No such bundle %s" % bname)
- except: # pylint: disable=W0702
- err = sys.exc_info()[1]
- print("Failed to render bundle %s for host %s: %s" % (bname,
- client,
- err))
- else:
+ if len(args.split()) != 2:
print(self._get_usage(self.do_buildbundle))
+ return 1
+
+ bname, client = args.split()
+ try:
+ metadata = self.build_metadata(client)
+ bundle = self.plugins['Bundler'].entries[bname]
+ print(lxml.etree.tostring(bundle.get_xml_value(metadata),
+ xml_declaration=False,
+ pretty_print=True).decode('UTF-8'))
+ except KeyError:
+ print("No such bundle %s" % bname)
+ except: # pylint: disable=W0702
+ err = sys.exc_info()[1]
+ print("Failed to render bundle %s for host %s: %s" % (bname,
+ client,
+ err))
def do_automatch(self, args):
""" automatch [-f] <propertyfile> <hostname> - Perform automatch on