summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-07-15 20:48:05 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-07-16 16:36:15 -0500
commitc4f6826b85be5873793741a9fe32f0ce09406f1d (patch)
tree1472f7e53780a9f0c41de90649c74f140400ba69 /src
parent84b3bcd2d27e92323ac699fd84a9c1130d85280f (diff)
downloadbcfg2-c4f6826b85be5873793741a9fe32f0ce09406f1d.tar.gz
bcfg2-c4f6826b85be5873793741a9fe32f0ce09406f1d.tar.bz2
bcfg2-c4f6826b85be5873793741a9fe32f0ce09406f1d.zip
Admin/Pull: Allow a list of files to be read from stdin
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5976 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Admin/Pull.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/lib/Server/Admin/Pull.py b/src/lib/Server/Admin/Pull.py
index d6dfa9e5a..71a7b496a 100644
--- a/src/lib/Server/Admin/Pull.py
+++ b/src/lib/Server/Admin/Pull.py
@@ -1,4 +1,5 @@
import getopt
+import sys
import Bcfg2.Server.Admin
class Pull(Bcfg2.Server.Admin.MetadataCore):
@@ -7,19 +8,22 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
"""
__shorthelp__ = ("Integrate configuration information "
"from clients into the server repository")
- __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin pull [-v] [-f][-I] "
+ __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin pull [-v] [-f][-I] [-s]"
"<client> <entry type> <entry name>")
__usage__ = ("bcfg2-admin pull [options] <client> <entry type> "
"<entry name>\n\n"
" %-25s%s\n"
" %-25s%s\n"
+ " %-25s%s\n"
" %-25s%s\n" %
("-v",
"be verbose",
"-f",
"force",
"-I",
- "interactive"))
+ "interactive",
+ "-s",
+ "stdin"))
allowed = ['Metadata', 'BB', "DBStats", "Statistics", "Cfg", "SSHbase"]
def __init__(self, configfile):
@@ -30,8 +34,9 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
def __call__(self, args):
Bcfg2.Server.Admin.Mode.__call__(self, args)
+ use_stdin = False
try:
- opts, gargs = getopt.getopt(args, 'vfI')
+ opts, gargs = getopt.getopt(args, 'vfIs')
except:
print self.__shorthelp__
raise SystemExit(1)
@@ -42,7 +47,22 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
self.mode = 'force'
elif opt[0] == '-I':
self.mode == 'interactive'
- self.PullEntry(gargs[0], gargs[1], gargs[2])
+ elif opt[0] == '-s':
+ use_stdin = True
+
+ if use_stdin:
+ for line in sys.stdin:
+ try:
+ self.PullEntry(*line.split(None, 3))
+ except SystemExit:
+ print " for %s" % line
+ except:
+ print "Bad entry: %s" % line.strip()
+ elif len(gargs) < 3:
+ print self.__longhelp__
+ raise SystemExit(1)
+ else:
+ self.PullEntry(gargs[0], gargs[1], gargs[2])
def BuildNewEntry(self, client, etype, ename):
"""Construct a new full entry for given client/entry from statistics."""