r5437 - trunk/wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-07-31 02:29:42 +0000 (Tue, 31 Jul 2012)
New Revision: 5437
Modified:
trunk/wooly/python/wooly/util.py
Log:
Add a log message on failure of os.urandom
Modified: trunk/wooly/python/wooly/util.py
===================================================================
--- trunk/wooly/python/wooly/util.py 2012-07-30 17:06:24 UTC (rev 5436)
+++ trunk/wooly/python/wooly/util.py 2012-07-31 02:29:42 UTC (rev 5437)
@@ -39,6 +39,7 @@
bits = [struct.unpack("=L", os.urandom(4))[0] for x in range(4)]
except NotImplementedError:
bits = [random.getrandbits(32) for x in range(4)]
+ log.debug("Wooly: os.urandom raised NotImplementedError")
return "%08x-%08x-%08x-%08x" % (bits[0], bits[1], bits[2], bits[3])
11 years, 8 months
r5436 - trunk/wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-07-30 17:06:24 +0000 (Mon, 30 Jul 2012)
New Revision: 5436
Modified:
trunk/wooly/python/wooly/util.py
Log:
Use standard encoding for single quote.
Modified: trunk/wooly/python/wooly/util.py
===================================================================
--- trunk/wooly/python/wooly/util.py 2012-07-25 17:48:53 UTC (rev 5435)
+++ trunk/wooly/python/wooly/util.py 2012-07-30 17:06:24 UTC (rev 5436)
@@ -20,7 +20,7 @@
from parsley.collectionsex import *
quote_entities = {'"': """,
- "'": "'"}
+ "'": "'"}
def xml_escape(string, entities=None):
if type(string) in (str, unicode):
11 years, 8 months
r5435 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-07-25 17:48:53 +0000 (Wed, 25 Jul 2012)
New Revision: 5435
Modified:
trunk/cumin/python/cumin/formats.py
trunk/cumin/python/cumin/widgets.py
Log:
For BZ:800611 we are now producing valid XHTML when displaying a long queue name on the add binding form. This is being done by omitting the span tag that was causing the problem when it was added to the value attribute.
Modified: trunk/cumin/python/cumin/formats.py
===================================================================
--- trunk/cumin/python/cumin/formats.py 2012-07-16 13:50:47 UTC (rev 5434)
+++ trunk/cumin/python/cumin/formats.py 2012-07-25 17:48:53 UTC (rev 5435)
@@ -111,13 +111,18 @@
def fmt_none_brief():
return "<span class=\"none\">–</span>"
-def fmt_shorten(string, pre=16, post=4):
+def fmt_shorten(string, pre=16, post=4, spanify=True):
if len(string) > pre + post:
if post:
- string = "<span title=\"%s\">%s</span>" % (string, string[:pre] + "…" + string[-post:])
+ if spanify:
+ string = "<span title=\"%s\">%s</span>" % (string, string[:pre] + "…" + string[-post:])
+ else:
+ string = "%s" % string[:pre] + "…" + string[-post:]
else:
- string = "<span title=\"%s\">%s</span>" % (string, string[:pre] + "…")
-
+ if spanify:
+ string = "<span title=\"%s\">%s</span>" % (string, string[:pre] + "…")
+ else:
+ string = "%s" % string[:pre] + "…"
return string
def fmt_link(href, content, class_="", id="", link_title="", bm="", click="", attribs={}):
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-07-16 13:50:47 UTC (rev 5434)
+++ trunk/cumin/python/cumin/widgets.py 2012-07-25 17:48:53 UTC (rev 5435)
@@ -1533,7 +1533,7 @@
if self.disabled:
field = self.form.object.get(session)
return fmt_shorten(field.get_formatted_value("name", escape=True),
- pre=36, post=4)
+ pre=36, post=4, spanify=False)
else:
input_value = self.param.get(session)
return input_value and xml_escape(input_value) or ""
11 years, 8 months
r5434 - trunk/rosemary/python/rosemary
by croberts@fedoraproject.org
Author: croberts
Date: 2012-07-16 13:50:47 +0000 (Mon, 16 Jul 2012)
New Revision: 5434
Modified:
trunk/rosemary/python/rosemary/model.py
Log:
New method for fetching selection samples.
Modified: trunk/rosemary/python/rosemary/model.py
===================================================================
--- trunk/rosemary/python/rosemary/model.py 2012-07-13 20:15:31 UTC (rev 5433)
+++ trunk/rosemary/python/rosemary/model.py 2012-07-16 13:50:47 UTC (rev 5434)
@@ -512,7 +512,29 @@
selection.append(obj)
return selection
+
+ def get_selection_samples(self, cursor, **criteria):
+ selection = list()
+ sql = SqlSelect(self.sql_samples_table)
+ for name in criteria:
+ # XXX need to translate ref=obj args here
+
+ column = self.sql_table._columns_by_name[name]
+ sql.add_filter(SqlValueFilter(column))
+
+ sql.execute(cursor, criteria)
+
+ for record in cursor.fetchall():
+ obj = self._get_rosemary_object(None)
+
+ self._set_object_attributes(obj, self.sql_samples_table._columns, record)
+
+ selection.append(obj)
+
+ return selection
+
+
def get_selection_like(self, cursor, **criteria):
selection = list()
sql = SqlSelect(self.sql_table)
11 years, 8 months
r5433 - trunk/cumin/python/cumin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-07-13 20:15:31 +0000 (Fri, 13 Jul 2012)
New Revision: 5433
Modified:
trunk/cumin/python/cumin/main.py
Log:
Print exceptions during cumin module import so that syntax errors can be seen.
(this has to do with the use of __import__())
Modified: trunk/cumin/python/cumin/main.py
===================================================================
--- trunk/cumin/python/cumin/main.py 2012-07-13 14:22:14 UTC (rev 5432)
+++ trunk/cumin/python/cumin/main.py 2012-07-13 20:15:31 UTC (rev 5433)
@@ -162,8 +162,11 @@
try:
m = __import__(name, globals())
m.Module(self, name)
- except:
+ except ImportError:
pass
+ except Exception, e:
+ import traceback
+ traceback.print_exc()
def db_init(self, schema_version_check=True):
self.model.init()
11 years, 8 months
r5432 - trunk/cumin/python/cumin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-07-13 14:22:14 +0000 (Fri, 13 Jul 2012)
New Revision: 5432
Modified:
trunk/cumin/python/cumin/authenticator.py
Log:
Tweak ldap.timeout setting for compatibility with RHEL 5
BZ839576
Modified: trunk/cumin/python/cumin/authenticator.py
===================================================================
--- trunk/cumin/python/cumin/authenticator.py 2012-07-13 13:52:29 UTC (rev 5431)
+++ trunk/cumin/python/cumin/authenticator.py 2012-07-13 14:22:14 UTC (rev 5432)
@@ -96,9 +96,6 @@
# Always demand a certificate if the cacert is set
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND)
- if self.ldap_timeout is not None:
- ldap.set_option(ldap.OPT_TIMEOUT, self.ldap_timeout)
-
def _start_tls(self, conn):
if self.start_tls and not conn.start_tls_called:
conn.start_tls_called = True
@@ -114,6 +111,11 @@
try:
self._set_ldap_options()
conn = ldap.initialize(self.url.urlscheme + "://" +self.url.hostport)
+ if self.ldap_timeout is not None:
+ # ldap.set_option(OPT_TIMEOUT, val) doesn't seem to work on
+ # older versions of python_ldap. Instead, you have to set the
+ # value explicitly on the connection object after creation.
+ conn.timeout = self.ldap_timeout
conn.start_tls_called = False
except Exception,e:
log.error("Authenticator: cannot contact ldap server %s",e)
@@ -147,7 +149,7 @@
except Exception, e:
msg = str(e)
if not msg:
- msg = e.__repr__()
+ msg = repr(e)
log.error("Authenticator: find_user, "\
"query returned exception %s" % msg)
return conn, res
11 years, 8 months
r5431 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2012-07-13 13:52:29 +0000 (Fri, 13 Jul 2012)
New Revision: 5431
Modified:
trunk/cumin/python/cumin/grid/dashboard.py
Log:
Setting the default duration to 1-day for all plumage-based charts.
Modified: trunk/cumin/python/cumin/grid/dashboard.py
===================================================================
--- trunk/cumin/python/cumin/grid/dashboard.py 2012-07-12 17:02:24 UTC (rev 5430)
+++ trunk/cumin/python/cumin/grid/dashboard.py 2012-07-13 13:52:29 UTC (rev 5431)
@@ -52,19 +52,19 @@
chart = self.PoolEfficiencyChart(app, "eff", app.model.com_redhat_grid_plumage.OSUtil)
chart.stats = ["efficiency"]
chart.max_samples = 250
- chart.duration.param.default = "3600"
+ chart.duration.param.default = "86400"
charts.add_child(chart)
chart = self.PoolMemoryChart(app, "fmem", app.model.com_redhat_grid_plumage.OSUtil)
chart.stats = ["usedmem", "freemem"]
chart.max_samples = 250
- chart.duration.param.default = "3600"
+ chart.duration.param.default = "86400"
charts.add_child(chart)
chart = self.PoolCpuChart(app, "fcpu", app.model.com_redhat_grid_plumage.OSUtil)
chart.stats = [ "usedcpu", "freecpu"]
chart.max_samples = 250
- chart.duration.param.default = "3600"
+ chart.duration.param.default = "86400"
charts.add_child(chart)
chart = self.UserUsageChart(app, "useruse", app.model.com_redhat_grid_plumage.Accountant)
11 years, 8 months
r5430 - in trunk/cumin/python/cumin: . grid
by croberts@fedoraproject.org
Author: croberts
Date: 2012-07-12 17:02:24 +0000 (Thu, 12 Jul 2012)
New Revision: 5430
Modified:
trunk/cumin/python/cumin/grid/dashboard.py
trunk/cumin/python/cumin/model.py
trunk/cumin/python/cumin/stat.py
trunk/cumin/python/cumin/stat.strings
Log:
Adding new plumage-based chart for pool usage by user (accounting group). (BZ:703859)
Modified: trunk/cumin/python/cumin/grid/dashboard.py
===================================================================
--- trunk/cumin/python/cumin/grid/dashboard.py 2012-07-12 15:06:02 UTC (rev 5429)
+++ trunk/cumin/python/cumin/grid/dashboard.py 2012-07-12 17:02:24 UTC (rev 5430)
@@ -6,6 +6,7 @@
from wooly.table import TableHeader
from wooly.widgets import RadioModeSet, WidgetSet
from wooly.template import WidgetTemplate
+from wooly.forms import StringInput
from parsley.stringex import rpartition
from rosemary.sqlquery import SqlQueryOptions
@@ -66,6 +67,15 @@
chart.duration.param.default = "3600"
charts.add_child(chart)
+ chart = self.UserUsageChart(app, "useruse", app.model.com_redhat_grid_plumage.Accountant)
+ chart.stats = ["resused"]
+ chart.max_samples = 250
+ filter = ReportingChart.FilterInput(app, "namefilter", app.model.com_redhat_grid_plumage.Accountant, app.model.com_redhat_grid_plumage.Accountant.user.name, "userc", "Filter user")
+ chart.filters.append(filter)
+ chart.add_child(filter)
+ chart.duration.param.default= "86400"
+ charts.add_child(chart)
+
def render_title(self, session):
return "History"
@@ -81,6 +91,14 @@
def render_title(self, session):
return "Pool efficiency"
+ class UserUsageChart(ReportingChart):
+ def render_title(self, session):
+ return "Pool usage by user"
+
+ class AccountingChart(ReportingChart):
+ def render_title(self, session):
+ return "Usage by parent accounting group"
+
class DashboardSummary(Widget):
def __init__(self, app, name, collector):
super(DashboardSummary, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2012-07-12 15:06:02 UTC (rev 5429)
+++ trunk/cumin/python/cumin/model.py 2012-07-12 17:02:24 UTC (rev 5430)
@@ -318,12 +318,16 @@
return retval
class SamplesSqlAdapter(SqlAdapter):
- def __init__(self, app, cls, sig, session):
+ def __init__(self, app, cls, sig, session, extra_filters=None):
super(SamplesSqlAdapter, self).__init__(app, cls.sql_samples_table)
filters = cls.get_sample_filters_by_signature(sig)
for f in filters:
self.query.add_filter(f)
+
+ if extra_filters is not None:
+ for ef in extra_filters:
+ self.query.add_filter(ef)
self.update_col = cls.get_timestamp_col()
Modified: trunk/cumin/python/cumin/stat.py
===================================================================
--- trunk/cumin/python/cumin/stat.py 2012-07-12 15:06:02 UTC (rev 5429)
+++ trunk/cumin/python/cumin/stat.py 2012-07-12 17:02:24 UTC (rev 5430)
@@ -18,6 +18,8 @@
from cumin.util import calc_rate, secs, nvl, xml_escape
from cumin.OpenFlashChart import Element, Chart
+from rosemary.sqlfilter import SqlFilter
+
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.stat")
@@ -176,7 +178,7 @@
if self.chart_type:
params.append("type=%s" % self.chart_type)
-
+
return params
def render_href(self, session):
@@ -211,6 +213,7 @@
self.duration.add_state("2592000", "1 month")
self.duration.add_state("31557600", "1 year")
self.max_samples = 0
+ self.filters = list()
def get_href_params(self, session):
params = list()
@@ -302,8 +305,47 @@
return 120
def render_id_nodots(self, session):
- return self.render_id(session).replace(".", "_")
+ return self.render_id(session).replace(".", "_")
+
+ def render_filters(self, session):
+ filtertext = ""
+ for f in self.filters:
+ filtertext += f.do_render(session)
+
+ return filtertext
+
+ class FilterInput(Widget):
+ def __init__(self, app, name, cls, attr, param, title):
+ super(ReportingChart.FilterInput, self).__init__(app, name)
+ self.user_list = list()
+ self.cls = cls
+ self.attr = attr
+ self.param = param
+ self.title = title
+
+ def render_onclick(self, session):
+ return """onclick="updateFilter(this.getPrevious().value, this, '%s')" """ % self.parent.path
+ def render_onchange(self, session):
+ return """onchange="updateFilter(this.value, this, '%s', '%s')" """ % (self.parent.path, self.param)
+
+ def render_name(self, session):
+ return self.name
+
+ def do_process(self, session):
+ rows = self.cls.get_selection_samples(session.cursor)
+ self.user_list = sorted(list(set((getattr(x, self.attr)) for x in rows)))
+
+ def render_user_list(self, session):
+ options = ""
+ for u in self.user_list:
+ options += """<option value="%s">%s</option>""" % (xml_escape(u), xml_escape(u))
+
+ return options
+
+ def render_title(self, session):
+ return self.title
+
class ImageCache(object):
def __init__(self):
self.__files = dict() # {name: {"time": time_created, "file": file object, "cookie": (cookie values)}}
@@ -476,10 +518,28 @@
stats = [getattr(rosemary_class, x) for x in self.stats.get(session)]
adapters = dict()
for stat in stats:
- adapters[stat] = SamplesSqlAdapter(self.app, rosemary_class, signature, session)
+ filters = list()
+ if self.user_selection.get(session) is not None and self.user_selection.get(session).lower() != "none" and self.user_selection.get(session) != "":
+ filters.append(self.UserFilter(rosemary_class, self.user_selection.get(session)))
+ if self.group_selection.get(session) is not None and self.group_selection.get(session).lower() != "none" and self.group_selection.get(session) != "":
+ filters.append(self.UserFilter(rosemary_class, self.group_selection.get(session)))
+ adapters[stat] = SamplesSqlAdapter(self.app, rosemary_class, signature, session, filters)
+
return (adapters, stats)
+ class UserFilter(SqlFilter):
+ def __init__(self, cls, value):
+
+ table = cls.sql_samples_table
+
+ fmt = "(%s like '%s')"
+ args = (table.user.identifier, value)
+
+ self.text = fmt % args
+
+ def emit(self):
+ return self.text
# builds an object that is similar to a RosemaryStatistic that can
# be used later in the chart rendering to give values to the chart items
class Pseudostat(object):
@@ -1242,6 +1302,14 @@
self.percent_property = Parameter(app, "tp")
self.add_parameter(self.percent_property)
+
+ self.user_selection = Parameter(app, "userc")
+ self.user_selection.default = None
+ self.add_parameter(self.user_selection)
+
+ self.group_selection = Parameter(app, "groupc")
+ self.group_selection.default = None
+ self.add_parameter(self.group_selection)
def get_content_type(self, session):
return "text/plain"
Modified: trunk/cumin/python/cumin/stat.strings
===================================================================
--- trunk/cumin/python/cumin/stat.strings 2012-07-12 15:06:02 UTC (rev 5429)
+++ trunk/cumin/python/cumin/stat.strings 2012-07-12 17:02:24 UTC (rev 5430)
@@ -132,6 +132,9 @@
top:49px;
}
+div.chartFilter {
+ margin-top:10px;
+}
[StatValueChart.css]
div.StatValueChart {
@@ -350,10 +353,79 @@
<div class="loading" style="display:none;"><span>Loading...</span></div>
</div>
</div>
+ <div class="chartFilter">
+ {filters}
+ </div>
</div>
-
</div>
+
+[ReportingChart.javascript]
+function updateFilter(filter, a, id, param, attempt) {
+ var li = a.parentNode;
+ var ul = li.parentNode;
+ var as = ul.getElementsByTagName('a');
+ var hash = wooly.session.hash();
+ hash[id] = filter;
+ wooly.session.setHash(hash);
+
+ var oImg = document.images[id];
+ if (oImg) {
+ var src = oImg.src;
+ var branch = wooly.session.branch(src);
+ branch.userc = filter;
+ src = branch.marshal();
+ src = cumin.refreshTime(src);
+ oImg.src = src;
+
+ $(oImg).onerror = $(oImg).onload = function () {this.className = ""};
+ oImg.className = "Loading";
+
+ var loading = $(id).getElement(".loading");
+ if (loading) {
+ loading.loading = true;
+ setTimeout("showLoading('"+id+"')", 1000);
+ setTimeout("hideLoading('"+id+"')", 1000 * 60);
+ }
+
+ wooly.cancelIntervalUpdate();
+ wooly.resumeIntervalUpdate();
+ cumin.expireIntervalUpdate();
+ return false;
+ } else {
+ var chart = cumin.getChart(id);
+ if ((chart == null) || (typeof $(chart).getParent().getElements('a')[chart_href] == "undefined")) {
+ if (typeof attempt == "undefined")
+ attempt = 1;
+ if (attempt < 10)
+ setTimeout(function () {updateFilter(filter, a, id, attempt+1);}, 100);
+ return false;
+ }
+ newurl = get_new_chart_url(id, $(chart).getParent().getElements('a')[chart_href].get('href'), param, filter);
+ $(chart).getParent().getElements('a')[chart_href].set('href', newurl);
+ drawSingleChart(chart, true);
+ }
+ return false;
+}
+
+function get_new_chart_url(id, url, param, value) {
+ var chart = cumin.getChart(id);
+ if (chart == null)
+ return false;
+
+ var branch = wooly.session.branch(url);
+ var now = new Date().getTime();
+ branch['elapsed'] = now; // force an entire update
+ branch[param] = value;
+ url = branch.marshal();
+
+ return url;
+}
+
+[FilterInput.html]
+<!-- <input id="{id}" type="text" name="{name}"></input><input type="button" value="Update filter" {onclick}/> -->
+{title}: <select {onchange}>{user_list}</select>
+
[GenericChart.css]
div.FullpageChart {
margin: 1.5em;
@@ -366,7 +438,6 @@
<img id="{id}" src="{img_href}" height="{height}" width="{width}" alt="stats" />
<div class="loading" style="display:none;"><span>Loading...</span></div>
</div>
- YOU ARE HERE!
</div>
[PieFlashChart.html]
11 years, 8 months
r5429 - in trunk: cumin/python/cumin cumin/python/cumin/grid wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-07-12 15:06:02 +0000 (Thu, 12 Jul 2012)
New Revision: 5429
Modified:
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/grid/submission.py
trunk/cumin/python/cumin/objectframe.py
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/server.py
Log:
Tweaks to role enforcement.
BZ837047
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2012-07-10 13:21:25 UTC (rev 5428)
+++ trunk/cumin/python/cumin/grid/job.py 2012-07-12 15:06:02 UTC (rev 5429)
@@ -25,20 +25,21 @@
log = logging.getLogger("cumin.job")
class JobFrame(ObjectFrame):
- def __init__(self, app, name, submission):
+ def __init__(self, app, name, submission, check_viewable=False):
cls = app.model.com_redhat_grid.Submission
super(JobFrame, self).__init__(app, name, cls)
self.view = JobView(app, "view", self.object)
self.replace_child(self.view)
+ self.do_check_viewable = check_viewable
# view or edit
- self.ads = JobAdModes(app, "ads")
+ self.ads = JobAdModes(app, "ads", check_viewable)
self.view.add_tab(self.ads)
- self.view.add_tab(JobOutput(app, "output"))
+ self.view.add_tab(JobOutput(app, "output", check_viewable))
self.job_id = Parameter(app, "job_id")
self.add_parameter(self.job_id)
@@ -98,18 +99,60 @@
return branch.marshal()
def not_viewable_redirect(self):
+ # The object held by this frame is actually a submission,
+ # so a redirect from a higher level should use this message
return (self.parent,
- "Logged in user does not own the specified job")
+ "Logged in user does not own the specified submission")
+ def do_process(self, session):
+ super(JobFrame, self).do_process(session)
+
+ # Make sure that the job belongs to the designated submission.
+ id = self.id.get(session)
+ submission, js, sched = self.get_trifecta(session, id)
+ summaries = self.app.model.get_submission_job_summaries(submission,
+ sched.Name)
+ okay = False
+ frame = None
+ message = ""
+ if summaries.data is None:
+ # Well, someone is requesting a particular job but we have no
+ # data yet so we don't know if it is legit or not. Redirect
+ # to the parent frame, but without a notice. Normally data should
+ # be present because the trail through Cumin goes to the submission
+ # job list first, with a link to a particular job.
+ frame = self.parent
+ else:
+ job_id = self.job_id.get(session)
+ for summary in summaries.data:
+ if str(summary["ClusterId"]) + "." + \
+ str(summary["ProcId"]) == job_id:
+ okay = True
+ break
+
+ if not okay:
+ frame = self.parent
+ message = "The specified job is not part "\
+ "of the specified submission"
+
+ # If the check failed and there is not yet a redirect
+ # value, set the redirect. Add the notice in either case.
+ if not self.get_redirect(session) and frame:
+ self.set_redirect(session, frame, message)
+ elif message:
+ session.add_notice(Notice(message))
+
class JobAdModes(ModeSet):
- def __init__(self, app, name):
+ def __init__(self, app, name, check_viewable):
super(JobAdModes, self).__init__(app, name)
self.viewer = JobAdsViewer(app, "viewer")
self.add_mode(self.viewer)
+ self.viewer.do_check_viewable = check_viewable
self.editor = JobAdsEditor(app, "editor")
self.add_mode(self.editor)
+ self.editor.do_check_viewable = check_viewable
def render_title(self, session):
return "Attributes"
@@ -444,7 +487,7 @@
if not self.errors.get(session) and \
self.app.authorizator.is_enforcing():
# Check here to make sure the logged in user owns
- # the job or is an admin
+ # the submission or is an admin
login = session.client_session.attributes["login_session"]
if "admin" not in login.group:
user = login.user.name
@@ -456,8 +499,7 @@
f = FormError("The logged in user does not "\
"own this submission.")
self.errors.add(session, f)
-
-
+
class JobAdsSet(PropertySet):
types = {0: "expression",
1: "integer",
@@ -473,19 +515,38 @@
self.qmf_error = Attribute(app, "qmf_error")
self.add_attribute(self.qmf_error)
+ self.do_check_viewable = False
+
+ def get_job_ad(self, session):
+ id = self.frame.id.get(session)
+ submission, job_server, sched = self.frame.get_trifecta(session, id)
+ job_id = self.frame.job_id.get(session)
+ results = self.app.remote.get_job_ad(job_server, job_id,
+ sched.Name, submission,
+ default={'JobAd': {}})
+ return results
+
+ def check_job_owner(self, session, ad):
+ error = None
+ if not session.client_session.check_owner(ad['Owner']):
+ class InventError:
+ def __init__(self, msg):
+ self.args = [msg]
+ error = InventError("Logged in user does not own the specified job")
+ return error
+
def do_get_items(self, session):
ad_list = self.items.get(session)
error = self.qmf_error.get(session)
-
if not ad_list and not error:
ad_list = list()
- id = self.frame.id.get(session)
- submission, job_server, sched = self.frame.get_trifecta(session, id)
- job_id = self.frame.job_id.get(session)
- results = self.app.remote.get_job_ad(job_server, job_id,
- sched.Name, submission,
- default={'JobAd': {}})
- error = results.error
+ results = self.get_job_ad(session)
+ error = None
+ if results.error:
+ error = results.error
+ elif self.do_check_viewable:
+ error = self.check_job_owner(session, results.data['JobAd'])
+
self.qmf_error.set(session, error)
ads = results.data['JobAd']
cls = self.app.model.job_meta_data
@@ -637,7 +698,8 @@
# check for qmf error
_, error = self.parent.do_get_items(session)
if error:
- msg = len(error.args) > 0 and error.args[0] or ""
+ msg = (hasattr(error, "args") and \
+ len(error.args) > 0 and error.args[0]) or ""
if not msg:
# probably a timeout exception
msg = "Unable to get Job information at this time"
@@ -693,6 +755,8 @@
else:
return super(JobAdsViewer, self).do_render(session)
+ self.do_check_viewable = False
+
def render_edit_button(self, session):
_, error = self.do_get_items(session)
render = True
@@ -822,6 +886,9 @@
orig=ads[x]["orig"]) for x in ads]
items, error = super(JobAdsEditor, self).do_get_items(session)
+ if error:
+ items = []
+
for item in items:
item["path"] = self.ads.path
return items, error
@@ -844,6 +911,21 @@
def has_double_quotes(value):
return value[:1] == "\"" and value[-1:] == "\""
+ # Check to see if the job is owned by the logged in user.
+ # At this point, the only way to do this check is request
+ # the job ad again. Maybe not efficient.
+ if self.do_check_viewable:
+ results = self.get_job_ad(session)
+ if results.error:
+ error = results.error
+ else:
+ error = self.check_job_owner(session,
+ results.data['JobAd'])
+ if error:
+ self.qmf_error.set(session, error)
+ self.process_cancel(session)
+ return
+
ads = self.ads.get(session)
just_ads = dict()
@@ -965,7 +1047,7 @@
return file and "loading..." or self.err_msg
class JobOutput(JobAdsSet, Form):
- def __init__(self, app, name):
+ def __init__(self, app, name, check_viewable):
super(JobOutput, self).__init__(app, name)
self.which_file = self.FileSwitch(app, "file")
@@ -980,6 +1062,8 @@
self.output = OutputFile(app, "job_output", self.which_file, self.first_last)
self.add_child(self.output)
+ self.do_check_viewable = check_viewable
+
def render_title(self, session):
return "Output"
@@ -1004,6 +1088,11 @@
iwd = None
ads, error = self.do_get_items(session)
+ if error:
+ msg = (hasattr(error, "args") and \
+ len(error.args) > 0 and error.args[0]) or ""
+ self.set_redirect(session, self.frame.parent, msg)
+
for ad in ads:
if ad['name'] == "Out":
out_file = ad['value']
Modified: trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- trunk/cumin/python/cumin/grid/submission.py 2012-07-10 13:21:25 UTC (rev 5428)
+++ trunk/cumin/python/cumin/grid/submission.py 2012-07-12 15:06:02 UTC (rev 5429)
@@ -34,13 +34,9 @@
# processing pass.
self.do_check_viewable = check_viewable
- self.job = JobFrame(app, "job", self.object)
+ self.job = JobFrame(app, "job", self.object, check_viewable)
self.add_mode(self.job)
- # Ditto. This will check whether the selected job
- # is viewable by the logged in user.
- self.job.do_check_viewable = check_viewable
-
jobs = JobSelector(app, "jobs", self.object)
self.view.add_tab(jobs)
Modified: trunk/cumin/python/cumin/objectframe.py
===================================================================
--- trunk/cumin/python/cumin/objectframe.py 2012-07-10 13:21:25 UTC (rev 5428)
+++ trunk/cumin/python/cumin/objectframe.py 2012-07-12 15:06:02 UTC (rev 5429)
@@ -62,24 +62,18 @@
return (self.parent,
"Logged in user does not own a specified object")
+ def check_owner(self, obj, session):
+ return not hasattr(obj, "Owner") or \
+ session.client_session.check_owner(obj.Owner)
+
def check_viewable(self, obj, session):
- login = session.client_session.attributes["login_session"]
- user = login.user.name
- okay = not hasattr(obj, "Owner") or obj.Owner == user
- if okay:
- frame = None
- message = None
- else:
- frame, message = self.not_viewable_redirect()
- return okay, frame, message
+ frame = None
+ message = None
+ okay = self.check_owner(obj, session)
+ if not okay:
+ frame, message = self.not_viewable_redirect()
+ return okay, frame, message
- def set_redirect(self, session, frame, message):
- nsession = session.branch()
- frame.view.show(nsession)
- url = nsession.marshal()
- self.page.redirect.set(session, url)
- session.add_notice(Notice(message))
-
def do_process(self, session):
# XXX don't process if this frame is invisible
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-07-10 13:21:25 UTC (rev 5428)
+++ trunk/wooly/python/wooly/__init__.py 2012-07-12 15:06:02 UTC (rev 5429)
@@ -396,6 +396,17 @@
def render_error_msg(self, session, *args):
return "There is no content to display"
+ def set_redirect(self, session, frame, message):
+ nsession = session.branch()
+ frame.view.show(nsession)
+ url = nsession.marshal()
+ self.page.redirect.set(session, url)
+ if message:
+ session.add_notice(Notice(message))
+
+ def get_redirect(self, session):
+ return self.page.redirect.get(session)
+
class Frame(Widget):
def show(self, session):
super(Frame, self).show(session)
Modified: trunk/wooly/python/wooly/server.py
===================================================================
--- trunk/wooly/python/wooly/server.py 2012-07-10 13:21:25 UTC (rev 5428)
+++ trunk/wooly/python/wooly/server.py 2012-07-12 15:06:02 UTC (rev 5429)
@@ -267,6 +267,10 @@
self.attributes = dict()
+ def check_owner(self, owner):
+ user = self.attributes["login_session"].user.name
+ return owner == user
+
def __repr__(self):
args = (self.__class__.__name__, self.id, self.created)
return "%s(%s,%s)" % args
11 years, 8 months
r5428 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2012-07-10 13:21:25 +0000 (Tue, 10 Jul 2012)
New Revision: 5428
Modified:
trunk/cumin/python/cumin/grid/dashboard.py
Log:
Removing some test code that accidentally got checked-in.
Modified: trunk/cumin/python/cumin/grid/dashboard.py
===================================================================
--- trunk/cumin/python/cumin/grid/dashboard.py 2012-07-05 19:28:00 UTC (rev 5427)
+++ trunk/cumin/python/cumin/grid/dashboard.py 2012-07-10 13:21:25 UTC (rev 5428)
@@ -686,10 +686,6 @@
options.group_column = ",".join((self.sum_column, self.act_state_column.identifier))
records = self.get_data(values, options)
- for i in range(1,5):
- record = records[0]
- record = ('Linux%d' % i, 50L, 'IdleUnclaimed')
- records.append(record)
# accumulate records by os/used|unused manually
recs_by_os = dict()
11 years, 8 months