Author: justi9
Date: 2010-07-12 17:45:23 -0400 (Mon, 12 Jul 2010)
New Revision: 4105
Removed:
mgmt/newdata/cumin/python/cumin/grid/submission.strings
Modified:
mgmt/newdata/cumin/python/cumin/grid/pool.py
mgmt/newdata/cumin/python/cumin/grid/scheduler.py
mgmt/newdata/cumin/python/cumin/grid/submission.py
mgmt/newdata/cumin/python/cumin/main.py
mgmt/newdata/cumin/python/cumin/objectselector.py
mgmt/newdata/cumin/python/cumin/usergrid/model.strings
mgmt/newdata/cumin/python/cumin/usergrid/widgets.py
mgmt/newdata/wooly/python/wooly/table.py
Log:
* Filter submissions by pool
* Add more columns to the submission selectors
* Remove unused sqlobject-based query string resource
* Repair the job stats in the grid user view
* Add a method for inserting columns into indexed locations in tables
Modified: mgmt/newdata/cumin/python/cumin/grid/pool.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/pool.py 2010-07-12 18:05:42 UTC (rev 4104)
+++ mgmt/newdata/cumin/python/cumin/grid/pool.py 2010-07-12 21:45:23 UTC (rev 4105)
@@ -78,11 +78,9 @@
overview = PoolOverview(app, "overview", self.object)
self.view.add_tab(overview)
- submissions = SubmissionSelector(app, "submissions")
+ submissions = PoolSubmissionSelector(app, "submissions", self.object)
self.view.add_tab(submissions)
- # XXX submissions.add_filter(self.object, submissions.cls.Pool)
-
slots = SlotSelector(app, "slots", self.object)
self.view.add_tab(slots)
Modified: mgmt/newdata/cumin/python/cumin/grid/scheduler.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/scheduler.py 2010-07-12 18:05:42 UTC (rev 4104)
+++ mgmt/newdata/cumin/python/cumin/grid/scheduler.py 2010-07-12 21:45:23 UTC (rev 4105)
@@ -35,7 +35,7 @@
overview = SchedulerOverview(app, "overview", self.object)
self.view.add_tab(overview)
- submissions = SubmissionSelector(app, "submissions")
+ submissions = PoolSubmissionSelector(app, "submissions", pool)
self.view.add_tab(submissions)
cls = submissions.cls
Modified: mgmt/newdata/cumin/python/cumin/grid/submission.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/submission.py 2010-07-12 18:05:42 UTC (rev 4104)
+++ mgmt/newdata/cumin/python/cumin/grid/submission.py 2010-07-12 21:45:23 UTC (rev 4105)
@@ -8,7 +8,6 @@
from cumin.util import *
from job import JobSelector, JobFrame
-strings = StringCatalog(__file__)
log = logging.getLogger("cumin.grid.submission")
class SubmissionFrame(ObjectFrame):
@@ -23,20 +22,44 @@
jobs = JobSelector(app, "jobs", self.object)
self.view.add_tab(jobs)
+class SubmissionData(ObjectSqlAdapter):
+ def __init__(self, app):
+ submission = app.model.com_redhat_grid.Submission
+ jobserver = app.model.com_redhat_grid.JobServer
+
+ super(SubmissionData, self).__init__(app, submission)
+
+ self.add_join(jobserver, submission.jobserverRef, jobserver._id)
+
class SubmissionSelector(ObjectSelector):
def __init__(self, app, name):
cls = app.model.com_redhat_grid.Submission
+ data = SubmissionData(app)
- super(SubmissionSelector, self).__init__(app, name, cls)
+ super(SubmissionSelector, self).__init__(app, name, cls, data)
- frame = "main.grid.pool.submission"
- col = ObjectLinkColumn(app, "name", cls.Name, cls._id, frame)
- self.add_column(col)
-
self.add_attribute_column(cls.Idle)
self.add_attribute_column(cls.Running)
self.add_attribute_column(cls.Completed)
+ self.add_attribute_column(cls.Held)
+class PoolSubmissionSelector(SubmissionSelector):
+ def __init__(self, app, name, pool):
+ super(PoolSubmissionSelector, self).__init__(app, name)
+
+ self.pool = pool
+
+ cls = app.model.com_redhat_grid.JobServer
+ self.add_filter(self.pool, cls.Pool)
+
+ frame = "main.grid.pool.submission"
+ col = ObjectLinkColumn(app, "name", self.cls.Name, self.cls._id,
frame)
+ self.insert_column(1, col)
+
+ attr = self.cls.Owner
+ col = ObjectAttributeColumn(app, attr.name, attr)
+ self.insert_column(2, col)
+
class SubmissionAdd(ObjectTask):
EXPR_TYPE, INTEGER_TYPE, FLOAT_TYPE, STRING_TYPE = 0, 1, 2, 3
UNIVERSE = {"VANILLA": 5,
Deleted: mgmt/newdata/cumin/python/cumin/grid/submission.strings
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/submission.strings 2010-07-12 18:05:42 UTC (rev
4104)
+++ mgmt/newdata/cumin/python/cumin/grid/submission.strings 2010-07-12 21:45:23 UTC (rev
4105)
@@ -1,17 +0,0 @@
-[TopSubmissionSet.sql]
-select
- s.id,
- s.name,
- s.qmf_create_time,
- d.pool
-from submission as s
-join scheduler d on d.id = s.scheduler_id
-left outer join submission_stats as c on c.id = s.stats_curr_id
-where c.running > 0
- and c.qmf_update_time > now() - interval '60 seconds'
-order by s.qmf_create_time asc
-limit 5
-
-[TopSubmissionSet.count_sql]
---
-
Modified: mgmt/newdata/cumin/python/cumin/main.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/main.py 2010-07-12 18:05:42 UTC (rev 4104)
+++ mgmt/newdata/cumin/python/cumin/main.py 2010-07-12 21:45:23 UTC (rev 4105)
@@ -144,6 +144,8 @@
self.add_mode(self.main)
self.set_default_frame(self.main)
+ self.page_html_class = "Cumin"
+
def render_title(self, session):
return self.get_title(session)
@@ -348,14 +350,15 @@
self.add_column(col)
self.sort_col = cls._qmf_create_time.name
- running_col = self.adapter.table._columns_by_name["Running"]
- SqlComparisonFilter(self.adapter.query,
- running_col, "0", ">")
+ def init(self):
+ super(TopSubmissionTable, self).init()
- update_col = self.adapter.table._columns_by_name["_qmf_update_time"]
- SqlComparisonFilter(self.adapter.query,
- update_col, "now() - interval '60 seconds'",
">=")
+ table = self.cls.sql_table
+ SqlComparisonFilter(self.adapter.query, table.Running, "0",
">")
+ SqlComparisonFilter(self.adapter.query, table._qmf_update_time,
+ "now() - interval '60 seconds'",
">=")
+
class NameColumn(ObjectLinkColumn):
def render_cell_href(self, session, record):
# XXX fix this when submission has collector ref
Modified: mgmt/newdata/cumin/python/cumin/objectselector.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/objectselector.py 2010-07-12 18:05:42 UTC (rev 4104)
+++ mgmt/newdata/cumin/python/cumin/objectselector.py 2010-07-12 21:45:23 UTC (rev 4105)
@@ -67,6 +67,8 @@
for this, that, fobj in self.filter_specs:
obj = fobj.get(session)
+ session.log("%r %r %r" % (this, obj, that))
+
values[this.name] = getattr(obj, that.name)
return values
Modified: mgmt/newdata/cumin/python/cumin/usergrid/model.strings
===================================================================
--- mgmt/newdata/cumin/python/cumin/usergrid/model.strings 2010-07-12 18:05:42 UTC (rev
4104)
+++ mgmt/newdata/cumin/python/cumin/usergrid/model.strings 2010-07-12 21:45:23 UTC (rev
4105)
@@ -1,22 +1,9 @@
[LoadUserJobStats.sql]
select
- sum(c.running + c.idle + c.removed + c.held + c.completed) as total,
- sum(c.running) as running,
- sum(c.idle) as idle,
- sum(c.removed) as removed,
- sum(c.held) as held,
- sum(c.completed) as completed
-from submission as s
-left outer join submission_stats as c on c.id = s.stats_curr_id
+ sum(s."RunningJobs") as RunningJobs,
+ sum(s."IdleJobs") as IdleJobs,
+ sum(s."HeldJobs") as held
+from "com.redhat.grid"."Submitter" as s
[xxx]
where s.submitter like '{user_name}@%'
-
-[LoadUserSlotStats.sql]
-select
- count(*) as total,
- count(case s.activity when 'Busy' then 1 end) as busy,
- count(case s.activity when 'Idle' then 1 end) as idle,
- count(case s.activity when 'Suspended' then 1 end) as suspended
-from slot as s
-where s.remote_owner like '{user_name}@%'
Modified: mgmt/newdata/cumin/python/cumin/usergrid/widgets.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/usergrid/widgets.py 2010-07-12 18:05:42 UTC (rev
4104)
+++ mgmt/newdata/cumin/python/cumin/usergrid/widgets.py 2010-07-12 21:45:23 UTC (rev
4105)
@@ -28,6 +28,8 @@
self.add_mode(self.main)
self.set_default_frame(self.main)
+ self.page_html_class = "Cumin"
+
def render_title(self, session):
return self.get_title(session)
@@ -65,8 +67,8 @@
def __init__(self, app, name, user):
super(SubmissionsFrame, self).__init__(app, name)
- #self.view = UserSubmissionSet(app, "view", user)
- #self.add_mode(self.view)
+ self.view = UserSubmissionSelector(app, "view", user)
+ self.add_mode(self.view)
self.submission = SubmissionFrame(app, "submission")
self.add_mode(self.submission)
@@ -74,62 +76,44 @@
def render_title(self, session):
return "Submissions"
-# class UserSubmissionSet(SubmissionSet):
-# def __init__(self, app, name, user):
-# super(UserSubmissionSet, self).__init__(app, name)
+class UserSubmissionSelector(SubmissionSelector):
+ def __init__(self, app, name, user):
+ super(UserSubmissionSelector, self).__init__(app, name)
-# self.user = user
+ self.user = user
-# self.scheduler_col.visible = False
-# self.submitter_col.visible = False
+ self.user_name = UserSubmissionSelector.UserName(self, "username")
+ self.add_attribute(self.user_name)
-# task = app.grid.SubmissionAdd
-# link = TaskLink(app, "add", task, None)
-# self.links.add_child(link)
+ #self.add_filter(self.user_name, self.cls.Owner)
+
+ frame = "main.submissions.submission"
+ col = ObjectLinkColumn(app, "name", self.cls.Name, self.cls._id,
frame)
+ self.insert_column(1, col)
-# def get_submission_href(self, session, id):
-# submission = Identifiable(id)
-# return self.page.main.submissions.submission.get_href \
-# (session, submission)
+ class UserName(Attribute):
+ def get(self, session):
+ user = self.widget.user.get(session)
+ return user.name
-# def render_sql_where(self, session):
-# pass # XXX return "where m.name = %(name)s"
-
-# def get_sql_values(self, session):
-# user = self.page.user.get(session)
-# return {"name": user.name}
-
class UserJobStatSet(NewStatSet):
def __init__(self, app, name, user):
super(UserJobStatSet, self).__init__(app, name)
- stat = self.TotalJobs("total")
- self.stats.append(stat)
-
stat = self.RunningJobs("running")
self.stats.append(stat)
stat = self.IdleJobs("idle")
self.stats.append(stat)
- stat = self.RemovedJobs("removed")
- self.stats.append(stat)
-
stat = self.HeldJobs("held")
self.stats.append(stat)
- stat = self.CompletedJobs("completed")
- self.stats.append(stat)
-
self.load = LoadUserJobStats(app, user)
def get_values(self, session):
return self.load.execute(session).fetchone()
- class TotalJobs(CuminStatistic):
- def get_title(self, session):
- return "Total"
-
class RunningJobs(CuminStatistic):
def get_title(self, session):
return "Running"
@@ -138,51 +122,6 @@
def get_title(self, session):
return "Idle"
- class RemovedJobs(CuminStatistic):
- def get_title(self, session):
- return "Removed"
-
class HeldJobs(CuminStatistic):
def get_title(self, session):
return "Held"
-
- class CompletedJobs(CuminStatistic):
- def get_title(self, session):
- return "Completed"
-
-class UserSlotStatSet(NewStatSet):
- def __init__(self, app, name, user):
- super(UserSlotStatSet, self).__init__(app, name)
-
- stat = self.TotalSlots("total")
- self.stats.append(stat)
-
- stat = self.BusySlots("busy")
- self.stats.append(stat)
-
- stat = self.IdleSlots("idle")
- self.stats.append(stat)
-
- stat = self.SuspendedSlots("suspended")
- self.stats.append(stat)
-
- self.load = LoadUserSlotStats(app, user)
-
- def get_values(self, session):
- return self.load.execute(session).fetchone()
-
- class TotalSlots(CuminStatistic):
- def get_title(self, session):
- return "Total"
-
- class BusySlots(CuminStatistic):
- def get_title(self, session):
- return "Busy"
-
- class IdleSlots(CuminStatistic):
- def get_title(self, session):
- return "Idle"
-
- class SuspendedSlots(CuminStatistic):
- def get_title(self, session):
- return "Suspended"
Modified: mgmt/newdata/wooly/python/wooly/table.py
===================================================================
--- mgmt/newdata/wooly/python/wooly/table.py 2010-07-12 18:05:42 UTC (rev 4104)
+++ mgmt/newdata/wooly/python/wooly/table.py 2010-07-12 21:45:23 UTC (rev 4105)
@@ -31,6 +31,11 @@
self.columns.append(column)
+ def insert_column(self, index, column):
+ self.add_child(column)
+
+ self.columns.insert(index, column)
+
def get_data(self, session):
return ()