Author: eallen
Date: 2008-09-25 11:23:36 -0400 (Thu, 25 Sep 2008)
New Revision: 2541
Modified:
mgmt/trunk/cumin/python/cumin/job.py
mgmt/trunk/cumin/python/cumin/scheduler.py
mgmt/trunk/cumin/python/cumin/submitter.py
Log:
Consolidated some methods in JobFrame class
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-09-25 15:22:40 UTC (rev 2540)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-09-25 15:23:36 UTC (rev 2541)
@@ -82,6 +82,10 @@
def get_phase_sql(self, session):
return self.phase.get_sql_constraint(session)
+
+ def get_phase_title(self, session):
+ state = self.phase.get(session)
+ return self.phase.get_title(state)
class ArgsColumn(SqlTableColumn):
def render_title(self, session, data):
@@ -175,6 +179,61 @@
def render_title(self, session, data):
return "Title"
+class JobTab(JobSet, Form):
+ def __init__(self, app, name):
+ super(JobTab, self).__init__(app, name)
+
+ self.set_default_column_name("global_job_id")
+
+ self.__remove = JobRemoveButton(app, "remove", self)
+ self.add_child(self.__remove)
+
+ self.__hold = JobHoldButton(app, "hold", self)
+ self.add_child(self.__hold)
+
+ self.__release = JobReleaseButton(app, "release", self)
+ self.add_child(self.__release)
+
+ def get_visible_columns(self, session):
+ return self.get_request_visible_columns(session, ["custom_group",
"scheduler", "submitter"])
+
+ def render_sql_where(self, session, *args):
+ phase_sql = self.get_phase_sql(session)
+ return "where %s" % phase_sql
+
+ def render_count(self, session, *args):
+ count = self.get_item_count(session, *args)
+ phase = self.get_phase_title(session)
+ if phase == "All":
+ phase = ""
+ return "%i %s %s" % (count, phase, count == 1 and "Job" or
"Jobs")
+
+class JobSetFrame(object):
+ """ Intermediate class to consolidate the show_xxx methods associated
with a jobset
+
+ Used by LimitsFrame, SchedulerFrame, SubmitterFrame, etc."""
+ def show_job(self, session, job):
+ return self.frame.show_job(session, job)
+
+ def show_scheduler(self, session, sched):
+ return self.frame.show_scheduler(session, sched)
+
+ def show_submitter(self, session, submitter):
+ return self.frame.show_submitter(session, submitter)
+
+ def show_job_group(self, session, job_group):
+ return self.frame.show_job_group(session, job_group)
+
+ def show_jobs_hold(self, session):
+ return self.frame.show_jobs_hold(session)
+
+ def show_jobs_release(self, session):
+ return self.frame.show_jobs_release(session)
+
+ def show_jobs_remove(self, session):
+ return self.frame.show_jobs_remove(session)
+
+
class JobGroupFrame(CuminFrame):
def __init__(self, app, name):
super(JobGroupFrame, self).__init__(app, name)
@@ -351,7 +410,7 @@
phase = self.parent.phase.get(session)
return (phase == "r" or phase == "d") and
"disabled" or "enabled"
-class JobGroupJobSet(JobSet, Form):
+class JobGroupJobSet(JobTab):
def __init__(self, app, name):
super(JobGroupJobSet, self).__init__(app, name)
@@ -378,6 +437,10 @@
group_sql = "j.custom_group = '%s'" % group.get_id()
return "where %s" % " and ".join([phase_sql, group_sql])
+ def render_count(self, session, *args):
+ str = super(JobGroupJobSet, self).render_count(session, *args)
+ return "%s in Job Group '%s'" % (str, args[0].id)
+
class JobGroupStatus(CuminStatus):
def render_color(self, session, job_group):
#return JobStatusInfo.get_status_color(job.JobStatus)
@@ -1014,28 +1077,6 @@
if is_group == "g":
return self.job_group_tab.render(session)
-class JobTab(JobSet, Form):
- def __init__(self, app, name):
- super(JobTab, self).__init__(app, name)
-
- self.set_default_column_name("global_job_id")
-
- self.__remove = JobRemoveButton(app, "remove", self)
- self.add_child(self.__remove)
-
- self.__hold = JobHoldButton(app, "hold", self)
- self.add_child(self.__hold)
-
- self.__release = JobReleaseButton(app, "release", self)
- self.add_child(self.__release)
-
- def get_visible_columns(self, session):
- return self.get_request_visible_columns(session, ["custom_group",
"scheduler", "submitter"])
-
- def render_sql_where(self, session, *args):
- phase_sql = self.get_phase_sql(session)
- return "where %s" % phase_sql
-
class JobGroupTab(JobGroupSet, Form):
def __init__(self, app, name):
super(JobGroupTab, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/scheduler.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/scheduler.py 2008-09-25 15:22:40 UTC (rev 2540)
+++ mgmt/trunk/cumin/python/cumin/scheduler.py 2008-09-25 15:23:36 UTC (rev 2541)
@@ -38,7 +38,7 @@
self.frame.show_scheduler(branch, sched).show_view(branch)
return fmt_olink(branch, sched, name=data["name"])
-class SchedulerFrame(CuminFrame):
+class SchedulerFrame(CuminFrame, JobSetFrame):
def __init__(self, app, name):
super(SchedulerFrame, self).__init__(app, name)
@@ -48,25 +48,7 @@
view = SchedulerView(app, "view")
self.add_mode(view)
self.set_view_mode(view)
-
- def show_job(self, session, job):
- return self.frame.show_job(session, job)
-
- def show_job_group(self, session, job_group):
- return self.frame.show_job_group(session, job_group)
- def show_jobs_hold(self, session):
- return self.frame.show_jobs_hold(session)
-
- def show_jobs_release(self, session):
- return self.frame.show_jobs_release(session)
-
- def show_jobs_remove(self, session):
- return self.frame.show_jobs_remove(session)
-
- def show_submitter(self, session, submitter):
- return self.frame.show_submitter(session, submitter)
-
class SchedulerView(CuminView):
def __init__(self, app, name):
super(SchedulerView, self).__init__(app, name)
@@ -128,21 +110,10 @@
def render_title(self, session, sched):
return "Jobs"
-class SchedulerJobSet(JobSet, Form):
+class SchedulerJobSet(JobTab):
def __init__(self, app, name):
super(SchedulerJobSet, self).__init__(app, name)
- self.set_default_column_name("global_job_id")
-
- self.__remove = JobRemoveButton(app, "remove", self)
- self.add_child(self.__remove)
-
- self.__hold = JobHoldButton(app, "hold", self)
- self.add_child(self.__hold)
-
- self.__release = JobReleaseButton(app, "release", self)
- self.add_child(self.__release)
-
def get_visible_columns(self, session):
return self.get_request_visible_columns(session, ["custom_group",
"submitter"])
Modified: mgmt/trunk/cumin/python/cumin/submitter.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/submitter.py 2008-09-25 15:22:40 UTC (rev 2540)
+++ mgmt/trunk/cumin/python/cumin/submitter.py 2008-09-25 15:23:36 UTC (rev 2541)
@@ -38,7 +38,7 @@
self.frame.show_submitter(branch, sub).show_view(branch)
return fmt_olink(branch, sub, name=data["name"])
-class SubmitterFrame(CuminFrame):
+class SubmitterFrame(CuminFrame, JobSetFrame):
def __init__(self, app, name):
super(SubmitterFrame, self).__init__(app, name)
@@ -49,25 +49,7 @@
self.add_mode(view)
self.set_view_mode(view)
- def show_scheduler(self, session, scheduler):
- return self.frame.show_scheduler(session, scheduler)
-
- def show_job(self, session, job):
- return self.frame.show_job(session, job)
-
- def show_job_group(self, session, job_group):
- return self.frame.show_job_group(session, job_group)
- def show_jobs_hold(self, session):
- return self.frame.show_jobs_hold(session)
-
- def show_jobs_release(self, session):
- return self.frame.show_jobs_release(session)
-
- def show_jobs_remove(self, session):
- return self.frame.show_jobs_remove(session)
-
-
class SubmitterView(CuminView):
def __init__(self, app, name):
super(SubmitterView, self).__init__(app, name)
@@ -117,21 +99,10 @@
def render_title(self, session, sched):
return "Jobs"
-class SubmitterJobSet(JobSet, Form):
+class SubmitterJobSet(JobTab):
def __init__(self, app, name):
super(SubmitterJobSet, self).__init__(app, name)
- self.set_default_column_name("global_job_id")
-
- self.__remove = JobRemoveButton(app, "remove", self)
- self.add_child(self.__remove)
-
- self.__hold = JobHoldButton(app, "hold", self)
- self.add_child(self.__hold)
-
- self.__release = JobReleaseButton(app, "release", self)
- self.add_child(self.__release)
-
def get_visible_columns(self, session):
return self.get_request_visible_columns(session, ["custom_group",
"scheduler"])