From dd36afc992b78d4b03b8a2c8a0ba50cfbacc5662 Mon Sep 17 00:00:00 2001 From: James Yang Date: Tue, 15 Jul 2008 15:52:08 +0000 Subject: 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 --- src/sbin/bcfg2-reports | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/sbin/bcfg2-reports') 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: -- cgit v1.2.3-1-g7c22