Author: eallen Date: 2011-03-08 21:40:10 +0000 (Tue, 08 Mar 2011) New Revision: 4584
Modified: trunk/cumin/python/cumin/grid/pool.py trunk/cumin/python/cumin/grid/pool.strings Log: For BZ 673189: Display an error message when the collector is missing.
Modified: trunk/cumin/python/cumin/grid/pool.py =================================================================== --- trunk/cumin/python/cumin/grid/pool.py 2011-03-08 21:36:16 UTC (rev 4583) +++ trunk/cumin/python/cumin/grid/pool.py 2011-03-08 21:40:10 UTC (rev 4584) @@ -1,25 +1,50 @@ import logging
+from wooly import Widget +from wooly.template import WidgetTemplate +from wooly.util import StringCatalog, Writer + from cumin.widgets import Session, StateSwitch -from wooly.util import StringCatalog -from cumin.objectframe import ObjectFrame +from cumin.objectframe import ObjectFrame, ObjectView +from cumin.parameters import CollectorGridAttribute, RosemaryObjectParameter +from cumin.stat import StatFlashChart, StatSet, FlashFullPage +from cumin.grid.dashboard import PoolDashboard + from submission import SubmissionFrame, PoolSubmissionJoinSelector from slot import SlotFrame, SlotSelector, SlotMap, SlotMapPage from scheduler import SchedulerFrame, SchedulerSelector from negotiator import NegotiatorFrame, NegotiatorSelector,\ - NegotiatorEditDynamicQuota + NegotiatorEditDynamicQuota, NegotiatorAttribute from limit import LimitFrame, LimitSelector -from quota import QuotaSelector -from wooly import Attribute, Widget -from cumin.parameters import CollectorGridAttribute, RosemaryObjectParameter +from cumin.grid.quota import QuotaSelector from collector import CollectorGeneralStatSet -from cumin.stat import StatFlashChart, StatSet, FlashFullPage -from cumin.grid.dashboard import PoolDashboard
strings = StringCatalog(__file__) log = logging.getLogger("cumin.pool")
+class PoolView(ObjectView): + def __init__(self, app, name, object): + super(PoolView, self).__init__(app, name, object) + + self.error_tmpl = WidgetTemplate(self, "error_html") + + def do_render(self, session): + id = self.frame.id.get(session) + if not id: + writer = Writer() + self.error_tmpl.render(writer, session) + return writer.to_string() + + return super(PoolView, self).do_render(session) + + def render_title(self, session): + obj = self.object.get(session) + if not obj: + return "Missing Pool" + + return obj.get_title() + class PoolFrame(ObjectFrame): def __init__(self, app, name): cls = app.model.com_redhat_grid.Collector @@ -28,6 +53,9 @@
self.icon_href = "resource?name=pool-36.png"
+ self.view = PoolView(app, "view", self.object) + self.replace_child(self.view) + self.mode.default = self.view
self.submission = SubmissionFrame(app, "submission") @@ -63,7 +91,7 @@ negotiators = NegotiatorSelector(app, "negotiators", self.object) self.view.add_tab(negotiators)
- self.negotiator_attribute = self.NegotiatorAttribute(app, "neg", self.object) + self.negotiator_attribute = NegotiatorAttribute(app, "neg", self.object) self.add_attribute(self.negotiator_attribute)
self.edit_dynamic_quota = NegotiatorEditDynamicQuota(app, self) @@ -78,6 +106,13 @@ def render_title(self, session): return "Grid"
+ def get_title(self, session): + obj = self.object.get(session) + if not obj: + return None + + return super(PoolFrame, self).get_title(session) + def do_process(self, session): id = self.id.get(session) if not id: @@ -96,31 +131,6 @@
super(PoolFrame, self).do_process(session)
- class NegotiatorAttribute(Attribute): - def __init__(self, app, name, collector): - super(PoolFrame.NegotiatorAttribute, self).__init__(app, name) - - self.collector = collector - - def get(self, session): - negotiator = super(PoolFrame.NegotiatorAttribute, self).get(session) - if not negotiator: - cls = self.app.model.com_redhat_grid.Negotiator - - pool = self.collector.get(session) - if pool: - negotiators = cls.get_selection(session.cursor, Pool=pool.Pool) - # use the most recently updated one if there are multiple - if len(negotiators) > 0: - recent_negotiator = negotiators[0] - for neg in negotiators: - if neg._qmf_update_time > \ - recent_negotiator._qmf_update_time: - recent_negotiator = neg - self.set(session, recent_negotiator) - negotiator = recent_negotiator - return negotiator - class PoolOverview(Widget): def __init__(self, app, name, collector): super(PoolOverview, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/grid/pool.strings =================================================================== --- trunk/cumin/python/cumin/grid/pool.strings 2011-03-08 21:36:16 UTC (rev 4583) +++ trunk/cumin/python/cumin/grid/pool.strings 2011-03-08 21:40:10 UTC (rev 4584) @@ -1,3 +1,22 @@ +[PoolView.error_html] +<div id="{id}" class="{class}"> + {heading} + <div class="TaskInvocationSet"> + <ul> + <li> + <b>Collector not found.</b> + Please ensure the grid is setup correctly and that cumin-data is running. + If cumin was just started, it may take a few minutes for the collector to become available. + </li> + </ul> + </div> +</div> +<script type="text/javascript"> + setTimeout(function () { + window.location.reload( true ); + }, 9000); +</script> + [PoolOverview.css] div#PoolOverview div.col1, div#PoolOverview div.col2 { float: left;
cumin-developers@lists.fedorahosted.org