From 0b68cbc71bf044f95f51982002dad26a22b81fb1 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 1 Mar 2007 01:18:14 +0000 Subject: Add two new options to bcfg2-build-reports (Patch from Sumit Roy) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2892 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/bcfg2-build-reports | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/sbin/bcfg2-build-reports b/src/sbin/bcfg2-build-reports index dafa1326d..4504856cd 100755 --- a/src/sbin/bcfg2-build-reports +++ b/src/sbin/bcfg2-build-reports @@ -139,6 +139,8 @@ def pretty_print(element, level=0): if __name__ == '__main__': + ping=True + all=False if '-C' in sys.argv: cfpath = sys.argv[sys.argv.index('-C') + 1] else: @@ -157,17 +159,21 @@ if __name__ == '__main__': #websrcspath = "/usr/share/bcfg2/web-rprt-srcs/" try: - opts, args = getopt.getopt(sys.argv[1:], "C:hc:s:", ["help", "config=", "stats="]) + opts, args = getopt.getopt(sys.argv[1:], "C:hAc:Ns:", ["help", "all", "config=","no-ping", "stats="]) except getopt.GetoptError, mesg: # print help information and exit: - print "%s\nUsage:\nbcfg2-build-reports [-h] [-c ] [-s ]" % (mesg) + print "%s\nUsage:\nbcfg2-build-reports [-h][-A (include ALL clients)] [-c ] [-s ][-N (do not ping clients)]" % (mesg) raise SystemExit, 2 for o, a in opts: if o in ("-h", "--help"): print "Usage:\nbcfg2-build-reports [-h] [-c ] [-s ]" raise SystemExit + if o in ("-A", "--all"): + all=True if o in ("-c", "--config"): configpath = a + if o in ("-N", "--no-ping"): + ping = False if o in ("-s", "--stats"): statpath = a @@ -176,7 +182,8 @@ if __name__ == '__main__': #try: #hostinstat = os.stat(hostinfopath) #if (time() - hostinstat[9])/(60*60) > 23.5: - os.system('bcfg2-ping-sweep') # bcfg2-ping-sweep needs to be in path + if ping: + os.system('bcfg2-ping-sweep') # bcfg2-ping-sweep needs to be in path #except OSError: # os.system('GenerateHostInfo')#Generate HostInfo needs to be in path @@ -202,18 +209,29 @@ if __name__ == '__main__': nodereport = Element("Report", attrib={"time" : asctime()}) #should all of the other info in Metadata be appended? #What about all of the package stuff for other types of reports? - for client in clientsdata.findall("Client"): nodel = Element("Node", attrib={"name" : client.get("name")}) nodel.append(client) - for nod in statsdata.findall("Node"): if client.get('name').find(nod.get('name')) == 0: for statel in nod.findall("Statistics"): nodel.append(statel) - nodereport.append(nodel) - - + nodereport.append(nodel) + + if all: + for nod in statsdata.findall("Node"): + for client in clientsdata.findall("Client"): + if client.get('name').find(nod.get('name')) == 0: + break + else: + nodel = Element("Node", attrib={"name" : nod.get("name")}) + client = Element("Client", attrib={"name" : nod.get("name"), "profile" : "default"}) + nodel.append(client) + for statel in nod.findall("Statistics"): + nodel.append(statel) + nodereport.append(nodel) + + for reprt in configdata.findall('Report'): nodereport.set("name", reprt.get("name", default="BCFG Report")) -- cgit v1.2.3-1-g7c22