r5425 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2012-06-28 15:14:50 +0000 (Thu, 28 Jun 2012)
New Revision: 5425
Modified:
trunk/cumin/python/cumin/grid/dashboard.strings
Log:
Allowing charts on the history tab to display inline and wrap according to browser width.
Modified: trunk/cumin/python/cumin/grid/dashboard.strings
===================================================================
--- trunk/cumin/python/cumin/grid/dashboard.strings 2012-06-27 19:38:39 UTC (rev 5424)
+++ trunk/cumin/python/cumin/grid/dashboard.strings 2012-06-28 15:14:50 UTC (rev 5425)
@@ -311,3 +311,21 @@
{export}
</div>
</div>
+
+[DashboardHistory.css]
+div.DashboardHistory ul.WidgetSet {
+ padding: 0;
+ margin: 0;
+ list-style: none;
+}
+
+div.DashboardHistory ul.WidgetSet li {
+ display: inline;
+ float: left;
+}
+
+[DashboardHistory.html]
+<div class="{class}">
+ {charts}
+</div>
+<div style="clear:both;"></div>
11 years, 9 months
r5424 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-06-27 19:38:39 +0000 (Wed, 27 Jun 2012)
New Revision: 5424
Modified:
trunk/cumin/python/cumin/stat.py
Log:
Database requests to retrieve multiple stats for a single chart are now done concurrently.
Modified: trunk/cumin/python/cumin/stat.py
===================================================================
--- trunk/cumin/python/cumin/stat.py 2012-06-22 13:58:47 UTC (rev 5423)
+++ trunk/cumin/python/cumin/stat.py 2012-06-27 19:38:39 UTC (rev 5424)
@@ -1,7 +1,8 @@
import cStringIO
import logging
from datetime import datetime, timedelta
-from time import time
+from time import time, sleep
+import threading
from wooly import Widget, Page, Parameter, Attribute
from wooly.util import StringCatalog, escape_entity, Writer
@@ -472,10 +473,12 @@
signature = self.object_signature.get(session)
- adapter = SamplesSqlAdapter(self.app, rosemary_class, signature, session)
stats = [getattr(rosemary_class, x) for x in self.stats.get(session)]
-
- return (adapter, stats)
+ adapters = dict()
+ for stat in stats:
+ adapters[stat] = SamplesSqlAdapter(self.app, rosemary_class, signature, session)
+
+ return (adapters, stats)
# 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
@@ -533,7 +536,7 @@
ret["xy"] = title_xy[cached_samples[stat][1]]
rets[stat.name] = ret
return str(rets)
-
+
class ModifiedAgentIdParameter(StringParameter):
def get(self, session):
agent = super(ModifiedAgentIdParameter, self).get(session)
@@ -929,7 +932,11 @@
super(AreaChart, self).__init__(app, name, page)
self.alpha = 3
-
+
+ def getStatSamples(self, adapter, samples, stat, dur, interval, method, end_seconds_ago, delta):
+ # get more samples than needed to allow chart to clip correctly (explains the + 600)
+ samples[stat] = adapter[stat].samples(stat, dur+600, interval, method, secs2=end_seconds_ago, delta=delta)
+
def fetch_samples(self, adapter, dur, interval, method, mode, delta, stats, end_seconds_ago=0):
samples = dict()
if mode == "rate":
@@ -949,10 +956,16 @@
samples[stat] = ns
else:
- for stat in stats:
- # get more samples than needed to allow chart to clip correctly
- samples[stat] = adapter.samples(stat, dur+600, interval, method, secs2=end_seconds_ago, delta=delta)
+ threads = []
+ for i, stat in enumerate(stats):
+ # start a thread to do the db query, etc for each stat requested
+ threads.append(threading.Thread(target = self.getStatSamples, args = (adapter, samples, stat, dur, interval, method, end_seconds_ago, delta)))
+ threads[i].start()
+ for th in threads:
+ while th.isAlive():
+ pass
+
return samples
def get_max_min(self, session, stats, samples, time_span=99999, end_seconds_ago=0):
11 years, 9 months
r5423 - trunk/cumin/model/plumage
by croberts@fedoraproject.org
Author: croberts
Date: 2012-06-22 13:58:47 +0000 (Fri, 22 Jun 2012)
New Revision: 5423
Modified:
trunk/cumin/model/plumage/rosemary.xml
Log:
Changing display labels for some of the plumage OSUtil stats.
Modified: trunk/cumin/model/plumage/rosemary.xml
===================================================================
--- trunk/cumin/model/plumage/rosemary.xml 2012-06-20 18:15:37 UTC (rev 5422)
+++ trunk/cumin/model/plumage/rosemary.xml 2012-06-22 13:58:47 UTC (rev 5423)
@@ -38,35 +38,35 @@
</statistic>
<statistic name="freemem">
- <title>Free memory (pool)</title>
+ <title>Free(MB)</title>
</statistic>
<statistic name="usedmem">
- <title>Used memory (pool)</title>
+ <title>Used(MB)</title>
</statistic>
<statistic name="availmem">
- <title>Available memory (pool)</title>
+ <title>Available(MB)</title>
</statistic>
<statistic name="totalmem">
- <title>Total memory (pool)</title>
+ <title>Total(MB)</title>
</statistic>
<statistic name="freecpu">
- <title>Free cpus (pool)</title>
+ <title>Free</title>
</statistic>
<statistic name="usedcpu">
- <title>Used cpus (pool)</title>
+ <title>Used</title>
</statistic>
<statistic name="availcpu">
- <title>Available cpus (pool)</title>
+ <title>Available</title>
</statistic>
<statistic name="totalcpu">
- <title>Total cpus (pool)</title>
+ <title>Total</title>
</statistic>
</class>
11 years, 9 months
r5422 - in trunk/cumin: bin etc python/cumin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-06-20 18:15:37 +0000 (Wed, 20 Jun 2012)
New Revision: 5422
Modified:
trunk/cumin/bin/cumin-data
trunk/cumin/bin/cumin-report
trunk/cumin/bin/cumin-web
trunk/cumin/etc/cumin.conf
trunk/cumin/python/cumin/config.py
Log:
Allow absolute or relative paths for log-file values. For relative paths,
the base will be $CUMIN_HOME/log/ if defined or else /usr/share/cumin/log/.
Modified: trunk/cumin/bin/cumin-data
===================================================================
--- trunk/cumin/bin/cumin-data 2012-06-20 14:54:11 UTC (rev 5421)
+++ trunk/cumin/bin/cumin-data 2012-06-20 18:15:37 UTC (rev 5422)
@@ -173,6 +173,8 @@
# Use the config values as defaults for unspecified options
apply_defaults(values, opts)
+ # If log_file is a relative path, base it from $CUMIN_HOME/log
+ opts.log_file = config.expand_log_file(opts.log_file)
setup_operational_logging(opts,
values.log_max_mb,
values.log_max_archives)
Modified: trunk/cumin/bin/cumin-report
===================================================================
--- trunk/cumin/bin/cumin-report 2012-06-20 14:54:11 UTC (rev 5421)
+++ trunk/cumin/bin/cumin-report 2012-06-20 18:15:37 UTC (rev 5422)
@@ -143,6 +143,8 @@
# Use the config values as defaults for unspecified options
apply_defaults(values, opts)
+ # If log_file is a relative path, base it from $CUMIN_HOME/log
+ opts.log_file = config.expand_log_file(opts.log_file)
setup_operational_logging(opts,
values.log_max_mb,
values.log_max_archives)
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2012-06-20 14:54:11 UTC (rev 5421)
+++ trunk/cumin/bin/cumin-web 2012-06-20 18:15:37 UTC (rev 5422)
@@ -184,6 +184,8 @@
# Use the config values as defaults for unspecified options
apply_defaults(values, opts)
+ # If log_file is a relative path, base it from $CUMIN_HOME/log
+ opts.log_file = config.expand_log_file(opts.log_file)
setup_operational_logging(opts,
values.log_max_mb,
values.log_max_archives)
Modified: trunk/cumin/etc/cumin.conf
===================================================================
--- trunk/cumin/etc/cumin.conf 2012-06-20 14:54:11 UTC (rev 5421)
+++ trunk/cumin/etc/cumin.conf 2012-06-20 18:15:37 UTC (rev 5422)
@@ -2,6 +2,10 @@
# Explanatory comments for some options are included
# at the end of the file.
+# Values for log-file parameters may be absolute or
+# relative paths. See the comments under the [web]
+# section at the end of the file for more information.
+
# If a configuration section does not set a value for
# a particular parameter, the parameter is searched for
# in the [common] section. This allows values to be set
@@ -102,7 +106,7 @@
# ****************************************************
[web]
-# log-file: $CUMIN_HOME/log/web.log
+# log-file: /usr/share/cumin/log/web.log
# host: localhost ('0.0.0.0' binds to all local interfaces)
# port: 45672
# server-cert:
@@ -123,7 +127,7 @@
# A value of 0 will cause the messages to never timeout
[data]
-# log-file: $CUMIN_HOME/log/data.log
+# log-file: /usr/share/cumin/log/data.log
# expire-enabled: True
# expire-interval: 3600
# expire-threshold: 86400
@@ -145,7 +149,7 @@
#exclude-classes: com.redhat.grid:*
[data.grid]
-# log-file: $CUMIN_HOME/log/data.grid.log
+# log-file: /usr/share/cumin/log/data.grid.log
# expire-enabled: True
expire-interval: 900
# expire-threshold: 86400
@@ -156,7 +160,7 @@
com.redhat.grid:JobServer, com.redhat.grid:Submitter, com.redhat.grid:Scheduler
[data.grid-slots]
-# log-file: $CUMIN_HOME/log/data.grid-slots.log
+# log-file: /usr/share/cumin/log/data.grid-slots.log
expire-enabled: False
# expire-interval: 3600
# expire-threshold: 86400
@@ -166,7 +170,7 @@
# exclude-classes: [none]
[data.grid-submissions]
-# log-file: $CUMIN_HOME/log/data.grid-submissions.log
+# log-file: /usr/share/cumin/log/data.grid-submissions.log
expire-enabled: False
# expire-interval: 3600
# expire-threshold: 86400
@@ -177,7 +181,7 @@
# exclude-classes: [none]
[data.sesame]
-# log-file: $CUMIN_HOME/log/data.sesame.log
+# log-file: /usr/share/cumin/log/data.sesame.log
expire-enabled: False
# expire-interval: 3600
# expire-threshold: 86400
@@ -187,7 +191,7 @@
# exclude-classes: [none]
[data.other]
-# log-file: $CUMIN_HOME/log/data.messaging.log
+# log-file: /usr/share/cumin/log/data.other.log
expire-enabled: False
# expire-interval: 3600
# expire-threshold: 86400
@@ -199,7 +203,7 @@
[report]
# include-classes: [all]
# exclude-classes: [none]
-# log-file: $CUMIN_HOME/log/report.log
+# log-file: /usr/share/cumin/log/report.log
# expire-enabled: True
expire-interval: 1d
expire-threshold: 90d
@@ -282,6 +286,12 @@
## [web]
+## log-file:
+## If the value starts with "/" it is an absolute path for the
+## log file. Otherwise, the value will be a relative path.
+## For a relative path, the base path will be $CUMIN_HOME/log/.
+## If $CUMIN_HOME is not defined, the base will be /usr/share/cumin/log/.
+
## server-cert:
## This is a server certificate file in PEM format.
## If server-cert and server-key are both set and valid,
@@ -344,6 +354,9 @@
## [data]
+## log-file:
+## See notes under the [web] section
+
## expire-enabled: True
## Whether or not the instance runs a thread which periodically expires samples.
## Running the expire thread from more than one instance is okay but unnecessary
Modified: trunk/cumin/python/cumin/config.py
===================================================================
--- trunk/cumin/python/cumin/config.py 2012-06-20 14:54:11 UTC (rev 5421)
+++ trunk/cumin/python/cumin/config.py 2012-06-20 18:15:37 UTC (rev 5422)
@@ -33,6 +33,13 @@
return os.path.join(self.home, "log", "." + section_name + ".init")
return ""
+ def expand_log_file(self, log_file):
+ # If log_file begins with a / it's absolute and we
+ # leave it alone. If not, it's relative to $CUMIN_HOME/log
+ if not log_file or log_file.startswith("/"):
+ return log_file
+ return os.path.join(self.home, "log", log_file)
+
def parse(self):
paths = list()
11 years, 9 months
r5421 - in trunk: cumin/bin cumin/python/cumin sage/python/sage/wallaby
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-06-20 14:54:11 +0000 (Wed, 20 Jun 2012)
New Revision: 5421
Modified:
trunk/cumin/bin/cumin-data
trunk/cumin/bin/cumin-report
trunk/cumin/bin/cumin-web
trunk/cumin/python/cumin/util.py
trunk/sage/python/sage/wallaby/wallabyoperations.py
Log:
Minor improvements to shutdown handling
Modified: trunk/cumin/bin/cumin-data
===================================================================
--- trunk/cumin/bin/cumin-data 2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/bin/cumin-data 2012-06-20 14:54:11 UTC (rev 5421)
@@ -308,6 +308,8 @@
except:
tm = 5
t.join(tm)
+ if t.isAlive():
+ log.info("Shutdown thread timed out, exiting")
if pipeThread:
pipeThread.stop(immediate=True)
Modified: trunk/cumin/bin/cumin-report
===================================================================
--- trunk/cumin/bin/cumin-report 2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/bin/cumin-report 2012-06-20 14:54:11 UTC (rev 5421)
@@ -286,6 +286,8 @@
except:
tm = 5
t.join(tm)
+ if t.isAlive():
+ log.info("Shutdown thread timed out, exiting")
if pipeThread:
pipeThread.stop(immediate=True)
return adjust_return(passed_init, return_code)
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/bin/cumin-web 2012-06-20 14:54:11 UTC (rev 5421)
@@ -321,6 +321,8 @@
except:
tm = 5
t.join(tm)
+ if t.isAlive():
+ log.info("Shutdown thread timed out, exiting")
if pipeThread:
pipeThread.stop(immediate=True)
return adjust_return(passed_init, return_code)
Modified: trunk/cumin/python/cumin/util.py
===================================================================
--- trunk/cumin/python/cumin/util.py 2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/cumin/python/cumin/util.py 2012-06-20 14:54:11 UTC (rev 5421)
@@ -282,4 +282,11 @@
self.daemon = True
def run(self):
- self.routine()
+ # We know that ShutdwonThreads by nature may not
+ # terminate, and the app may exit underneath them.
+ # Try to squash exceptions here in the case of a
+ # timeout.
+ try:
+ self.routine()
+ except:
+ pass
Modified: trunk/sage/python/sage/wallaby/wallabyoperations.py
===================================================================
--- trunk/sage/python/sage/wallaby/wallabyoperations.py 2012-06-20 12:37:10 UTC (rev 5420)
+++ trunk/sage/python/sage/wallaby/wallabyoperations.py 2012-06-20 14:54:11 UTC (rev 5421)
@@ -247,6 +247,14 @@
log.debug("WallabyOperations: %s seconds to refresh %s" % (delta, attr))
return d
+ # Wrap the entire cache thread with an exception handler
+ def wrap_maintain_cache():
+ try:
+ maintain_cache(self)
+ log.debug("WallabyOperations: cache maintenance thread exited")
+ except:
+ pass
+
if self._maintain_cache is not None and \
self._maintain_cache.isAlive():
# No, you can't start another one.
@@ -256,7 +264,7 @@
if self.broker_uri is not None:
# self._maintain_cache = CallThread(cProfile.runctx('maintain_cache(self)', globals(), locals(), filename='sage.stats'), None)
- self._maintain_cache = CallThread(maintain_cache, None, self)
+ self._maintain_cache = CallThread(wrap_maintain_cache, None)
self._maintain_cache.daemon = True
self._maintain_cache.start()
log.debug("WallabyOperations: start cache maintenance thread")
@@ -287,6 +295,7 @@
self._condition.notify()
self._condition.release()
if wait and self._maintain_cache.isAlive():
+ log.debug("WallabyOperations: waiting for cache maintenance thread to exit")
self._maintain_cache.join(timeout)
log.debug("WallabyOperations: stopped cache maintenance thread")
11 years, 9 months
r5420 - in trunk: cumin/bin cumin/python/cumin sage/python/sage/aviary
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-06-20 12:37:10 +0000 (Wed, 20 Jun 2012)
New Revision: 5420
Modified:
trunk/cumin/bin/cumin-web
trunk/cumin/python/cumin/config.py
trunk/cumin/python/cumin/main.py
trunk/sage/python/sage/aviary/aviaryoperations.py
Log:
By default, look for aviary wsdl files in /var/lib/condor/aviary/services before looking at the files bundled with Cumin. This helps avoid minor incompatibilities in wsdl versions.
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2012-06-19 00:23:53 UTC (rev 5419)
+++ trunk/cumin/bin/cumin-web 2012-06-20 12:37:10 UTC (rev 5420)
@@ -30,6 +30,9 @@
# For development use. Default is False. Undocumented.
cumin.aviary_suds_logs = values.aviary_suds_logs
+ # Defautl is True. Undocumented.
+ cumin.aviary_prefer_condor = values.aviary_prefer_condor
+
def set_wallaby_configs(cumin, values, brokers):
if values.wallaby_broker == "":
cumin.wallaby_broker = brokers[0]
Modified: trunk/cumin/python/cumin/config.py
===================================================================
--- trunk/cumin/python/cumin/config.py 2012-06-19 00:23:53 UTC (rev 5419)
+++ trunk/cumin/python/cumin/config.py 2012-06-20 12:37:10 UTC (rev 5420)
@@ -186,12 +186,6 @@
param = ConfigParameter(self, "aviary-query-servers", str)
param.default = "http://localhost:9091"
- param = ConfigParameter(self, "server-cert", str)
- param.default = ""
-
- param = ConfigParameter(self, "server-key", str)
- param.default = ""
-
param = ConfigParameter(self, "aviary-locator", str)
param.default = ""
@@ -212,6 +206,21 @@
param = ConfigParameter(self, "aviary-suds-logs", bool)
param.default = False
+ # By default, Cumin will look for aviary wsdl files in
+ # /var/lib/condor/aviary/services before it looks to the
+ # wsdl files bundled with Cumin.
+ # If this flag is set to False, it will look at the files
+ # bundled with Cumin first.
+ # Undocumented.
+ param = ConfigParameter(self, "aviary-prefer-condor", bool)
+ param.default = True
+
+ param = ConfigParameter(self, "server-cert", str)
+ param.default = ""
+
+ param = ConfigParameter(self, "server-key", str)
+ param.default = ""
+
param = ConfigIntervalParameter(self, "update-interval")
param.default = 10
Modified: trunk/cumin/python/cumin/main.py
===================================================================
--- trunk/cumin/python/cumin/main.py 2012-06-19 00:23:53 UTC (rev 5419)
+++ trunk/cumin/python/cumin/main.py 2012-06-20 12:37:10 UTC (rev 5420)
@@ -105,10 +105,11 @@
self.aviary_root_cert = ""
self.aviary_domain_verify=True
self.aviary_locator = ""
-
+
# For development use only
self.aviary_suds_logs = False
-
+ self.aviary_prefer_condor = True
+
self.wallaby = None
self.wallaby_broker = None
self.wallaby_refresh = 60
@@ -202,12 +203,19 @@
imports_ok = False
if imports_ok:
SudsLogging.set(self.aviary_suds_logs, self.home)
- aviary_dir = os.path.join(self.home, "rpc-defs/aviary")
- # The factory will choose an impl that gives us jobs, queries, or both
- # depending on whether job_servers and query_servers are empty strings.
- # If locator is non empty, their actual values will be overridden
- # but the presence of a value will stole control enable/disable.
+ # By default Cumin uses /var/lib/condor/aviary/services for
+ # aviary wsdl files if it exists.
+ aviary_dir = ["/var/lib/condor/aviary/services",
+ os.path.join(self.home, "rpc-defs/aviary")]
+ if not self.aviary_prefer_condor:
+ aviary_dir = [aviary_dir[1], aviary_dir[0]]
+
+ # The factory will choose an impl that gives us jobs, queries,
+ # or both depending on whether job_servers and query_servers
+ # are empty strings. If locator is non empty, their actual
+ # values will be overridden but the presence of a value will
+ # still control enable/disable.
aviary_itf = AviaryOperationsFactory("aviary", aviary_dir,
self.aviary_locator,
self.aviary_job_servers,
Modified: trunk/sage/python/sage/aviary/aviaryoperations.py
===================================================================
--- trunk/sage/python/sage/aviary/aviaryoperations.py 2012-06-19 00:23:53 UTC (rev 5419)
+++ trunk/sage/python/sage/aviary/aviaryoperations.py 2012-06-20 12:37:10 UTC (rev 5420)
@@ -224,7 +224,10 @@
"/services/job/",
"JOB")
- job_wsdl = "file:" + os.path.join(datadir, "aviary-job.wsdl")
+
+
+ job_wsdl = "file:" + os.path.join(self.get_datadir(datadir,"job"),
+ "aviary-job.wsdl")
self.job_client_pool = ClientPool(job_wsdl, None)
def set_job_attribute(self, scheduler, job_id, name, value, callback, submission):
@@ -411,7 +414,8 @@
"/services/query/",
"QUERY_SERVER")
- query_wsdl = "file:" + os.path.join(datadir, "aviary-query.wsdl")
+ query_wsdl = "file:" + os.path.join(self.get_datadir(datadir,"query"),
+ "aviary-query.wsdl")
self.query_client_pool = ClientPool(query_wsdl, None)
def fetch_job_data(self, job_server, job_id, ftype, file, start, end,
@@ -639,6 +643,23 @@
self.type_to_aviary = self._type_to_aviary()
self.aviary_to_type = self._aviary_to_type()
+ def get_datadir(self, datadir, subdir):
+ if not type(datadir) in (tuple, list):
+ datadir = [datadir]
+
+ # Find the first element in datadir that is a valid
+ # path. If the path has a subdirectory called
+ # "subdir", consider that part of the path.
+ for d in datadir:
+ if os.path.isdir(d):
+ s = os.path.join(d, subdir)
+ if os.path.isdir(s):
+ return s
+ return d
+ # Hmm, well, just return the first one since we're
+ # going to get an error anyway.
+ return datadir[0]
+
@classmethod
def _type_to_aviary(cls):
# Need to be able to turn simple Python types into Aviary types for attributes
11 years, 9 months
r5419 - in branches/stability/cumin/python/cumin: . grid usergrid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-06-19 00:23:53 +0000 (Tue, 19 Jun 2012)
New Revision: 5419
Modified:
branches/stability/cumin/python/cumin/grid/job.py
branches/stability/cumin/python/cumin/grid/submission.py
branches/stability/cumin/python/cumin/objectframe.py
branches/stability/cumin/python/cumin/usergrid/widgets.py
Log:
Merge changes from trunk.
BZ769573 (mod)
svn merge -r 5415:HEAD svn+ssh://svn.fedorahosted.org/svn/cumin/trunk .
Modified: branches/stability/cumin/python/cumin/grid/job.py
===================================================================
--- branches/stability/cumin/python/cumin/grid/job.py 2012-06-18 21:16:28 UTC (rev 5418)
+++ branches/stability/cumin/python/cumin/grid/job.py 2012-06-19 00:23:53 UTC (rev 5419)
@@ -16,7 +16,7 @@
from wooly import Widget, Parameter, Attribute
from wooly.util import StringCatalog, Writer, escape_amp, escape_entity,\
xml_escape
-from wooly.forms import Form, FormButton, StringField, NoXMLStringField
+from wooly.forms import Form, FormButton, StringField, NoXMLStringField, FormError
from wooly.widgets import ModeSet, PropertySet, TemplateRenderer
from wooly.template import WidgetTemplate
from wooly.parameters import ListParameter, IntegerParameter, DictParameter
@@ -95,6 +95,10 @@
return branch.marshal()
+ def not_viewable_redirect(self):
+ return (self.parent,
+ "Logged in user does not own the specified job")
+
class JobAdModes(ModeSet):
def __init__(self, app, name):
super(JobAdModes, self).__init__(app, name)
@@ -420,6 +424,25 @@
reason = self.reason.render(session)
return "<table class=\"FormFieldSet\"><tbody>%s</tbody></table>%s" % (reason, content)
+ def validate(self, session):
+ super(JobObjectSelectorTaskForm, self).validate(session)
+ 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
+ login = session.client_session.attributes["login_session"]
+ if "admin" not in login.group:
+ user = login.user.name
+ submission_id = self.submission_id.get(session)
+ cls = self.app.model.com_redhat_grid.Submission
+ submission = cls.get_object_by_id(session.cursor,
+ submission_id)
+ if hasattr(submission, "Owner") and submission.Owner != user:
+ f = FormError("The logged in user does not "\
+ "own this submission.")
+ self.errors.add(session, f)
+
+
class JobAdsSet(PropertySet):
types = {0: "expression",
1: "integer",
@@ -1110,6 +1133,22 @@
self.task.invoke(session, scheduler, job_id, reason, submission)
self.task.exit_with_redirect(session)
+ def validate(self, session):
+ super(JobActionForm, self).validate(session)
+ 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
+ login = session.client_session.attributes["login_session"]
+ if "admin" not in login.group:
+ user = login.user.name
+ id = self.id.get(session)
+ submission = self.task.frame.get_submission(session, id)
+ if hasattr(submission, "Owner") and submission.Owner != user:
+ f = FormError("The logged in user does not "\
+ "own this submission.")
+ self.errors.add(session, f)
+
class ReasonField(NoXMLStringField):
def render_title(self, session):
return "Reason"
Modified: branches/stability/cumin/python/cumin/grid/submission.py
===================================================================
--- branches/stability/cumin/python/cumin/grid/submission.py 2012-06-18 21:16:28 UTC (rev 5418)
+++ branches/stability/cumin/python/cumin/grid/submission.py 2012-06-19 00:23:53 UTC (rev 5419)
@@ -23,17 +23,30 @@
log = logging.getLogger("cumin.grid.submission")
class SubmissionFrame(ObjectFrame):
- def __init__(self, app, name):
+ def __init__(self, app, name, check_viewable=False):
cls = app.model.com_redhat_grid.Submission
super(SubmissionFrame, self).__init__(app, name, cls)
+ # This will check whether or not the selected submission
+ # object is viewable by the logged in user during the
+ # processing pass.
+ self.do_check_viewable = check_viewable
+
self.job = JobFrame(app, "job", self.object)
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)
+ def not_viewable_redirect(self):
+ return (self.parent,
+ "Logged in user does not own the specified submission")
+
class PoolSubmissionFrame(SubmissionFrame):
# Use an ObjectView derivation here so that
# SubmissionFrame can use a different summary class later on...
Modified: branches/stability/cumin/python/cumin/objectframe.py
===================================================================
--- branches/stability/cumin/python/cumin/objectframe.py 2012-06-18 21:16:28 UTC (rev 5418)
+++ branches/stability/cumin/python/cumin/objectframe.py 2012-06-19 00:23:53 UTC (rev 5419)
@@ -35,6 +35,8 @@
self.tasks = list()
+ self.do_check_viewable = False
+
def init(self):
super(ObjectFrame, self).init()
@@ -56,19 +58,49 @@
return "%s '%s'" % (obj._class._title, obj.get_title())
+ def not_viewable_redirect(self):
+ return (self.parent,
+ "Logged in user does not own a specified object")
+
+ 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
+
+ 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
id = self.id.get(session)
-
assert id
obj = self.get_object(session, id)
-
self.object.set(session, obj)
- super(ObjectFrame, self).do_process(session)
-
+ # If the check is turned on, see if the object can be
+ # viewed by the session. The check_viewable method will
+ # return a status, as well as a frame to redirect to and
+ # a message if the status is false
+ okay = not self.do_check_viewable or obj is None
+ if not okay:
+ okay, frame, message = self.check_viewable(obj, session)
+ if okay:
+ super(ObjectFrame, self).do_process(session)
+ else:
+ self.set_redirect(session, frame, message)
+
def get_object(self, session, id):
return self.cls.get_object_by_id(session.cursor, id)
Modified: branches/stability/cumin/python/cumin/usergrid/widgets.py
===================================================================
--- branches/stability/cumin/python/cumin/usergrid/widgets.py 2012-06-18 21:16:28 UTC (rev 5418)
+++ branches/stability/cumin/python/cumin/usergrid/widgets.py 2012-06-19 00:23:53 UTC (rev 5419)
@@ -95,7 +95,8 @@
self.view = UserSubmissionSelector(app, "view", user)
self.add_mode(self.view)
- self.submission = SubmissionFrame(app, "submission")
+ self.submission = SubmissionFrame(app, "submission",
+ check_viewable=True)
self.add_mode(self.submission)
def render_title(self, session):
11 years, 9 months
r5418 - trunk/wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-06-18 21:16:28 +0000 (Mon, 18 Jun 2012)
New Revision: 5418
Modified:
trunk/wooly/python/wooly/forms.py
Log:
There ought to be a blank line here.
Modified: trunk/wooly/python/wooly/forms.py
===================================================================
--- trunk/wooly/python/wooly/forms.py 2012-06-18 21:15:27 UTC (rev 5417)
+++ trunk/wooly/python/wooly/forms.py 2012-06-18 21:16:28 UTC (rev 5418)
@@ -152,6 +152,7 @@
def get_message(self, session):
title = self.widget.render_title(session)
return "The '%s' field may not contain XML special characters" % title
+
class EmptyInputError(FormError):
def __init__(self):
super(EmptyInputError, self).__init__("This value is required")
11 years, 9 months
r5417 - trunk/cumin/python/cumin/grid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-06-18 21:15:27 +0000 (Mon, 18 Jun 2012)
New Revision: 5417
Modified:
trunk/cumin/python/cumin/grid/job.py
Log:
Role enforcement tweaks.
BZ769573 (mod)
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2012-06-18 16:29:47 UTC (rev 5416)
+++ trunk/cumin/python/cumin/grid/job.py 2012-06-18 21:15:27 UTC (rev 5417)
@@ -16,7 +16,7 @@
from wooly import Widget, Parameter, Attribute
from wooly.util import StringCatalog, Writer, escape_amp, escape_entity,\
xml_escape
-from wooly.forms import Form, FormButton, StringField, NoXMLStringField
+from wooly.forms import Form, FormButton, StringField, NoXMLStringField, FormError
from wooly.widgets import ModeSet, PropertySet, TemplateRenderer, Notice
from wooly.template import WidgetTemplate
from wooly.parameters import ListParameter, IntegerParameter, DictParameter
@@ -439,6 +439,25 @@
reason = self.reason.render(session)
return "<table class=\"FormFieldSet\"><tbody>%s</tbody></table>%s" % (reason, content)
+ def validate(self, session):
+ super(JobObjectSelectorTaskForm, self).validate(session)
+ 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
+ login = session.client_session.attributes["login_session"]
+ if "admin" not in login.group:
+ user = login.user.name
+ submission_id = self.submission_id.get(session)
+ cls = self.app.model.com_redhat_grid.Submission
+ submission = cls.get_object_by_id(session.cursor,
+ submission_id)
+ if hasattr(submission, "Owner") and submission.Owner != user:
+ f = FormError("The logged in user does not "\
+ "own this submission.")
+ self.errors.add(session, f)
+
+
class JobAdsSet(PropertySet):
types = {0: "expression",
1: "integer",
@@ -1141,6 +1160,22 @@
self.task.invoke(session, scheduler, job_id, reason, submission)
self.task.exit_with_redirect(session)
+ def validate(self, session):
+ super(JobActionForm, self).validate(session)
+ 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
+ login = session.client_session.attributes["login_session"]
+ if "admin" not in login.group:
+ user = login.user.name
+ id = self.id.get(session)
+ submission = self.task.frame.get_submission(session, id)
+ if hasattr(submission, "Owner") and submission.Owner != user:
+ f = FormError("The logged in user does not "\
+ "own this submission.")
+ self.errors.add(session, f)
+
class ReasonField(NoXMLStringField):
def render_title(self, session):
return "Reason"
11 years, 9 months
r5416 - in trunk: cumin/python/cumin cumin/python/cumin/grid cumin/python/cumin/usergrid wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-06-18 16:29:47 +0000 (Mon, 18 Jun 2012)
New Revision: 5416
Modified:
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/grid/submission.py
trunk/cumin/python/cumin/objectframe.py
trunk/cumin/python/cumin/usergrid/widgets.py
trunk/wooly/python/wooly/__init__.py
Log:
Role enforcement tweaks.
BZ769573 (mod)
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2012-06-14 20:14:04 UTC (rev 5415)
+++ trunk/cumin/python/cumin/grid/job.py 2012-06-18 16:29:47 UTC (rev 5416)
@@ -97,6 +97,10 @@
return branch.marshal()
+ def not_viewable_redirect(self):
+ return (self.parent,
+ "Logged in user does not own the specified job")
+
class JobAdModes(ModeSet):
def __init__(self, app, name):
super(JobAdModes, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- trunk/cumin/python/cumin/grid/submission.py 2012-06-14 20:14:04 UTC (rev 5415)
+++ trunk/cumin/python/cumin/grid/submission.py 2012-06-18 16:29:47 UTC (rev 5416)
@@ -24,17 +24,30 @@
log = logging.getLogger("cumin.grid.submission")
class SubmissionFrame(ObjectFrame):
- def __init__(self, app, name):
+ def __init__(self, app, name, check_viewable=False):
cls = app.model.com_redhat_grid.Submission
super(SubmissionFrame, self).__init__(app, name, cls)
+ # This will check whether or not the selected submission
+ # object is viewable by the logged in user during the
+ # processing pass.
+ self.do_check_viewable = check_viewable
+
self.job = JobFrame(app, "job", self.object)
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)
+ def not_viewable_redirect(self):
+ return (self.parent,
+ "Logged in user does not own the specified submission")
+
class PoolSubmissionFrame(SubmissionFrame):
# Use an ObjectView derivation here so that
# SubmissionFrame can use a different summary class later on...
Modified: trunk/cumin/python/cumin/objectframe.py
===================================================================
--- trunk/cumin/python/cumin/objectframe.py 2012-06-14 20:14:04 UTC (rev 5415)
+++ trunk/cumin/python/cumin/objectframe.py 2012-06-18 16:29:47 UTC (rev 5416)
@@ -35,6 +35,8 @@
self.tasks = list()
+ self.do_check_viewable = False
+
def init(self):
super(ObjectFrame, self).init()
@@ -56,19 +58,49 @@
return "%s '%s'" % (obj._class._title, obj.get_title())
+ def not_viewable_redirect(self):
+ return (self.parent,
+ "Logged in user does not own a specified object")
+
+ 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
+
+ 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
id = self.id.get(session)
-
assert id
obj = self.get_object(session, id)
-
self.object.set(session, obj)
- super(ObjectFrame, self).do_process(session)
-
+ # If the check is turned on, see if the object can be
+ # viewed by the session. The check_viewable method will
+ # return a status, as well as a frame to redirect to and
+ # a message if the status is false
+ okay = not self.do_check_viewable or obj is None
+ if not okay:
+ okay, frame, message = self.check_viewable(obj, session)
+ if okay:
+ super(ObjectFrame, self).do_process(session)
+ else:
+ self.set_redirect(session, frame, message)
+
def _allow_none(self, session):
try:
return self.page.allow_object_not_found.get(session)
Modified: trunk/cumin/python/cumin/usergrid/widgets.py
===================================================================
--- trunk/cumin/python/cumin/usergrid/widgets.py 2012-06-14 20:14:04 UTC (rev 5415)
+++ trunk/cumin/python/cumin/usergrid/widgets.py 2012-06-18 16:29:47 UTC (rev 5416)
@@ -95,7 +95,8 @@
self.view = UserSubmissionSelector(app, "view", user)
self.add_mode(self.view)
- self.submission = SubmissionFrame(app, "submission")
+ self.submission = SubmissionFrame(app, "submission",
+ check_viewable=True)
self.add_mode(self.submission)
def render_title(self, session):
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-06-14 20:14:04 UTC (rev 5415)
+++ trunk/wooly/python/wooly/__init__.py 2012-06-18 16:29:47 UTC (rev 5416)
@@ -510,11 +510,16 @@
self.process(session)
redirect = self.redirect.get(session)
+ if redirect:
+ raise PageRedirect()
+ rend = self.render(session)
+
+ redirect = self.redirect.get(session)
if redirect:
raise PageRedirect()
- return self.render(session)
+ return rend
def redirect_on_exception(self, session):
return None
11 years, 9 months