From 81e936424b9f2a9ada20a83ca9353b5c0609b28c Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 18 Aug 2011 12:06:54 -0400 Subject: added --altsrc flag to bcfg2-info buildfile --- src/sbin/bcfg2-info | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/sbin/bcfg2-info') diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index e5ae84378..6d4e3e883 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -261,9 +261,20 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): def do_buildfile(self, args): """Build a config file for client.""" - if len(args.split()) == 2: - fname, client = args.split() + usage = 'Usage: buildfile [--altsrc=] filename hostname' + try: + opts, alist = getopt.gnu_getopt(args.split(), '', ['altsrc=']) + except: + print(usage) + return + for opt in opts: + if opt[0] == '--altsrc': + altsrc = opt[1] + if len(alist) == 2: + fname, client = alist entry = lxml.etree.Element('Path', type='file', name=fname) + if altsrc: + entry.set("altsrc", altsrc) try: metadata = self.build_metadata(client) self.Bind(entry, metadata) @@ -272,7 +283,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): except: print("Failed to build entry %s for host %s" % (fname, client)) else: - print('Usage: buildfile filename hostname') + print(usage) def do_buildbundle(self, args): """Render a bundle for client.""" -- cgit v1.2.3-1-g7c22