[rhmessaging-commits] rhmessaging commits: r2702 - mgmt/trunk/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Wed Oct 29 16:30:27 EDT 2008
Author: eallen
Date: 2008-10-29 16:30:27 -0400 (Wed, 29 Oct 2008)
New Revision: 2702
Modified:
mgmt/trunk/cumin/python/cumin/model.py
Log:
Added methods to update slot and job grids using ajax.
Checking in Irina's changes for syscon, auth, fedid for connections.
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-10-29 20:29:37 UTC (rev 2701)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-10-29 20:30:27 UTC (rev 2702)
@@ -59,6 +59,7 @@
# Systems
CuminSystem(self)
+ CuminSlot(self)
def check(self):
self.data.check()
@@ -523,6 +524,31 @@
prop.title = "Last Updated"
prop.summary = True
+class CuminSlot(RemoteClass):
+ def __init__(self, model):
+ super(CuminSlot, self).__init__(model, "slot", Slot, SlotStats)
+
+ prop = CuminProperty(self, "Name")
+ prop.title = "Name"
+
+ prop = CuminProperty(self, "Machine")
+ prop.title = "Machine"
+
+ prop = CuminProperty(self, "JobId")
+ prop.title = "Current Job Id"
+
+ stat = CuminStat(self, "Activity")
+ stat.title = "Activity"
+ stat.category = "general"
+
+ stat = CuminStat(self, "CondorLoadAvg")
+ stat.title = "Condor Load Avg"
+ stat.category = "general"
+
+ stat = CuminStat(self, "LoadAvg")
+ stat.title = "Load Avg"
+ stat.category = "general"
+
class CuminSystem(RemoteClass):
def __init__(self, model):
super(CuminSystem, self).__init__(model, "system", System, SystemStats)
@@ -546,6 +572,9 @@
prop = CuminProperty(self, "machine")
prop.title = "Architecture"
+ action = self.VisSlots(self, "slots")
+ action.navigable = False
+
#action = CuminAction(self, "ping")
#action.title = "Send Ping"
#action.summary = True
@@ -562,6 +591,44 @@
def get_object_name(self, object):
return object.nodeName
+ class VisSlots(CuminAction):
+ load_colors = {"Idle": "clear",
+ "Busy": "green",
+ "Suspended": "red",
+ "Vacating": "red",
+ "Killing": "blue",
+ "Benchmarking": "yellow" }
+ def do_invoke(self, system, *args):
+ slots = self.get_slots(system)[0]
+ writer = Writer()
+ writer.write("<slots>")
+ for slot in slots:
+ writer.write("<slot id='%i' name='%s' machine='%s' job='%s' color='%s'/>" % \
+ (slot.sourceObjectId,
+ slot.Name,
+ slot.Machine,
+ slot.JobId,
+ self.get_color(slot)))
+ writer.write("</slots>")
+ return writer.to_string()
+
+ def get_slots(self, system):
+ elems = list()
+ elems.append("machine = '%s'" % system.nodeName)
+ elems.append("rec_time > now() - interval '90 minutes'")
+ elems.append("deletion_time is null")
+ sql = " and ".join(elems)
+ return (Slot.select(sql), )
+
+ def get_color(self, slot):
+ activity = slot.statsCurr.Activity
+ if activity in self.load_colors:
+ return self.load_colors[activity]
+ return "black"
+
+ def get_colors(self):
+ return self.load_colors
+
class SystemIdProperty(CuminProperty):
def value(self, session, object):
val = super(CuminSystem.SystemIdProperty, self).value(session, object)
@@ -1159,6 +1226,15 @@
prop = CuminProperty(self, "address")
prop.title = "Address"
+ prop = CuminProperty(self, "SystemConnection")
+ prop.title = "System Connection?"
+
+ prop = CuminProperty(self, "authIdentity")
+ prop.title = "Auth Identity?"
+
+ prop = CuminProperty(self, "federationLink")
+ prop.title = "Federation Link"
+
stat = CuminStat(self, "closing")
stat.title = "Closing Down"
stat.category = "general"
@@ -1716,6 +1792,9 @@
stat = CuminStat(self, "Jobs")
stat.title = "Total Jobs"
+ action = self.VisJobs(self, "jobs")
+ action.navigable = False
+
def init(self):
self.frame = self.model.frame.pool
@@ -1730,6 +1809,48 @@
return title
+ class VisJobs(CuminAction):
+ def do_invoke(self, pool, *args):
+ pool = self.model.get_main_pool()
+ jobs = self.get_jobs(pool)[0]
+ writer = Writer()
+ writer.write("<jobs>")
+ for job in jobs:
+ status = self.get_status(job)
+ writer.write("<job id='%i' name='%s' submitter='%s' status='%s' color='%s'/>" % \
+ (job.sourceObjectId,
+ job.CustomId,
+ job.submitter.Name,
+ JobStatusInfo.get_status_string(status),
+ self.get_color(job)))
+ writer.write("</jobs>")
+ return writer.to_string()
+
+ def get_jobs(self, pool):
+ elems = list()
+ elems.append("job.rec_time > now() - interval '90 minutes'")
+ #elems.append("job.deletion_time is null and job_status != %i" % JobStatusInfo.get_status_int("Removed"))
+ elems.append("s.pool = '%s'" % pool.id)
+ sql = " and ".join(elems)
+ jn = "inner join scheduler as s on s.id = scheduler_id"
+ return (Job.select(sql, join=jn).orderBy("custom_id"), )
+
+ def get_status(self, job):
+ status = job.JobStatus
+ if status != JobStatusInfo.get_status_int("Completed") and job.deletionTime:
+ status = JobStatusInfo.get_status_int("Removed")
+ return status
+
+ def get_color(self, job):
+ status = self.get_status(job)
+ color = JobStatusInfo.get_status_color(status)
+ if "Idle" == JobStatusInfo.get_status_string(status):
+ color = "clear"
+ return color
+
+ def get_colors(self):
+ return JobStatusInfo.get_zipped_colors()
+
class CuminLimit(CuminClass):
def __init__(self, model):
super(CuminLimit, self).__init__ \
@@ -2507,7 +2628,7 @@
self.__args = Parameter(app, "xargs")
self.add_parameter(self.__args)
-
+
def get_content_type(self, session):
return Page.xml_content_type
More information about the rhmessaging-commits
mailing list