[rhmessaging-commits] rhmessaging commits: r4273 - mgmt/newdata/cumin/python/cumin/grid.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Fri Sep 10 11:27:03 EDT 2010
Author: eallen
Date: 2010-09-10 11:27:03 -0400 (Fri, 10 Sep 2010)
New Revision: 4273
Modified:
mgmt/newdata/cumin/python/cumin/grid/job.py
mgmt/newdata/cumin/python/cumin/grid/job.strings
Log:
Fix for BZ 268701. Provide feedback when GetJobAds qmf call returns an error.
Also included is the code to handle a list returned from GetJobSummaries instead of a dict
Modified: mgmt/newdata/cumin/python/cumin/grid/job.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/job.py 2010-09-10 00:21:05 UTC (rev 4272)
+++ mgmt/newdata/cumin/python/cumin/grid/job.py 2010-09-10 15:27:03 UTC (rev 4273)
@@ -108,18 +108,48 @@
submission = values["obj"]
results = self.app.model.get_submission_job_summaries(submission)
#TODO: handle error status and create an invok message
- rows = self.process_results(results.data)
+
+ if isinstance(results.data, dict):
+ rows = super(JobSummariesAdapter, self).process_results(results.data)
+ elif isinstance(results.data, list):
+ rows = self.process_results(results.data)
+ else:
+ rows = []
page = rows[first_index:last_index]
return page
+ def process_results(self, results):
+ # the results for this call is a list
+ records = list()
+
+ if results:
+ for rec in results:
+ row = self.process_record(None, rec)
+ records.append(row)
+
+ return records
+
def process_record(self, key, record):
field_data = list()
for column in self.columns:
try:
val = record[column.name]
except KeyError:
+ val = None
if column.name == "JobId":
- val = key
+ # GlobalJobId should look like localhost6.localdomain6#94.1#1284091602
+ try:
+ gjid = record["GlobalJobId"]
+ parts = gjid.split("#")
+ if len(parts) == 3:
+ val = parts[1]
+ except Exception, e:
+ pass
+ if not val:
+ try:
+ val = "%s.%s" % (str(record["ClusterId"]), str(record["ProcId"]))
+ except KeyError:
+ val = "0"
else:
val = 0
field_data.append(val)
@@ -304,11 +334,14 @@
self.items = Attribute(app, "cached_items")
self.add_attribute(self.items)
+ self.qmf_error = Attribute(app, "qmf_error")
+ self.add_attribute(self.qmf_error)
+
def do_get_items(self, session):
ad_list = self.items.get(session)
- error = False
+ error = self.qmf_error.get(session)
- if not ad_list:
+ if not ad_list and not error:
ad_list = list()
id = self.frame.id.get(session)
job_server = self.frame.get_job_server(session, id)
@@ -317,6 +350,7 @@
action = QmfCall(self.app, {'JobAd': {}})
results = action.execute(job_server, "GetJobAd", job_id)
error = results.error
+ self.qmf_error.set(session, error)
ads = results.data['JobAd']
cls = self.app.model.job_meta_data
ad_list = [self.gen_item(x, ads[x], cls, dtype=self.get_type(ads[x])) \
@@ -418,8 +452,15 @@
def render_groups(self, session):
writer = Writer()
- for group in self.app.model.get_ad_groups():
- self.group_tmpl.render(writer, session, group)
+
+ # check for qmf error
+ _, error = self.parent.do_get_items(session)
+ if error:
+ self.error_tmpl.render(writer, session, error.message)
+ else:
+ for group in self.app.model.get_ad_groups():
+ self.group_tmpl.render(writer, session, group)
+
return writer.to_string()
def render_group_name(self, session, group):
@@ -429,11 +470,8 @@
items, error = self.parent.get_group_items(session, group)
writer = Writer()
- if error:
- self.error_tmpl.render(writer, session, error.message)
- else:
- for item in items:
- self.parent.item_renderer.render(writer, session, item)
+ for item in items:
+ self.parent.item_renderer.render(writer, session, item)
return writer.to_string()
@@ -452,16 +490,18 @@
self.wait = Wait(app, "wait")
self.add_child(self.wait)
+ self.edit_button = JobAdsEditButton(app, "edit_button")
+ self.add_child(self.edit_button)
+
self.defer_enabled = True
+ def render_edit_button(self, session):
+ _, error = self.do_get_items(session)
+ return not error and self.edit_button.render(session) or ""
+
def render_title(self, session):
return "Attributes"
- def render_edit_ads_url(self, session):
- branch = session.branch()
- self.frame.show_ads_edit(branch)
- return branch.marshal()
-
def get_group_items(self, session, group):
group_items = list()
@@ -477,6 +517,12 @@
return group_items, error
+class JobAdsEditButton(Widget):
+ def render_edit_ads_url(self, session):
+ branch = session.branch()
+ self.parent.frame.show_ads_edit(branch)
+ return branch.marshal()
+
class JobAdsEditor(JobAdsViewer, CuminForm):
def __init__(self, app, name):
super(JobAdsEditor, self).__init__(app, name)
Modified: mgmt/newdata/cumin/python/cumin/grid/job.strings
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/job.strings 2010-09-10 00:21:05 UTC (rev 4272)
+++ mgmt/newdata/cumin/python/cumin/grid/job.strings 2010-09-10 15:27:03 UTC (rev 4273)
@@ -1,8 +1,6 @@
[JobAdsViewer.html]
<div id="{id}">
-<ul class="actions">
- <li><a class="nav" href="{edit_ads_url}">Edit Attributes</a></li>
-</ul>
+{edit_button}
<table class="CuminDetails">
<tbody>
<tr>
@@ -12,9 +10,7 @@
</tr>
</tbody>
</table>
-<ul class="actions">
- <li><a class="nav" href="{edit_ads_url}">Edit Attributes</a></li>
-</ul>
+{edit_button}
</div>
[JobAdsViewer.deferred_html]
@@ -22,6 +18,11 @@
{wait}
</div>
+[JobAdsEditButton.html]
+<ul class="actions">
+ <li><a class="nav" href="{edit_ads_url}">Edit Attributes</a></li>
+</ul>
+
[JobAdsGroups.css]
div.ads_error {
margin: 1em;
@@ -54,7 +55,11 @@
</table>
[JobAdsGroups.error_html]
-<div class="ads_error">{error_msg}</div>
+<div class="TaskInvocationSet">
+ <ul>
+ <li>{error_msg}</li>
+ </ul>
+</div>
[JobAdsViewer.property_html]
<tr>
More information about the rhmessaging-commits
mailing list