summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-reports
diff options
context:
space:
mode:
authorJames Yang <jjyang@mcs.anl.gov>2008-07-15 15:52:08 +0000
committerJames Yang <jjyang@mcs.anl.gov>2008-07-15 15:52:08 +0000
commitdd36afc992b78d4b03b8a2c8a0ba50cfbacc5662 (patch)
tree42bc7a454cbb82330135eec2c3468fd3562b1d4e /src/sbin/bcfg2-reports
parentf4a05ad2a7bc36a8fa2fa88bcd65e733a1b4725f (diff)
downloadbcfg2-dd36afc992b78d4b03b8a2c8a0ba50cfbacc5662.tar.gz
bcfg2-dd36afc992b78d4b03b8a2c8a0ba50cfbacc5662.tar.bz2
bcfg2-dd36afc992b78d4b03b8a2c8a0ba50cfbacc5662.zip
bcfg2-reports now has the option to read bad entry queries from a file
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4790 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin/bcfg2-reports')
-rwxr-xr-xsrc/sbin/bcfg2-reports28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/sbin/bcfg2-reports b/src/sbin/bcfg2-reports
index e8ad20832..98ba85247 100755
--- a/src/sbin/bcfg2-reports
+++ b/src/sbin/bcfg2-reports
@@ -20,6 +20,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name
from Bcfg2.Server.Reports.reports.models import Client
from getopt import getopt
import datetime
+import fileinput
def timecompare(client1, client2):
'''compares two clients by their timestamps'''
@@ -131,7 +132,9 @@ Options and arguments (and corresponding environment variables):
the current interaction of NAME
-x NAME : toggles expired/unexpired state of NAME
--badentry=KIND,NAME : shows only hosts whose current interaction has bad
- entries in of KIND kind and NAME name
+ entries in of KIND kind and NAME name; if a single
+ argument ARG1 is given, then KIND,NAME pairs will be
+ read from a file of name ARG1
--fields=ARG1,ARG2,... : only displays the fields ARG1,ARG2,...
(name,time,state)'
--sort=ARG1,ARG2,... : sorts output on ARG1,ARG2,... (name,time,state)'''
@@ -181,12 +184,23 @@ else:
result.append(c_inst)
elif badentry != "":
- for c_inst in c_list:
- baditems = c_inst.current_interaction.bad_items.all()
- for item in baditems:
- if item.name == badentry[1] and item.kind == badentry[0]:
- result.append(c_inst)
- break
+ if len(badentry) == 1:
+ fileread =fileinput.input(badentry[0])
+ for line in fileread:
+ badentry = line.strip().split(',')
+ for c_inst in c_list:
+ baditems = c_inst.current_interaction.bad_items.all()
+ for item in baditems:
+ if item.name == badentry[1] and item.kind == badentry[0]:
+ result.append(c_inst)
+ break
+ else:
+ for c_inst in c_list:
+ baditems = c_inst.current_interaction.bad_items.all()
+ for item in baditems:
+ if item.name == badentry[1] and item.kind == badentry[0]:
+ result.append(c_inst)
+ break
else:
for c_inst in c_list: