summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Reports/reports/views.py
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-11-09 23:51:56 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-11-09 23:51:56 +0000
commitd14eef57303c4b9cef33fa97b71e12aa25e6bd0a (patch)
tree2779f16fc948fcceecc3fe73aac741e4f92ea797 /src/lib/Server/Reports/reports/views.py
parentd7e21c89c1b2e37ff45b40d14680a74ffc4974a5 (diff)
downloadbcfg2-d14eef57303c4b9cef33fa97b71e12aa25e6bd0a.tar.gz
bcfg2-d14eef57303c4b9cef33fa97b71e12aa25e6bd0a.tar.bz2
bcfg2-d14eef57303c4b9cef33fa97b71e12aa25e6bd0a.zip
Reports: Detailed Client List view from Tim Laszlo
This commit adds a new view for the reporting system submitted by Tim Laszlo. It gives detailed information about clients in a table format with State, Good/Bad/Extra entry counts, time of last run, and server client last communicated with. Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5563 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Reports/reports/views.py')
-rw-r--r--src/lib/Server/Reports/reports/views.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/Server/Reports/reports/views.py b/src/lib/Server/Reports/reports/views.py
index 7a092c7d2..03a97e523 100644
--- a/src/lib/Server/Reports/reports/views.py
+++ b/src/lib/Server/Reports/reports/views.py
@@ -102,6 +102,53 @@ def client_index(request, timestamp = 'now'):
'timestamp_date' : timestamp[:10],
'timestamp_time' : timestamp[11:19]})
+def client_detailed_list(request, **kwargs):
+ '''
+ Provides a more detailed list view of the clients. Allows for extra
+ filters to be passed in. Somewhat clunky now that dates are allowed.
+ '''
+ context = dict(path=request.path)
+ timestamp = 'now'
+ entry_max = None
+ if request.GET:
+ context['qsa']='?%s' % request.GET.urlencode()
+ if request.GET.has_key('date1') and request.GET.has_key('time'):
+ timestamp = "%s %s" % (request.GET['date1'],request.GET['time'])
+ entry_max = datetime(*strptime(timestamp, "%Y-%m-%d %H:%M:%S")[0:6])
+ client_list = Client.objects.active(timestamp).order_by('name')
+ if timestamp == 'now':
+ timestamp = datetime.now().isoformat('@')
+ context['timestamp_date'] = timestamp[:10]
+ context['timestamp_time'] = timestamp[11:19]
+
+ if 'server' in kwargs and kwargs['server']:
+ context['server'] = kwargs['server']
+ if 'state' in kwargs and kwargs['state']:
+ context['state'] = kwargs['state']
+
+ # build the entry list from available clients
+ entry_list = []
+ if entry_max:
+ for client in client_list:
+ try:
+ e = interaction.objects.filter(client=client).filter(timestamp__lt=entry_max).order_by('-timestamp')[0]
+ if 'server' in context and e.server != context['server']:
+ continue
+ if 'state' in context and e.state != context['state']:
+ continue
+ entry_list.append(e)
+ except IndexError:
+ # Should never see this.. but skip clients with no data
+ pass
+ else:
+ if 'server' in context:
+ client_list = client_list.filter(current_interaction__server__exact=kwargs['server'])
+ if 'state' in context:
+ client_list = client_list.filter(current_interaction__state__exact=kwargs['state'])
+ [ entry_list.append(x.current_interaction) for x in client_list ]
+ context['entry_list'] = entry_list
+ return render_to_response('clients/detailed-list.html', context)
+
def client_detail(request, hostname = None, pk = None):
#SETUP error pages for when you specify a client or interaction that doesn't exist
client = get_object_or_404(Client, name=hostname)