summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoey Hagedorn <hagedorn@mcs.anl.gov>2007-06-06 14:50:20 +0000
committerJoey Hagedorn <hagedorn@mcs.anl.gov>2007-06-06 14:50:20 +0000
commit0ad447aeae0fd400dfd849aca41e6edf87cf7ffc (patch)
tree0b1a8e0c7b1a462d30cc2b08778da964df191688 /src
parent49e0397c4b77f20385731bec146b050e8229b7c2 (diff)
downloadbcfg2-0ad447aeae0fd400dfd849aca41e6edf87cf7ffc.tar.gz
bcfg2-0ad447aeae0fd400dfd849aca41e6edf87cf7ffc.tar.bz2
bcfg2-0ad447aeae0fd400dfd849aca41e6edf87cf7ffc.zip
bugfix to updated statistics retention policy
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3248 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Reports/reports/views.py7
-rw-r--r--src/lib/Server/Reports/settings.py1
-rw-r--r--src/lib/Server/Reports/urls.py2
-rw-r--r--src/lib/Server/Statistics.py15
4 files changed, 16 insertions, 9 deletions
diff --git a/src/lib/Server/Reports/reports/views.py b/src/lib/Server/Reports/reports/views.py
index 5ddfa6533..758c07249 100644
--- a/src/lib/Server/Reports/reports/views.py
+++ b/src/lib/Server/Reports/reports/views.py
@@ -172,6 +172,13 @@ def client_detail(request, hostname = None, pk = None):
interaction = client.interactions.get(pk=pk)#can this be a get object or 404?
return render_to_response('clients/detail.html', {'client': client, 'interaction': interaction})
+def client_manage(request, hostname = None):
+ #SETUP error pages for when you specify a client or interaction that doesn't exist
+ client = get_object_or_404(Client, name=hostname)
+ #if post data has a ?disable=DATE, set it for the client in the DB (model!) +save
+ interaction = client.current_interaction
+ return render_to_response('clients/manage.html', {'client': client, 'interaction': interaction})
+
def display_sys_view(request, timestamp = 'now'):
client_lists = prepare_client_lists(request, timestamp)
return render_to_response('displays/sys_view.html', client_lists)
diff --git a/src/lib/Server/Reports/settings.py b/src/lib/Server/Reports/settings.py
index df781c890..f55696e27 100644
--- a/src/lib/Server/Reports/settings.py
+++ b/src/lib/Server/Reports/settings.py
@@ -59,6 +59,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
+ 'django.middleware.profile.ProfileMiddleware',
)
ROOT_URLCONF = 'Bcfg2.Server.Reports.urls'
diff --git a/src/lib/Server/Reports/urls.py b/src/lib/Server/Reports/urls.py
index 6d5fe8833..9f602cb4d 100644
--- a/src/lib/Server/Reports/urls.py
+++ b/src/lib/Server/Reports/urls.py
@@ -4,7 +4,9 @@ urlpatterns = patterns('',
# Example:
# (r'^Bcfg2.Server.Reports/', include('Bcfg2.Server.Reports.apps.foo.urls.foo')),
(r'^/*$','Bcfg2.Server.Reports.reports.views.index'),
+
(r'^clients/(?P<hostname>\S+)/(?P<pk>\d+)/$', 'Bcfg2.Server.Reports.reports.views.client_detail'),
+ (r'^clients/(?P<hostname>\S+)/manage/$', 'Bcfg2.Server.Reports.reports.views.client_manage'),
(r'^clients/(?P<hostname>\S+)/$', 'Bcfg2.Server.Reports.reports.views.client_detail'),
(r'^clients/(?P<hostname>\S+)$', 'Bcfg2.Server.Reports.reports.views.client_detail'),
#hack because hostnames have periods and we still want to append slash
diff --git a/src/lib/Server/Statistics.py b/src/lib/Server/Statistics.py
index adde4ad98..3dd275a89 100644
--- a/src/lib/Server/Statistics.py
+++ b/src/lib/Server/Statistics.py
@@ -74,13 +74,12 @@ class Statistics(object):
elif nummatch == 1 and not node_dirty:
# Delete old instance
node = nodes[0]
- now = asctime(localtime())
- for elem in [elem for elem in node.findall('Statistics') if isOlderThan24h(elem.get('time')) == True]:
+ for elem in [elem for elem in node.findall('Statistics') if self.isOlderThan24h(elem.get('time'))]:
node.remove(elem)
elif nummatch == 1 and node_dirty:
# Delete old dirty statistics entry
node = nodes[0]
- for elem in [elem for elem in node.findall('Statistics') if (elem.get('state') == 'dirty' and isOlderThan24h(elem.get('time')) == True]:
+ for elem in [elem for elem in node.findall('Statistics') if (elem.get('state') == 'dirty' and self.isOlderThan24h(elem.get('time')))]:
node.remove(elem)
else:
# Shouldn't be reached
@@ -97,13 +96,11 @@ class Statistics(object):
self.WriteBack()
- def isOlderThan24h(time):
+ def isOlderThan24h(self, testTime):
'''Helper function to determine if <time> string is older than 24 hours'''
now = time()
- utime = mktime(strptime(time))
+ utime = mktime(strptime(testTime))
secondsPerDay = 60*60*24
- if (now-utime)>secondsPerDay:
- return True
- else:
- return False
+ return (now-utime) > secondsPerDay
+