Author: eallen
Date: 2008-09-19 17:35:55 -0400 (Fri, 19 Sep 2008)
New Revision: 2505
Modified:
mgmt/trunk/cumin/python/cumin/job.py
mgmt/trunk/cumin/python/cumin/job.strings
mgmt/trunk/cumin/python/cumin/model.py
Log:
Added JobGroup Stats tab
Removed JobGroup Details tab
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-09-19 21:35:01 UTC (rev 2504)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-09-19 21:35:55 UTC (rev 2505)
@@ -204,10 +204,69 @@
self.__tabs = TabbedModeSet(app, "tabs")
self.add_child(self.__tabs)
+ self.__tabs.add_tab(JobGroupStats(app, "stats"))
self.__tabs.add_tab(JobGroupJobSet(app, "jobs"))
self.__tabs.add_tab(SystemSet(app, "systems"))
- self.__tabs.add_tab(CuminDetails(app, "details"))
+ #self.__tabs.add_tab(CuminDetails(app, "details"))
+class JobGroupStats(Widget):
+ def __init__(self, app, name):
+ super(JobGroupStats, self).__init__(app, name)
+
+ stats = JobGroupStatSet(app, "general", "general")
+ self.add_child(stats)
+
+ def render_title(self, session):
+ return "Statistics"
+
+class JobGroupStatSet(StatSet):
+ def __init__(self, app, name, category):
+ super(JobGroupStatSet, self).__init__(app, name, category)
+
+ self.jobs = Attribute(app, "jobs")
+ self.add_attribute(self.jobs)
+
+ def process(self, session):
+ group = self.frame.get_args(session)[0]
+ where_group = "custom_group = '%s'" % group.get_id()
+ value = Job.select(where_group).count()
+ self.jobs.set(session, value)
+ super(JobGroupStatSet, self).process(session)
+
+ def render_rate_text(self, session, args):
+ return "Percentage"
+
+ def render_item_name(self, session, args):
+ stat, object = args
+ return stat.name
+
+ def render_item_value(self, session, args):
+ stat, group = args
+ if stat.name == "Jobs":
+ return self.jobs.get(session)
+ else:
+ state = stat.name
+ value = self.get_value(group, state)
+ return value
+
+ def get_value(self, group, state):
+ where_group = "custom_group = '%s' \
+ and job_status = %i" % (group.get_id(),
+ JobStatusInfo.get_status_int(state))
+ return Job.select(where_group).count()
+
+ def render_item_rate(self, session, args):
+ stat, group = args
+ jobs = self.jobs.get(session)
+ state = stat.name
+ if stat.name == "Jobs":
+ value = jobs
+ else:
+ value = self.get_value(group, state)
+ percent = (value*1.0) / (jobs*1.0) * 100.0
+ return jobs and "%2.1f" % percent or "-"
+
+
class JobRemoveButton(FormButton):
def process_submit(self, session):
ids = self.parent.ids.get(session)
@@ -703,8 +762,9 @@
self.got_data = False
def completion(status, job_output):
- self.job_output = job_output["Data"]
- self.got_data = True
+ if "Data" in job_output:
+ self.job_output = job_output["Data"]
+ self.got_data = True
def predicate():
return self.got_data
@@ -720,9 +780,9 @@
job.Fetch(model.data, completion, file, start, end)
# wait for up to 20 seconds for completion to be called
wait(predicate, timeout=20)
- except:
- #self.job_output = "Unable to get file at %s" % file
- self.job_output = self.get_fake_output()
+ except Exception, e:
+ self.job_output = "Unable to get file at %s. Reason: %s" %
(file, e)
+ #self.job_output = self.get_fake_output()
return self.job_output and escape_entity(self.job_output)
Modified: mgmt/trunk/cumin/python/cumin/job.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.strings 2008-09-19 21:35:01 UTC (rev 2504)
+++ mgmt/trunk/cumin/python/cumin/job.strings 2008-09-19 21:35:55 UTC (rev 2505)
@@ -66,7 +66,13 @@
from job as j
{sql_where}
+[JobGroupStats.html]
+ <h2>General</h2>
+ <div style="width:50%;">
+ {general}
+ </div>
+
[JobsAndGroupsTab.html]
<div class="rfloat">{phase}</div>
{group}
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-09-19 21:35:01 UTC (rev 2504)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-09-19 21:35:55 UTC (rev 2505)
@@ -1480,10 +1480,25 @@
super(CuminJobGroup, self).__init__ \
(model, "job_group", JobGroup)
+ stat = CuminStat(self, "Running")
+ stat.title = "Running Jobs"
+
+ stat = CuminStat(self, "Completed")
+ stat.title = "Completed Jobs"
+
+ stat = CuminStat(self, "Idle")
+ stat.title = "Idle Jobs"
+
+ stat = CuminStat(self, "Held")
+ stat.title = "Held Jobs"
+
action = self.Hold(self, "hold")
action.title = "Hold"
action.summary = True
+ stat = CuminStat(self, "Jobs")
+ stat.title = "Total Jobs"
+
action = self.Release(self, "release")
action.title = "Release"
action.summary = True