From b2cd8e6bfc069f0665806e0d42163fa810778747 Mon Sep 17 00:00:00 2001 From: Joey Hagedorn Date: Fri, 12 Jan 2007 21:49:23 +0000 Subject: Reporting system update to include browsing by config-item rather than host-only. This enables users of the system to track down where problems are occuring across the system by looking in a package and system oriented way, rather than a host centric view only. *It is expected to be useful to verify that critical security updates are applied.* Additionally this update includes a bunch of files (yet not complete) from the Yahoo User Interface Library. It is sparsely incorporated as the files are used. This library is BSD licensed and provides great capability for the web reports. It also will help when incorporating ajax technology in to the reports for performance improvements. git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2660 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Reports/reports/views.py | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'src/lib/Server/Reports/reports/views.py') diff --git a/src/lib/Server/Reports/reports/views.py b/src/lib/Server/Reports/reports/views.py index 7f62aab94..5ddfa6533 100644 --- a/src/lib/Server/Reports/reports/views.py +++ b/src/lib/Server/Reports/reports/views.py @@ -9,6 +9,7 @@ from time import strptime from django.db import connection from django.db.backends import util from django.contrib.auth.decorators import login_required +from sets import Set def index(request): return render_to_response('index.html') @@ -85,6 +86,74 @@ def config_item_bad(request, eyedee = None, timestamp = 'now'): 'timestamp_date' : timestamp[:10], 'timestamp_time' : timestamp[11:19]}) +def bad_item_index(request, timestamp = 'now'): + timestamp = timestamp.replace("@"," ") + mod_or_bad = "bad" + cursor = connection.cursor() + + if timestamp == 'now': + bad_kinds = dict([(x,x.kind) for x in Bad.objects.filter(interactions__in= + [c.current_interaction + for c in Client.objects.all()]).distinct()]) + #this will need expiration support + kinds = list(Set(bad_kinds.values())) + item_list_dict = dict([(x,[]) for x in kinds]) + for obj in bad_kinds: + item_list_dict[obj.kind].append(obj) + + else: #this isn't done yet + bad_kinds = dict([(x,x.kind) for x in Bad.objects.filter(interactions__in= + [c.current_interaction + for c in Client.objects.all()]).distinct()]) + #this will need expiration support + kinds = list(Set(bad_kinds.values())) + item_list_dict = dict([(x,[]) for x in kinds]) + for obj in bad_kinds: + item_list_dict[obj.kind].append(obj) + + item_list_pseudodict = item_list_dict.items() + if timestamp == 'now': + timestamp = datetime.now().isoformat('@') + + return render_to_response('config_items/listing.html', {'item_list_pseudodict':item_list_pseudodict, + 'mod_or_bad':mod_or_bad, + 'timestamp' : timestamp, + 'timestamp_date' : timestamp[:10], + 'timestamp_time' : timestamp[11:19]}) +def modified_item_index(request, timestamp = 'now'): + timestamp = timestamp.replace("@"," ") + mod_or_bad = "modified" + cursor = connection.cursor() + + if timestamp == 'now': + mod_kinds = dict([(x,x.kind) for x in Modified.objects.filter(interactions__in= + [c.current_interaction + for c in Client.objects.all()]).distinct()]) + #this will need expiration support + kinds = list(Set(mod_kinds.values())) + item_list_dict = dict([(x,[]) for x in kinds]) + for obj in mod_kinds: + item_list_dict[obj.kind].append(obj) + + else: #this isn't done yet + mod_kinds = dict([(x,x.kind) for x in Modified.objects.filter(interactions__in= + [c.current_interaction + for c in Client.objects.all()]).distinct()]) + #this will need expiration support + kinds = list(Set(mod_kinds.values())) + item_list_dict = dict([(x,[]) for x in kinds]) + for obj in mod_kinds: + item_list_dict[obj.kind].append(obj) + + item_list_pseudodict = item_list_dict.items() + if timestamp == 'now': + timestamp = datetime.now().isoformat('@') + + return render_to_response('config_items/listing.html', {'item_list_pseudodict':item_list_pseudodict, + 'mod_or_bad':mod_or_bad, + 'timestamp' : timestamp, + 'timestamp_date' : timestamp[:10], + 'timestamp_time' : timestamp[11:19]}) def client_index(request): @@ -175,6 +244,8 @@ def display_index(request): return render_to_response('displays/index.html') def prepare_client_lists(request, timestamp = 'now'): + #I suggest we implement "expiration" here. + timestamp = timestamp.replace("@"," ") #client_list = Client.objects.all().order_by('name')#change this to order by interaction's state client_interaction_dict = {} -- cgit v1.2.3-1-g7c22