diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-09-12 16:53:53 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-09-12 16:53:53 -0400 |
commit | fa25b112ec93f96eee47e7522047bafe29d2e92f (patch) | |
tree | 2fd1db61cd7d9dbfe956aedc111375bced719490 /src/sbin | |
parent | 2b9d8b5e93b91063db6d4b6cde613c2d172362e3 (diff) | |
download | bcfg2-fa25b112ec93f96eee47e7522047bafe29d2e92f.tar.gz bcfg2-fa25b112ec93f96eee47e7522047bafe29d2e92f.tar.bz2 bcfg2-fa25b112ec93f96eee47e7522047bafe29d2e92f.zip |
bcfg2-info: added "automatch" command to perform Properties automatching
Diffstat (limited to 'src/sbin')
-rwxr-xr-x | src/sbin/bcfg2-info | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 9ee02fd71..4725e05a3 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -42,6 +42,7 @@ buildall <directory> [<hostnames*>] - Build configs for all clients in directory buildallfile <directory> <filename> [<hostnames*>] - Build config file 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) +automatch <propertyfile> <hostname> - Perform automatch on a Properties file bundles - Print out group/bundle information clients - Print out client/profile information config - Print out the configuration of the Bcfg2 server @@ -427,6 +428,43 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore): else: print('Usage: buildbundle filename hostname') + def do_automatch(self, args): + alist = args.split() + force = False + for arg in alist: + if arg == '-f': + alist.remove('-f') + force = True + if len(alist) != 2: + print("Usage: automatch [-f] <propertiesfile> <hostname>") + return + + if 'Properties' not in self.plugins: + print("Properties plugin not enabled") + return + + pname, client = alist + try: + automatch = self.core.setup.cfp.getboolean("properties", + "automatch", + default=False) + + pfile = self.plugins['Properties'].store.entries[pname] + if (not force and + not automatch and + pfile.xdata.get("automatch", "false").lower() != "true"): + print("Automatch not enabled on %s" % pname) + else: + metadata = self.build_metadata(client) + print(lxml.etree.tostring(pfile.XMLMatch(metadata), + xml_declaration=False, + pretty_print=True).decode('UTF-8')) + except: + err = sys.exc_info()[1] + print("Failed to automatch %s for host %s: %s" % (pname, + client, + err)) + def do_bundles(self, _): """Print out group/bundle info.""" data = [('Group', 'Bundles')] |