Author: eallen
Date: 2008-12-03 11:18:20 -0500 (Wed, 03 Dec 2008)
New Revision: 2914
Modified:
mgmt/trunk/cumin/python/cumin/pool.py
mgmt/trunk/cumin/python/cumin/slot.py
mgmt/trunk/cumin/python/cumin/slot.strings
Log:
Temp replacement of Slot status stub. This one is static.
Modified: mgmt/trunk/cumin/python/cumin/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/pool.py 2008-12-03 15:32:36 UTC (rev 2913)
+++ mgmt/trunk/cumin/python/cumin/pool.py 2008-12-03 16:18:20 UTC (rev 2914)
@@ -17,7 +17,7 @@
from collector import CollectorSet, CollectorFrame, CollectorStart, CollectorStop
from negotiator import NegotiatorSet, NegotiatorFrame, NegStart, NegStop
from limits import LimitsSet, LimitsFrame
-from slot import SlotSet, MachineSet
+from slot import SlotSet, MachineSet, SlotStatSet
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.pool")
@@ -455,8 +455,29 @@
return "Percentage"
class PoolStatus(CuminStatus):
- def render_status(self, session, pool):
- return "Active"
+ def __init__(self, app, name):
+ super(PoolStatus, self).__init__(app, name)
+
+ self.slotset = self.StatusPoolSlotSet(app, "status")
def render_title(self, session, pool):
return "Pool Status"
+
+ def render_status(self, session, pool):
+ cursor = self.slotset.get_items(session, pool)
+ slot_list = self.slotset.cursor_to_rows(cursor)
+ # should be only one record
+ data = slot_list[0]
+ idle = data["idle"]
+ total = data["total"]
+ return "%i of %i slots active" % (total - idle, total)
+
+ class StatusPoolSlotSet(SlotStatSet):
+ def render_sql_where(self, session, pool):
+ elems = list()
+ elems.append("s.pool = %(pool)s")
+ return "where %s" % " and ".join(elems)
+
+ def get_sql_values(self, session, pool):
+ values = {"pool": pool.id}
+ return values
Modified: mgmt/trunk/cumin/python/cumin/slot.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/slot.py 2008-12-03 15:32:36 UTC (rev 2913)
+++ mgmt/trunk/cumin/python/cumin/slot.py 2008-12-03 16:18:20 UTC (rev 2914)
@@ -25,3 +25,5 @@
class MachineSet(CuminTable):
pass
+class SlotStatSet(CuminTable):
+ pass
\ No newline at end of file
Modified: mgmt/trunk/cumin/python/cumin/slot.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/slot.strings 2008-12-03 15:32:36 UTC (rev 2913)
+++ mgmt/trunk/cumin/python/cumin/slot.strings 2008-12-03 16:18:20 UTC (rev 2914)
@@ -20,6 +20,22 @@
from (select distinct name, machine, system, pool, qmf_delete_time from slot as s
{sql_where}) as s
+[SlotStatSet.sql]
+select
+ sum(case activity when 'Idle' then 1 else 0 end) / coll_count as idle,
+ sum(1) / coll_count as total
+from (select
+ machine, s.pool, c.activity, count(coll.id) as coll_count
+ from slot as s
+ left outer join slot_stats as c on c.id = s.stats_curr_id
+ left outer join collector as coll on coll.pool = s.pool
+ group by machine, s.pool, c.activity, s.stats_curr_id) as s
+{sql_where}
+group by coll_count
+
+[SlotStatSet.count_sql]
+1
+
[MachineSet.sql]
select
machine as id,