summaryrefslogtreecommitdiffstats
path: root/reports/brpt
diff options
context:
space:
mode:
authorJoey Hagedorn <hagedorn@mcs.anl.gov>2006-07-20 15:39:02 +0000
committerJoey Hagedorn <hagedorn@mcs.anl.gov>2006-07-20 15:39:02 +0000
commit01317c38ca41e7ee9ea060f9e96e232999e2e734 (patch)
tree22d9681298bc31228ff5093f9522293818a00f6c /reports/brpt
parent714beece4603247a5008002922eb7072e0066f2b (diff)
downloadbcfg2-01317c38ca41e7ee9ea060f9e96e232999e2e734.tar.gz
bcfg2-01317c38ca41e7ee9ea060f9e96e232999e2e734.tar.bz2
bcfg2-01317c38ca41e7ee9ea060f9e96e232999e2e734.zip
New Reports: Finalized Reasons display for bad and modified config elements. Also displays of other hosts with the same problem.
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1973 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'reports/brpt')
-rw-r--r--reports/brpt/reports/models.py3
-rw-r--r--reports/brpt/reports/templates/config_items/index.html77
-rw-r--r--reports/brpt/reports/templates/displays/timing.html1
-rw-r--r--reports/brpt/reports/views.py86
-rw-r--r--reports/brpt/urls.py4
5 files changed, 152 insertions, 19 deletions
diff --git a/reports/brpt/reports/models.py b/reports/brpt/reports/models.py
index b6ac51005..3fc6525a3 100644
--- a/reports/brpt/reports/models.py
+++ b/reports/brpt/reports/models.py
@@ -45,11 +45,12 @@ class InteractiveManager(models.Manager):
def interaction_per_client(self, maxdate = None):
from django.db import connection
cursor = connection.cursor()
- if (maxdate == 'now' or maxdate == None):
+ if (maxdate == 'now' or maxdate == None):
cursor.execute("select reports_interaction.id, x.client_id from (select client_id, MAX(timestamp) "+
"as timer from reports_interaction GROUP BY client_id) x, reports_interaction where "+
"reports_interaction.client_id = x.client_id AND reports_interaction.timestamp = x.timer")
else:
+ #THIS TOTALLY BREAKS WHEN you go too far back in time, when it should return 0 records. Try except it?
cursor.execute("select reports_interaction.id, x.client_id from (select client_id, timestamp, MAX(timestamp) "+
"as timer from reports_interaction WHERE timestamp < %s GROUP BY client_id) x, reports_interaction where "+
"reports_interaction.client_id = x.client_id AND reports_interaction.timestamp = x.timer", [maxdate])
diff --git a/reports/brpt/reports/templates/config_items/index.html b/reports/brpt/reports/templates/config_items/index.html
new file mode 100644
index 000000000..952172715
--- /dev/null
+++ b/reports/brpt/reports/templates/config_items/index.html
@@ -0,0 +1,77 @@
+{% extends "base.html" %}
+
+{% block extra_header_info %}
+<script type="text/javascript" src="/site_media/CalendarPopup.js"></script>
+<script language="JavaScript">var cal = new CalendarPopup();</script>
+{% endblock%}
+{% block title %}Configuration Element Details{% endblock %}
+
+{% block pagebanner %}
+ <div class="header">
+ <h1>Configuration Element Details</h1>
+ </div>
+ <br/>
+{% endblock %}
+
+{% block content %}
+{% ifequal mod_or_bad "bad" %}
+<div class="bad">
+<h2>Bad {{item.kind}}: {{item.name}}</h2>
+</div>
+{% else %}
+<div class="modified">
+<h2>Modified {{item.kind}}: {{item.name}}</h2>
+</div>
+{% endifequal %}
+<center>
+<table border=1 padding=0 >
+<tr><th>Reason</th><th>Current Status</th><th>Specified in BCFG</th></tr>
+{% if item.reason.current_owner %}
+<tr><td align="right"><b>Owner: </b></td><td>{{item.reason.owner}}</td><td>{{item.reason.current_owner}}</td></tr>
+{% endif %}{% if item.reason.current_group %}
+<tr><td align="right"><b>Group: </b></td><td>{{item.reason.group}}</td><td>{{item.reason.current_group}}</td></tr>
+{% endif %}{% if item.reason.current_perms %}
+<tr><td align="right"><b>Permissions: </b></td><td>{{item.reason.perms}}</td><td>{{item.reason.current_perms}}</td></tr>
+{% endif %}{% if item.reason.current_status %}
+<tr><td align="right"><b>Status: </b></td><td>{{item.reason.status}}</td><td>{{item.reason.current_status}}</td></tr>
+{% endif %}{% if item.reason.current_to %}
+<tr><td align="right"><b>Link Destination: </b></td><td>{{item.reason.to}}</td><td>{{item.reason.current_to}}</td></tr>
+{% endif %}{% if item.reason.current_version %}
+<tr><td align="right"><b>Version: </b></td><td>{{item.reason.version}}</td><td>{{item.reason.current_version}}</td></tr>
+{% endif %}{% if not item.reason.current_exists %}
+<tr><td align="right"><b>Existance: </b></td><td colspan=2>This item does not currently exist on the host but is specified to exist in the configuration.</td></tr>
+{% endif %}{% if item.reason.current_diff %}
+<tr><td align="right"><b>Unified Diff: </b></td><td colspan=2><pre>{{item.reason.current_diff}}</pre></td></tr>
+{% endif %}
+</table></center>
+<hr/>
+<div>
+<span class="mini-date">
+<b>Enter date or use calendar popup: </b>
+<form name="timestamp-select">
+<input type="text" name="date1" value="{{timestamp_date}}" size=10>@
+<input type="text" name="time" value="{{timestamp_time}}" size=8>
+<a href="" onClick="cal.select(document.forms['timestamp-select'].date1,'anchor1','yyyy-MM-dd'); return false;"
+ name="anchor1" ID="anchor1">Calendar</A>
+<input type="button" name="go" value="Go" onClick="location.href='/elements/{{mod_or_bad}}/{{item.id}}/'+document.forms['timestamp-select'].date1.value+'@'+document.forms['timestamp-select'].time.value;" />
+ | <input type="button" name="now" value="Now" onClick="location.href='/elements/{{mod_or_bad}}/{{item.id}}';"/>
+</form>
+</span><br/><br/><br/></div>
+{% if associated_client_list %}
+ <p>The following clients had this problem as of {{timestamp_date}}@{{timestamp_time}}:</p>
+ {% for client in associated_client_list %}
+ <a href="/clients/{{client.name}}">{{client.name}}</a><br/>
+ {% endfor %}
+ <br />
+ <br />
+{% else %}
+ <p>No Clients had this problem at {{timestamp}}</p>
+{% endif %}
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/reports/brpt/reports/templates/displays/timing.html b/reports/brpt/reports/templates/displays/timing.html
index e951ff886..e9020b8ef 100644
--- a/reports/brpt/reports/templates/displays/timing.html
+++ b/reports/brpt/reports/templates/displays/timing.html
@@ -13,7 +13,6 @@
<span class="notebox">Report Run @ {% now "F j, Y P"%}</span>
</div>
<br/>
-
<div>
<span class="mini-date">
<b>Enter date or use calendar popup: </b>
diff --git a/reports/brpt/reports/views.py b/reports/brpt/reports/views.py
index e4be8f745..a9dde75fc 100644
--- a/reports/brpt/reports/views.py
+++ b/reports/brpt/reports/views.py
@@ -11,33 +11,84 @@ from django.db import connection
def index(request):
return render_to_response('index.html')
-def config_item_modified(request, eyedee =None):
+def config_item_modified(request, eyedee =None, timestamp = 'now'):
#if eyedee = None, dump with a 404
- mod_or_bad = "Modified"
-
+ timestamp = timestamp.replace("@"," ")
+ mod_or_bad = "modified"
+
item = Modified.objects.get(id=eyedee)
-
#if everything is blank except current_exists, do something special
+ cursor = connection.cursor()
+ if timestamp == 'now':
+ cursor.execute("select client_id from reports_interaction, reports_modified_interactions, reports_client "+
+ "WHERE reports_client.current_interaction_id = reports_modified_interactions.interaction_id "+
+ "AND reports_modified_interactions.interaction_id = reports_interaction.id "+
+ "AND reports_modified_interactions.modified_id = %s", [eyedee])
+ associated_client_list = Client.objects.filter(id__in=[x[0] for x in cursor.fetchall()])
+ else:
+ interact_queryset = Interaction.objects.interaction_per_client(timestamp)
+ interactionlist = []
+ [interactionlist.append(x.id) for x in interact_queryset]
+ if not interactionlist == []:
+ cursor.execute("select client_id from reports_interaction, reports_modified_interactions, reports_client "+
+ "WHERE reports_modified_interactions.interaction_id IN %s "+
+ "AND reports_modified_interactions.interaction_id = reports_interaction.id "+
+ "AND reports_modified_interactions.modified_id = %s", [interactionlist, eyedee])
+ associated_client_list = Client.objects.filter(id__in=[x[0] for x in cursor.fetchall()])
+ else:
+ associated_client_list = []
- #cursor = connection.cursor()
- #cursor.execute("select client_id from reports_interaction, reports_modified_interactions, reports_client "+
- # "WHERE reports_client.current_interaction_id = reports_modified_interactions.interaction_id "+
- # "AND reports_modified_interactions.interaction_id = reports_interaction.id"+
- # "AND reports_modified_interactions = %s", [eyedee])
-
- #associated_client_list = Clients.objects.filter(id__in=[x[0] for x in cursor.fetchall()])
+ if timestamp == 'now':
+ timestamp = datetime.now().isoformat('@')
+ for q in connection.queries:
+ print q
return render_to_response('config_items/index.html',{'item':item,
'mod_or_bad':mod_or_bad,
- })
- #'associated_client_list':associated_client_list})
+ 'associated_client_list':associated_client_list,
+ 'timestamp' : timestamp,
+ 'timestamp_date' : timestamp[:10],
+ 'timestamp_time' : timestamp[11:19]})
+
-def config_item_bad(request, eyedee = None):
- mod_or_bad = "Bad"
+def config_item_bad(request, eyedee = None, timestamp = 'now'):
+ timestamp = timestamp.replace("@"," ")
+ mod_or_bad = "bad"
item = Bad.objects.get(id=eyedee)
+ cursor = connection.cursor()
+ if timestamp == 'now':
+ cursor.execute("select client_id from reports_interaction, reports_bad_interactions, reports_client "+
+ "WHERE reports_client.current_interaction_id = reports_bad_interactions.interaction_id "+
+ "AND reports_bad_interactions.interaction_id = reports_interaction.id "+
+ "AND reports_bad_interactions.bad_id = %s", [eyedee])
+ associated_client_list = Client.objects.filter(id__in=[x[0] for x in cursor.fetchall()])
+ else:
+ interact_queryset = Interaction.objects.interaction_per_client(timestamp)
+ interactionlist = []
+ [interactionlist.append(x.id) for x in interact_queryset]
+ if not interactionlist == []:
+ cursor.execute("select client_id from reports_interaction, reports_bad_interactions, reports_client "+
+ "WHERE reports_bad_interactions.interaction_id IN %s "+
+ "AND reports_bad_interactions.interaction_id = reports_interaction.id "+
+ "AND reports_bad_interactions.bad_id = %s", [interactionlist, eyedee])
+ associated_client_list = Client.objects.filter(id__in=[x[0] for x in cursor.fetchall()])
+ else:
+ associated_client_list = None
+
+ if timestamp == 'now':
+ timestamp = datetime.now().isoformat('@')
+
+
+ for q in connection.queries:
+ print q
+
return render_to_response('config_items/index.html',{'item':item,
- 'mod_or_bad':mod_or_bad})
+ 'mod_or_bad':mod_or_bad,
+ 'associated_client_list':associated_client_list,
+ 'timestamp' : timestamp,
+ 'timestamp_date' : timestamp[:10],
+ 'timestamp_time' : timestamp[11:19]})
@@ -73,7 +124,8 @@ def display_sys_view(request, timestamp = 'now'):
def display_summary(request, timestamp = 'now'):
client_lists = prepare_client_lists(request, timestamp)
-
+ #this returns timestamp and the timestamp parts
+
#for q in connection.queries:
# print q
diff --git a/reports/brpt/urls.py b/reports/brpt/urls.py
index 44050a774..982505273 100644
--- a/reports/brpt/urls.py
+++ b/reports/brpt/urls.py
@@ -17,8 +17,12 @@ urlpatterns = patterns('',
(r'^displays/timing/$','brpt.reports.views.display_timing'),
(r'^displays/$','brpt.reports.views.display_index'),
+
+ (r'^elements/modified/(?P<eyedee>\d+)/(?P<timestamp>(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])@([01][0-9]|2[0-3]):([0-5][0-9]|60):([0-5][0-9]|60))/$','brpt.reports.views.config_item_modified'),
(r'^elements/modified/(?P<eyedee>\d+)/$','brpt.reports.views.config_item_modified'),
+ (r'^elements/bad/(?P<eyedee>\d+)/(?P<timestamp>(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])@([01][0-9]|2[0-3]):([0-5][0-9]|60):([0-5][0-9]|60))/$','brpt.reports.views.config_item_bad'),
(r'^elements/bad/(?P<eyedee>\d+)/$','brpt.reports.views.config_item_bad'),
+
# Uncomment this for admin:
#(r'^admin/', include('django.contrib.admin.urls')),