rhmessaging commits: r4346 - mgmt/newdata/cumin/python/cumin/grid.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2010-09-27 09:56:47 -0400 (Mon, 27 Sep 2010)
New Revision: 4346
Modified:
mgmt/newdata/cumin/python/cumin/grid/limit.py
Log:
Display the current max limit on the form.
Display the max limit as an integer.
Modified: mgmt/newdata/cumin/python/cumin/grid/limit.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/limit.py 2010-09-27 13:45:38 UTC (rev 4345)
+++ mgmt/newdata/cumin/python/cumin/grid/limit.py 2010-09-27 13:56:47 UTC (rev 4346)
@@ -90,12 +90,17 @@
return "Name"
def render_content(self, session, data):
- limit = data["name"]
+ limit_name = data["name"]
+ try:
+ limit_max = int(data["max"])
+ except:
+ limit_max = "0"
negotiator = self.parent.data.get_negotiator(session)
self.frame.limit.id.set(session, negotiator._id)
- self.frame.limit.set_limit.form.limit_name.set(session, limit)
+ self.frame.limit.set_limit.form.limit_name.set(session, limit_name)
+ self.frame.limit.set_limit.form.limit_max.set(session, limit_max)
href = self.frame.limit.set_limit.get_href(session)
- return fmt_link(href, limit)
+ return fmt_link(href, limit_name)
class CurrentColumn(NonSortableTableColumn):
def render_title(self, session):
@@ -105,6 +110,13 @@
def render_title(self, session):
return "Max Allowance"
+ def render_content(self, session, data):
+ try:
+ limit_max = int(data["max"])
+ except:
+ limit_max = "0"
+ return limit_max
+
class Limits(Attribute):
def get_default(self, session):
return dict()
@@ -128,6 +140,7 @@
def do_enter(self, session, osession):
self.form.limit_name.set(session, self.form.limit_name.get(osession))
+ self.form.limit_max.set(session, self.form.limit_max.get(osession))
def do_invoke(self, invoc, negotiator, limit_name, limit_max):
action = QmfCall(self.app)
14 years, 5 months
rhmessaging commits: r4345 - mgmt/newdata/cumin/etc.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-09-27 09:45:38 -0400 (Mon, 27 Sep 2010)
New Revision: 4345
Modified:
mgmt/newdata/cumin/etc/cumin.conf
Log:
Add a note in the config file about how to bind to all local interfaces
Modified: mgmt/newdata/cumin/etc/cumin.conf
===================================================================
--- mgmt/newdata/cumin/etc/cumin.conf 2010-09-27 12:52:35 UTC (rev 4344)
+++ mgmt/newdata/cumin/etc/cumin.conf 2010-09-27 13:45:38 UTC (rev 4345)
@@ -7,7 +7,7 @@
[web]
# log-file: $CUMIN_HOME/log/web.log
-# host: localhost
+# host: localhost ('0.0.0.0' binds to all local interfaces)
# port: 45672
# operator-email: [none]
# update-interval: 10
14 years, 5 months
rhmessaging commits: r4344 - mgmt/newdata/cumin/python/cumin/grid.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2010-09-27 08:52:35 -0400 (Mon, 27 Sep 2010)
New Revision: 4344
Modified:
mgmt/newdata/cumin/python/cumin/grid/job.py
Log:
Timeout exceptions thrown by console.py don't have an error message. Display a generic error string instead of "".
Modified: mgmt/newdata/cumin/python/cumin/grid/job.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/job.py 2010-09-25 01:09:29 UTC (rev 4343)
+++ mgmt/newdata/cumin/python/cumin/grid/job.py 2010-09-27 12:52:35 UTC (rev 4344)
@@ -499,7 +499,11 @@
# check for qmf error
_, error = self.parent.do_get_items(session)
if error:
- self.error_tmpl.render(writer, session, error.message)
+ msg = error.message
+ if not msg:
+ # probably a timeout exception
+ msg = "Unable to get Job information at this time"
+ self.error_tmpl.render(writer, session, msg)
else:
for group in self.app.model.get_ad_groups():
self.group_tmpl.render(writer, session, group)
14 years, 5 months
rhmessaging commits: r4343 - mgmt/newdata/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2010-09-24 21:09:29 -0400 (Fri, 24 Sep 2010)
New Revision: 4343
Modified:
mgmt/newdata/cumin/python/cumin/stat.py
Log:
Prevent flash charts from being flooded with too much data and crashing.
Modified: mgmt/newdata/cumin/python/cumin/stat.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/stat.py 2010-09-24 21:53:27 UTC (rev 4342)
+++ mgmt/newdata/cumin/python/cumin/stat.py 2010-09-25 01:09:29 UTC (rev 4343)
@@ -751,6 +751,8 @@
interval = self.page.get_interval(session, duration, width)
+ msg = "Chart parameters: duration: %s end_secends_ago: %s interval: %s" % (str(duration), str(end_seconds_ago), str(interval))
+ log.debug(msg)
# get the most recent samples
samples = self.fetch_samples(adapter, duration, interval,
self.fix_method(method, mode),
@@ -767,6 +769,8 @@
max_of_axiis = max(max_value, axis_for_vals)
# the most recent value(s) changed the y-axis range
if axis_max != max_of_axiis:
+ msg = "Y-Axis changed. New chart parameters: time_span: %s end_secends_ago: %s interval: %s" % (str(time_span), str(end_seconds_ago), str(interval))
+ log.debug(msg)
samples = self.fetch_samples(adapter, time_span, interval,
self.fix_method(method, mode),
mode, False, stats,
@@ -775,6 +779,9 @@
else:
append = True
+ for sample, stat in zip(samples, stats):
+ log.debug("samples in %s: %d" % (stat.name, len(samples[sample])))
+
# create the chart dict
chart = self.get_chart(session, adapter, stats, samples, time_span, max_value, min_value, append, end_seconds_ago)
#print "**********\n"+chart.create()
@@ -1023,7 +1030,7 @@
def get_vals(self, session, samples, stat, text, duration, end_secs):
tnow = time()
points = self.points.get(session)
- vals = list()
+ values = list()
if points:
vals = [{"x":int(duration -(tnow - secs(dt)) + end_secs),
@@ -1033,8 +1040,18 @@
for dt, value, stacked_value in reversed(points[stat])
if value is not None]
- return vals
+ log.debug("number of points before culling: %d" % len(vals))
+ # allow only 1 value that has a -x
+ first_positive = 0
+ for i in range(len(vals)):
+ if vals[i]['x'] >= 0:
+ first_positive = i
+ break
+ values = [vals[i] for i in range(len(vals)) if i >= first_positive - 1]
+ log.debug("number of points after culling: %d" % len(values))
+ return values
+
class Points(Attribute):
def get_default(self, session):
return dict()
14 years, 5 months
rhmessaging commits: r4342 - in mgmt/newdata/cumin/python/cumin: account and 2 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-09-24 17:53:27 -0400 (Fri, 24 Sep 2010)
New Revision: 4342
Modified:
mgmt/newdata/cumin/python/cumin/account/widgets.py
mgmt/newdata/cumin/python/cumin/database.py
mgmt/newdata/cumin/python/cumin/grid/daemon.py
mgmt/newdata/cumin/python/cumin/messaging/binding.py
mgmt/newdata/cumin/python/cumin/messaging/broker.py
mgmt/newdata/cumin/python/cumin/messaging/brokergroup.py
mgmt/newdata/cumin/python/cumin/messaging/brokerlink.py
mgmt/newdata/cumin/python/cumin/messaging/queue.py
mgmt/newdata/cumin/python/cumin/parameters.py
mgmt/newdata/cumin/python/cumin/sqladapter.py
mgmt/newdata/cumin/python/cumin/stat.py
mgmt/newdata/cumin/python/cumin/widgets.py
Log:
More in the department of safe connection reuse and exception handling
Modified: mgmt/newdata/cumin/python/cumin/account/widgets.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/account/widgets.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/account/widgets.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -116,8 +116,7 @@
self.validate(session)
if not self.errors.get(session):
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ cursor = self.app.database.get_read_cursor()
cls = self.app.model.com_redhat_cumin.User
user = cls.get_object(cursor, name=name)
@@ -203,16 +202,20 @@
self.validate(session)
if not self.errors.get(session):
+ password = self.new0.get(session)
+
conn = self.app.database.get_connection()
- cursor = conn.cursor()
- password = self.new0.get(session)
+ try:
+ cursor = conn.cursor()
- user = session.client_session.attributes["login_session"].user
- user.password = crypt_password(password)
- user.save(cursor)
+ user = session.client_session.attributes["login_session"].user
+ user.password = crypt_password(password)
+ user.save(cursor)
- conn.commit()
+ conn.commit()
+ finally:
+ conn.close()
task = ObjectTask(self.app)
invoc = task.start(session, None)
Modified: mgmt/newdata/cumin/python/cumin/database.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/database.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/database.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -2,6 +2,8 @@
import re
import threading
+from psycopg2.extensions import *
+
from util import *
log = logging.getLogger("cumin.database")
@@ -20,14 +22,23 @@
#m = re.match(r"^([^:]+)://([^@]+)@([^/]+)/(.+)$", self.uri)
def get_connection(self):
- conn = getattr(self.thread_local, "connection", None)
+ return psycopg2.connect(self.dsn)
+ def get_read_connection(self):
+ key = "read_connection"
+ conn = getattr(self.thread_local, key, None)
+
if not conn or conn.closed:
- conn = psycopg2.connect(self.dsn)
- setattr(self.thread_local, "connection", conn)
+ conn = self.get_connection()
+ setattr(self.thread_local, key, conn)
+ conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
+
return conn
+ def get_read_cursor(self):
+ return self.get_read_connection().cursor()
+
def __repr__(self):
return self.__class__.__name__
Modified: mgmt/newdata/cumin/python/cumin/grid/daemon.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/daemon.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/grid/daemon.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -3,16 +3,11 @@
class DaemonFrameTask(ObjectFrameTask):
def get_master(self, system_name, invoc):
+ cursor = self.app.database.get_read_cursor()
+
cls = self.app.model.com_redhat_grid.Master
+ master = cls.get_object(cursor, System=system_name)
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
-
- try:
- master = cls.get_object(cursor, System=system_name)
- finally:
- conn.close()
-
if not master:
invoc.exception = Exception("Master daemon not running")
invoc.status = invoc.FAILED
@@ -58,16 +53,11 @@
class DaemonSelectorTask(ObjectSelectorTask):
def get_master(self, system_name, invoc):
+ cursor = self.app.database.get_read_cursor()
+
cls = self.app.model.com_redhat_grid.Master
+ master = cls.get_object(cursor, System=system_name)
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
-
- try:
- master = cls.get_object(cursor, System=system_name)
- finally:
- conn.close()
-
if not master:
invoc.exception = Exception("Master daemon not running")
invoc.status = invoc.FAILED
Modified: mgmt/newdata/cumin/python/cumin/messaging/binding.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/messaging/binding.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/messaging/binding.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -22,23 +22,20 @@
def do_invoke(self, invoc, binding):
assert isinstance(binding, RosemaryObject)
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ cursor = self.app.database.get_read_cursor()
queue = None
exchange = None
+
try:
- try:
- cls = self.app.model.org_apache_qpid_broker.Queue
- queue = cls.get_object_by_id(cursor, binding._queueRef_id)
- cls = self.app.model.org_apache_qpid_broker.Exchange
- exchange = cls.get_object_by_id(cursor, binding._exchangeRef_id)
- except Exception, e:
- invoc.status = "failed"
- invoc.exception = e
- log.exception(e)
- finally:
- conn.close()
+ cls = self.app.model.org_apache_qpid_broker.Queue
+ queue = cls.get_object_by_id(cursor, binding._queueRef_id)
+ cls = self.app.model.org_apache_qpid_broker.Exchange
+ exchange = cls.get_object_by_id(cursor, binding._exchangeRef_id)
+ except Exception, e:
+ invoc.status = "failed"
+ invoc.exception = e
+ log.exception(e)
if queue and exchange:
session = self.app.model.get_session_by_object(binding)
@@ -95,23 +92,20 @@
def do_invoke(self, invoc, binding):
assert isinstance(binding, RosemaryObject)
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ cursor = self.app.database.get_read_cursor()
queue = None
exchange = None
+
try:
- try:
- cls = self.app.model.org_apache_qpid_broker.Queue
- queue = cls.get_object_by_id(cursor, binding._queueRef_id)
- cls = self.app.model.org_apache_qpid_broker.Exchange
- exchange = cls.get_object_by_id(cursor, binding._exchangeRef_id)
- except Exception, e:
- invoc.status = "failed"
- invoc.exception = e
- log.exception(e)
- finally:
- conn.close()
+ cls = self.app.model.org_apache_qpid_broker.Queue
+ queue = cls.get_object_by_id(cursor, binding._queueRef_id)
+ cls = self.app.model.org_apache_qpid_broker.Exchange
+ exchange = cls.get_object_by_id(cursor, binding._exchangeRef_id)
+ except Exception, e:
+ invoc.status = "failed"
+ invoc.exception = e
+ log.exception(e)
if queue and exchange:
session = self.app.model.get_session_by_object(binding)
Modified: mgmt/newdata/cumin/python/cumin/messaging/broker.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/messaging/broker.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/messaging/broker.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -368,16 +368,19 @@
def do_invoke(self, invoc, broker, groups):
conn = self.app.database.get_connection()
- cursor = conn.cursor()
- cls = self.app.model.com_redhat_cumin.BrokerGroup
- all_groups = cls.get_selection(cursor)
- selected_ids = [x._id for x in groups]
+ try:
+ cursor = conn.cursor()
- cls = self.app.model.com_redhat_cumin.BrokerGroupMapping
- try:
+ cls = self.app.model.com_redhat_cumin.BrokerGroup
+ all_groups = cls.get_selection(cursor)
+ selected_ids = [x._id for x in groups]
+
+ cls = self.app.model.com_redhat_cumin.BrokerGroupMapping
+
for group in all_groups:
- existing_mapping = cls.get_selection(cursor, _broker_id=broker._id, _group_id=group._id)
+ existing_mapping = cls.get_selection \
+ (cursor, _broker_id=broker._id, _group_id=group._id)
if not group._id in selected_ids:
if len(existing_mapping) > 0:
existing_mapping[0].delete(cursor)
@@ -388,9 +391,9 @@
new_mapping._group_id = group._id
new_mapping.fake_qmf_values()
new_mapping.save(cursor)
+
+ conn.commit()
finally:
- cursor.close()
+ conn.close()
- conn.commit()
-
invoc.end()
Modified: mgmt/newdata/cumin/python/cumin/messaging/brokergroup.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/messaging/brokergroup.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/messaging/brokergroup.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -40,15 +40,16 @@
def do_invoke(self, invoc, group):
conn = self.app.database.get_connection()
- cursor = conn.cursor()
try:
+ cursor = conn.cursor()
+
group.delete(cursor)
+
+ conn.commit()
finally:
- cursor.close()
+ conn.close()
- conn.commit()
-
invoc.end()
class BrokerGroupInputSet(CheckboxInputSet):
@@ -123,22 +124,23 @@
def do_invoke(self, invoc, obj, name, description):
conn = self.app.database.get_connection()
- cursor = conn.cursor()
- cls = self.app.model.com_redhat_cumin.BrokerGroup
- group = cls.create_object(cursor)
+ try:
+ cursor = conn.cursor()
- group.name = name
- group.description = description
- group.fake_qmf_values()
+ cls = self.app.model.com_redhat_cumin.BrokerGroup
+ group = cls.create_object(cursor)
- try:
+ group.name = name
+ group.description = description
+ group.fake_qmf_values()
+
group.save(cursor)
+
+ conn.commit()
finally:
- cursor.close()
+ conn.close()
- conn.commit()
-
invoc.description = "Add broker group '%s'" % name
invoc.end()
@@ -173,15 +175,16 @@
group.description = description
conn = self.app.database.get_connection()
- cursor = conn.cursor()
try:
+ cursor = conn.cursor()
+
group.save(cursor)
+
+ conn.commit()
finally:
- cursor.close()
+ conn.close()
- conn.commit()
-
invoc.end()
class BrokerGroupEditForm(BrokerGroupForm):
@@ -215,15 +218,16 @@
def do_invoke(self, invoc, group):
conn = self.app.database.get_connection()
- cursor = conn.cursor()
try:
+ cursor = conn.cursor()
+
group.delete(cursor)
+
+ conn.commit()
finally:
- cursor.close()
+ conn.close()
- conn.commit()
-
invoc.end()
class BrokerEngroup(ObjectFrameTask):
Modified: mgmt/newdata/cumin/python/cumin/messaging/brokerlink.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/messaging/brokerlink.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/messaging/brokerlink.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -355,19 +355,11 @@
def do_invoke(self, invoc, vhost, host, port, durable, username,
password, transport):
- # XXX ugh. need to pass session into do_invoke instead of
- # this
+ cursor = self.app.database.get_read_cursor()
cls = self.app.model.org_apache_qpid_broker.Broker
+ obj = cls.get_object(cursor, _id=vhost._brokerRef_id)
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
-
- try:
- obj = cls.get_object(cursor, _id=vhost._brokerRef_id)
- finally:
- cursor.close()
-
if username == "anonymous":
mech = "ANONYMOUS"
else:
Modified: mgmt/newdata/cumin/python/cumin/messaging/queue.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/messaging/queue.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/messaging/queue.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -598,13 +598,11 @@
return "Move messages"
def do_invoke(self, invoc, vhost, src, dst, count):
+ cursor = self.app.database.get_read_cursor()
+
cls = self.app.model.org_apache_qpid_broker.Broker
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
- try:
- broker = cls.get_object_by_id(cursor, vhost._brokerRef_id)
- finally:
- cursor.close()
+ broker = cls.get_object_by_id(cursor, vhost._brokerRef_id)
+
self.qmf_call(invoc, broker, "queueMoveMessages", src, dst, count)
class MoveQueueMessages(MoveMessagesBase):
Modified: mgmt/newdata/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/parameters.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/parameters.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -34,14 +34,9 @@
self.cls = cls
def do_unmarshal(self, string):
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ cursor = self.app.database.get_read_cursor()
+ return self.cls.get_object_by_id(cursor, int(string))
- try:
- return self.cls.get_object_by_id(cursor, int(string))
- finally:
- cursor.close()
-
def do_marshal(self, obj):
return str(obj._id)
@@ -86,13 +81,9 @@
id = int(string)
cls = self.app.model.com_redhat_cumin.BrokerGroup
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ cursor = self.app.database.get_read_cursor()
- try:
- return cls.get_object_by_id(cursor, id)
- finally:
- cursor.close()
+ return cls.get_object_by_id(cursor, id)
class BrokerParameter(Parameter):
def do_unmarshal(self, string):
Modified: mgmt/newdata/cumin/python/cumin/sqladapter.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/sqladapter.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/sqladapter.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -16,15 +16,11 @@
def get_count(self, values):
# XXX urgh. I want session in here
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ cursor = self.app.database.get_read_cursor()
- try:
- self.query.execute(cursor, values, columns=("count(1)",))
+ self.query.execute(cursor, values, columns=("count(1)",))
- return cursor.fetchone()[0]
- finally:
- cursor.close()
+ return cursor.fetchone()[0]
def get_sql_options(self, options):
sql_options = SqlQueryOptions()
@@ -41,17 +37,13 @@
def get_data(self, values, options):
sql_options = self.get_sql_options(options)
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ cursor = self.app.database.get_read_cursor()
- try:
- self.query.execute(cursor, values,
- columns=self.columns,
- options=sql_options)
+ self.query.execute(cursor, values,
+ columns=self.columns,
+ options=sql_options)
- return cursor.fetchall()
- finally:
- cursor.close()
+ return cursor.fetchall()
class SqlField(DataAdapterField):
def __init__(self, adapter, column):
Modified: mgmt/newdata/cumin/python/cumin/stat.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/stat.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/stat.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -528,14 +528,10 @@
rosemary_package = self.app.model._packages_by_name[rpackage]
rosemary_class = rosemary_package._classes_by_name[rclass]
- id = self.widget.id.get(session)
- conn = self.app.database.get_connection()
- cursor = conn.cursor()
+ id = self.widget.id.get(session)
+ cursor = self.app.database.get_read_cursor()
- try:
- obj = rosemary_class.get_object(cursor, _id=id)
- finally:
- cursor.close()
+ obj = rosemary_class.get_object(cursor, _id=id)
self.set(session, obj)
Modified: mgmt/newdata/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/widgets.py 2010-09-24 15:37:19 UTC (rev 4341)
+++ mgmt/newdata/cumin/python/cumin/widgets.py 2010-09-24 21:53:27 UTC (rev 4342)
@@ -26,7 +26,7 @@
class CuminSqlDataSet(SqlDataSet):
def get_connection(self, session):
- return self.app.database.get_connection()
+ return self.app.database.get_read_connection()
class CuminHeartBeat(Widget):
""" the intent is to add stuff here """
@@ -770,7 +770,7 @@
return super(CuminTable.Links, self).do_render(session)
def get_connection(self, session):
- return self.app.database.get_connection()
+ return self.app.database.get_read_connection()
def do_process(self, session, *args):
super(CuminTable, self).do_process(session, *args)
@@ -1342,22 +1342,8 @@
self.error_tmpl = WidgetTemplate(self, "error_html")
self.not_found_tmpl = WidgetTemplate(self, "not_found_html")
- def service(self, session):
- try:
- return super(CuminPage, self).service(session)
- except PageRedirect:
- raise
- except:
- conn = self.app.database.get_connection()
-
- if not conn.closed:
- conn.rollback()
-
- raise
-
def do_process(self, session):
- conn = self.app.database.get_connection()
- session.cursor = conn.cursor()
+ session.cursor = self.app.database.get_read_cursor()
if not self.authorized(session):
page = self.app.login_page
14 years, 5 months
rhmessaging commits: r4341 - mgmt/newdata/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: tmckay
Date: 2010-09-24 11:37:19 -0400 (Fri, 24 Sep 2010)
New Revision: 4341
Modified:
mgmt/newdata/cumin/python/cumin/config.py
Log:
Reverse the order in which cumin.conf files are parsed. This allows local cumin.conf files to override system wide files. Previously, users' local configurations would be overwritten by system wide configurations.
Modified: mgmt/newdata/cumin/python/cumin/config.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/config.py 2010-09-24 15:31:20 UTC (rev 4340)
+++ mgmt/newdata/cumin/python/cumin/config.py 2010-09-24 15:37:19 UTC (rev 4341)
@@ -47,9 +47,9 @@
def parse(self):
paths = list()
+ paths.append(os.path.join(os.sep, "etc", "cumin", "cumin.conf"))
+ paths.append(os.path.join(self.home, "etc", "cumin.conf"))
paths.append(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
- paths.append(os.path.join(self.home, "etc", "cumin.conf"))
- paths.append(os.path.join(os.sep, "etc", "cumin", "cumin.conf"))
return self.parse_files(paths)
14 years, 5 months
rhmessaging commits: r4340 - in mgmt/newdata/cumin/python/cumin: grid and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2010-09-24 11:31:20 -0400 (Fri, 24 Sep 2010)
New Revision: 4340
Modified:
mgmt/newdata/cumin/python/cumin/grid/negotiator.py
mgmt/newdata/cumin/python/cumin/grid/negotiator.strings
mgmt/newdata/cumin/python/cumin/model.py
Log:
Fix BZ 636618: Periodically update the quotas cache
Also Handle exceptions better.
- Missing Negotiator
- Agent not found
- Request timeout
Modified: mgmt/newdata/cumin/python/cumin/grid/negotiator.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/negotiator.py 2010-09-23 21:52:14 UTC (rev 4339)
+++ mgmt/newdata/cumin/python/cumin/grid/negotiator.py 2010-09-24 15:31:20 UTC (rev 4340)
@@ -86,8 +86,8 @@
def __init__(self, app, name, negotiator, frame):
super(NegotiatorOverview, self).__init__(app, name)
- self.update_enabled = False
- self.defer_enabled = True
+ self.update_enabled = True
+ #self.defer_enabled = True
self.group_helper = GroupHelper(app, "groups", negotiator)
self.add_child(self.group_helper)
@@ -112,6 +112,9 @@
col = self.SpacerColumn(app, "spacer")
self.add_column(col)
+ self.error_tmpl = WidgetTemplate(self, "error_html")
+ self.loading_tmpl = WidgetTemplate(self, "deferred_html")
+
def render_title(self, session):
return "Quotas"
@@ -121,6 +124,33 @@
def render_deferred_content(self, session):
return "Loading..."
+ def do_render(self, session):
+ tmpl = self.error_tmpl
+ msg = None
+
+ try:
+ info = self.group_helper.get_config_info(session)
+ except AssertionError:
+ msg = "Missing negotiator"
+ except Exception, e:
+ msg = e.message
+ if msg == "Loading":
+ tmpl = self.loading_tmpl
+ else:
+ log.exception(e)
+ else:
+ return super(NegotiatorOverview, self).do_render(session)
+
+ writer = Writer()
+ if "is unknown" in msg:
+ msg = "Please try again later"
+ err_msg = "The data is not available at this time. <br/>%s" % msg
+ tmpl.render(writer, session, err_msg)
+ return writer.to_string()
+
+ def render_error_msg(self, session, msg):
+ return msg
+
def do_get_items(self, session):
info = self.group_helper.get_config_info(session)
@@ -215,9 +245,12 @@
def render_content(self, session, group):
value = self.parent.group_helper.get_config_value(session, group, "GROUP_QUOTA_DYNAMIC")
self.task.form.group_leader.set(session, group)
- href = self.task.get_href(session)
- content = "%s%%" % str(round(float(value) * 100.0, 2))
- return fmt_link(href, content, "", "", self.fmt_hover(""))
+ if not "loading" in value:
+ href = self.task.get_href(session)
+ content = "%s%%" % str(round(float(value) * 100.0, 2))
+ return fmt_link(href, content, "", "", self.fmt_hover(""))
+ else:
+ return value
class SpacerColumn(ItemTableColumn):
def render_title(self, session, *args):
@@ -230,68 +263,44 @@
def __init__(self, app, name, negotiator):
super(GroupHelper, self).__init__(app, name)
- self.groups = self.GroupAttribute(app, "groups")
- self.add_attribute(self.groups)
-
- self.group_dyn_quotas = self.GroupAttribute(app, "group_dynamic_quotas")
- self.add_attribute(self.group_dyn_quotas)
-
- self.group_static_quotas = self.GroupAttribute(app, "group_static_quotas")
- self.add_attribute(self.group_static_quotas)
-
- self.group_autoregroups = self.GroupAttribute(app, "group_autoregroups")
- self.add_attribute(self.group_autoregroups)
-
- self.user_autoregroups = self.GroupAttribute(app, "user_autoregroups")
- self.add_attribute(self.user_autoregroups)
-
- self.autoregroup = self.GroupAttribute(app, "autoregroup")
- self.add_attribute(self.autoregroup)
-
- self.group_factors = self.GroupAttribute(app, "group_factors")
- self.add_attribute(self.group_factors)
-
- self.user_factors = self.GroupAttribute(app, "user_factors")
- self.add_attribute(self.user_factors)
-
self.negotiator = negotiator
- self.users = self.Users(app, "users")
- self.add_attribute(self.users)
+ self.info = Attribute(app, "info")
+ self.add_attribute(self.info)
def get_config_info(self, session):
negotiator = self.negotiator.get(session)
- try:
- info = self.app.model.configs_by_negotiator \
- [negotiator._qmf_agent_id]
- except KeyError:
- info = dict()
- if len(info) == 0:
- default = {'Value': None}
- action = QmfCall(self.app, default=default, timeout=10)
- results = action.execute(negotiator, "GetRawConfig", "GROUP_NAMES")
+ info = self.info.get(session)
+
+ if not info:
+ results = self.app.model.get_negotiator_group_names(negotiator)
groups = results.data
- try:
- groups = self.split_group_names(groups['Value'])
- except Exception, e:
- if not groups:
- groups = ""
- msg = "Unable to parse groups %s %s" % (groups, e.message)
- log.debug(msg)
- groups = []
- info = dict()
- for group in groups:
- info[group] = dict()
+ if not groups:
+ if (not results.status) and (not results.exception):
+ raise QmfException("Loading")
+ #results.exception = QmfException("Request timed out. Please refresh the page to try again.")
+ if results.exception:
+ raise results.exception
+ else:
+ try:
+ groups = self.split_group_names(groups)
+ except Exception, e:
+ log.exception(e)
+ groups = []
- self.app.model.configs_by_negotiator[negotiator._qmf_agent_id] = info
+ info = dict()
+ for group in groups:
+ info[group] = dict()
+ self.info.set(session, info)
+
return info
def has_child(self, session, group):
negotiator = self.negotiator.get(session)
- info = self.app.model.configs_by_negotiator[negotiator._qmf_agent_id]
+ info = self.get_config_info(session)
try:
return info[group]['has_child']
@@ -302,12 +311,12 @@
info[group]['has_child'] = True
break
- self.app.model.configs_by_negotiator[negotiator._qmf_agent_id] = info
+ self.info.set(session, info)
return info[group]['has_child']
def get_parent(self, session, group):
negotiator = self.negotiator.get(session)
- info = self.app.model.configs_by_negotiator[negotiator._qmf_agent_id]
+ info = self.get_config_info(session)
try:
return info[group]['parent']
@@ -320,12 +329,12 @@
info[group]['parent'] = parent
- self.app.model.configs_by_negotiator[negotiator._qmf_agent_id] = info
+ self.info.set(session, info)
return info[group]['parent']
def get_siblings(self, session, node):
negotiator = self.negotiator.get(session)
- info = self.app.model.configs_by_negotiator[negotiator._qmf_agent_id]
+ info = self.get_config_info(session)
siblings = list()
(ng, s, nn) = rpartition(node, ".")
@@ -352,63 +361,31 @@
if len(needed_groups) > 0:
negotiator = self.negotiator.get(session)
- action = FetchRawConfigSet(self.app)
- raw_configs = action.execute(negotiator, needed_groups, config+"_")
- for group in raw_configs:
- res = raw_configs[group]
- info[group][config] = res.data['Value']
+ results = self.app.model.get_negotiator_config_values(negotiator, needed_groups, config)
+ raw_configs = results.data
+ try:
+ for config in raw_configs:
+ for group in raw_configs[config]:
+ info[group][config] = raw_configs[config][group].data['Value']
+ except Exception, e:
+ log.exception(e)
+
+ self.info.set(session, info)
+ return info
+
def get_config_value(self, session, group, config):
info = self.get_config_info(session)
- return info[group][config]
+ try:
+ return info[group][config]
+ except KeyError:
+ try:
+ info = self.get_config_for_groups(session, config, [group])
+ return info[group][config]
+ except:
+ return "loading"
- def get_group_raw_config(self, session, config, param, groups=None):
- configs = param.get(session)
-
- if len(configs) == 0:
- if groups is None:
- groups = self.get_group_names(session)
- negotiator = self.negotiator.get(session)
- action = FetchRawConfigSet(self.app)
- raw_configs = action.execute(negotiator, groups, config)
-
- for group in sorted(raw_configs):
- res = raw_configs[group]
- configs.append([group, res.data['Value'],
- (res.status, res.error, res.got_data)])
-
- param.set(session, configs)
-
- return configs
-
- def get_static_quota(self, session):
- return self.get_group_raw_config(session,
- "GROUP_QUOTA_",
- self.group_static_quotas)
-
- def get_dyn_quota(self, session):
- return self.get_group_raw_config(session,
- "GROUP_QUOTA_DYNAMIC_",
- self.group_dyn_quotas)
-
- def get_priority_factor(self, session, groups=None, user=False):
- param = user and self.user_factors or self.group_factors
- return self.get_group_raw_config(session,
- "GROUP_PRIO_FACTOR_",
- param, groups)
-
- def get_regroups(self, session, groups=None, user=False):
- param = user and self.user_autoregroups or self.group_autoregroups
- return self.get_group_raw_config(session,
- "GROUP_AUTOREGROUP_",
- param, groups)
-
- def get_autoregroup(self, session):
- return self.get_group_raw_config(session,
- "GROUP_AUTOREGROUP",
- self.autoregroup, [""])
-
def get_unclaimed_dyn_quota(self, session, groups):
info = self.get_config_info(session)
total = 0.0
@@ -424,14 +401,6 @@
val = min(1.0, val)
return val
- class GroupAttribute(Attribute):
- def get_default(self, session):
- return list()
-
- class Users(Attribute):
- def get_default(self, session):
- return dict()
-
class GroupAddForm(ObjectFrameTaskForm):
def __init__(self, app, name, task):
super(GroupAddForm, self).__init__(app, name, task)
@@ -689,6 +658,8 @@
if changed:
self.task.reconfig(negotiator)
+ self.app.model.update_negotiator_config_value(negotiator)
+
self.task.exit_with_redirect(session)
def check_quota(self, quota, original):
@@ -937,6 +908,12 @@
raise result.error
invoc.status_code = invoc.status
+ try:
+ group = group.split("_")[-1]
+ invoc.description = "Set %s to %s" % (group, value)
+ except:
+ pass
+
invoc.end()
def reconfig(self, negotiator):
Modified: mgmt/newdata/cumin/python/cumin/grid/negotiator.strings
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/negotiator.strings 2010-09-23 21:52:14 UTC (rev 4339)
+++ mgmt/newdata/cumin/python/cumin/grid/negotiator.strings 2010-09-24 15:31:20 UTC (rev 4340)
@@ -41,6 +41,29 @@
</table>
</div>
+[NegotiatorOverview.deferred_html]
+<div id="{id}">
+ <div class="deferredSpacer">Loading...</div>
+</div>
+<script type="text/javascript">
+<![CDATA[
+(function() {
+ window.addEvent("domready", function () {
+ setTimeout( function () { window.location.reload(); }, 2000 );
+ });
+}())
+]]>
+</script>
+
+[NegotiatorOverview.error_html]
+<div id="{id}">
+ <div class="TaskInvocationSet">
+ <ul>
+ <li>{error_msg}</li>
+ </ul>
+ </div>
+</div>
+
[GroupForm.css]
div.deferredSpacer {
height: 10em;
Modified: mgmt/newdata/cumin/python/cumin/model.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/model.py 2010-09-23 21:52:14 UTC (rev 4339)
+++ mgmt/newdata/cumin/python/cumin/model.py 2010-09-24 15:31:20 UTC (rev 4340)
@@ -30,7 +30,8 @@
self.limits_by_negotiator = dict()
self.job_summaries_by_submission = dict()
- self.configs_by_negotiator = dict()
+ self.group_names_by_negotiator = dict()
+ self.group_config_values_by_negotiator = dict()
self.lock = Lock()
@@ -73,6 +74,63 @@
return session
+ def get_negotiator_group_names(self, negotiator):
+ assert negotiator
+
+ self.lock.acquire()
+
+ try:
+ try:
+ store = self.group_names_by_negotiator[negotiator._qmf_agent_id]
+ except KeyError:
+ store = NegotiatorGroupNamesStore(self, negotiator)
+ store.start_updates()
+
+ self.group_names_by_negotiator[negotiator._qmf_agent_id] = store
+ #sleep(1)
+
+ return store
+ finally:
+ self.lock.release()
+
+ def get_negotiator_config_values(self, negotiator, needed_groups, config):
+ assert negotiator
+
+ self.lock.acquire()
+
+ try:
+ try:
+ store = self.group_config_values_by_negotiator[negotiator._qmf_agent_id]
+ added = 0
+ for group in needed_groups:
+ added += store.add_group_config(group, config)
+ if added > 0:
+ store.update(None)
+ sleep(1)
+ except KeyError:
+ store = NegotiatorGroupConfigValuesStore(self, negotiator, needed_groups, config)
+ store.start_updates()
+
+ self.group_config_values_by_negotiator[negotiator._qmf_agent_id] = store
+
+ sleep(1)
+
+ return store
+ finally:
+ self.lock.release()
+
+ def update_negotiator_config_value(self, negotiator):
+ assert negotiator
+
+ self.lock.acquire()
+
+ try:
+ store = self.group_config_values_by_negotiator[negotiator._qmf_agent_id]
+ store.update(None)
+ sleep(1)
+ finally:
+ self.lock.release()
+
def get_negotiator_limits(self, negotiator):
assert negotiator
@@ -1720,6 +1778,7 @@
session.call_method(self.get_completion(), job_server, "Fetch", (jobId, file, start, end))
except Exception, e:
self.error = e
+ log.exception(e)
return self.do_wait()
class CuminScheduler(RemoteClass):
@@ -2054,3 +2113,60 @@
del self.model.job_summaries_by_submission[self.submission._id]
super(SubmissionJobSummaryStore, self).delete()
+
+class NegotiatorGroupNamesStore(ObjectStore):
+ def __init__(self, model, negotiator):
+ super(NegotiatorGroupNamesStore, self).__init__(model)
+
+ self.negotiator = negotiator
+
+ def update(self, cursor):
+ def completion(status, data):
+ self.status = status
+ try:
+ self.data = data["Value"]
+ except KeyError:
+ pass
+
+ self.model.app.session.call_method \
+ (completion, self.negotiator, "GetRawConfig", ("GROUP_NAMES",))
+
+ def delete(self):
+ del self.model.group_names_by_negotiator[self.negotiator._qmf_agent_id]
+
+ super(NegotiatorGroupNamesStore, self).delete()
+
+class NegotiatorGroupConfigValuesStore(ObjectStore):
+ def __init__(self, model, negotiator, groups, config):
+ super(NegotiatorGroupConfigValuesStore, self).__init__(model)
+
+ self.negotiator = negotiator
+ self.configs = dict()
+
+ self.configs[config] = list(groups)
+ self.data = dict()
+
+ def add_group_config(self, group, config):
+ added = 0
+
+ try:
+ groups = self.configs[config]
+ if not group in groups:
+ groups.append(group)
+ added = 1
+ except KeyError:
+ self.configs[config] = [group]
+ added = 1
+
+ return added
+
+ def update(self, cursor):
+ for config in self.configs:
+ action = FetchRawConfigSet(self.model.app)
+ raw_configs = action.execute(self.negotiator, self.configs[config], config+"_")
+ self.data[config] = raw_configs
+
+ def delete(self):
+ del self.model.group_config_values_by_negotiator[self.negotiator._qmf_agent_id]
+
+ super(NegotiatorGroupConfigValuesStore, self).delete()
14 years, 5 months
rhmessaging commits: r4339 - mgmt/newdata/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-09-23 17:52:14 -0400 (Thu, 23 Sep 2010)
New Revision: 4339
Modified:
mgmt/newdata/cumin/python/cumin/widgets.py
mgmt/newdata/cumin/python/cumin/widgets.strings
Log:
For bz 622506, make error output cuminly
Modified: mgmt/newdata/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/widgets.py 2010-09-23 20:48:59 UTC (rev 4338)
+++ mgmt/newdata/cumin/python/cumin/widgets.py 2010-09-23 21:52:14 UTC (rev 4339)
@@ -1339,6 +1339,9 @@
self.user = UserAttribute(app, "user")
self.add_attribute(self.user)
+ self.error_tmpl = WidgetTemplate(self, "error_html")
+ self.not_found_tmpl = WidgetTemplate(self, "not_found_html")
+
def service(self, session):
try:
return super(CuminPage, self).service(session)
@@ -1393,6 +1396,21 @@
return False
+ def render_error(self, session):
+ cls, value, traceback = sys.exc_info()
+
+ writer = Writer()
+
+ if cls is RosemaryNotFound:
+ self.not_found_tmpl.render(writer, session)
+ else:
+ self.error_tmpl.render(writer, session)
+
+ return writer.to_string()
+
+ def render_error_dump(self, session):
+ return self.error.get(session).render()
+
class CuminFormPage(CuminPage):
def __init__(self, app, name):
super(CuminFormPage, self).__init__(app, name)
Modified: mgmt/newdata/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/newdata/cumin/python/cumin/widgets.strings 2010-09-23 20:48:59 UTC (rev 4338)
+++ mgmt/newdata/cumin/python/cumin/widgets.strings 2010-09-23 21:52:14 UTC (rev 4339)
@@ -165,8 +165,6 @@
<div id="body">
{tasks}
- <div id="messages" style="display: none;"><p title="close" onclick="cumin.hideActions()">x</p>{actions}</div>
-
{heartbeat}
{content}
@@ -174,6 +172,32 @@
<div id="foot"/>
+[CuminPage.error_html]
+<div id="body">
+ <h1 style="margin: 0.5em 0 1em 0;">An error!</h1>
+
+ <p>Something unexpected happened. Please report this problem
+ at <a href="http://bugzilla.redhat.com">bugzilla.redhat.com</a>
+ under the
+ <a href="https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Enterprise%...">Red Hat Enterprise MRG product</a>.</p>
+
+ <p><a onclick="$('error').setStyle('display', 'inline')">See the
+ details</a>. Please include this in any bugs filed.</p>
+
+ <div id="error" style="display: none;">
+ {error_dump}
+ </div>
+</div>
+
+[CuminPage.not_found_html]
+<div id="body">
+ <h1 style="margin: 0.5em 0 1em 0;">We can't find the object you requested</h1>
+
+ <p>This often happens when a far-off agent stops or is disconnected.
+ It may come back under a different database ID. Try navigating anew
+ from the <a href="/index.html">site root</a>.</p>
+</div>
+
[CuminPageLinks.css]
ul.CuminPageLinks {
padding: 0;
14 years, 5 months
rhmessaging commits: r4338 - mgmt/newdata/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-09-23 16:48:59 -0400 (Thu, 23 Sep 2010)
New Revision: 4338
Modified:
mgmt/newdata/cumin/python/cumin/model.py
Log:
For bz 636818, repair the obviously broken logic for looking up broker sessions
Modified: mgmt/newdata/cumin/python/cumin/model.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/model.py 2010-09-23 19:52:53 UTC (rev 4337)
+++ mgmt/newdata/cumin/python/cumin/model.py 2010-09-23 20:48:59 UTC (rev 4338)
@@ -66,9 +66,13 @@
def show_main(self, session):
return self.app.main_page.main.show(session)
- def get_session_by_object(self, object):
- return self.app.session.qmf_brokers[0].getAmqpSession()
+ def get_session_by_object(self, obj):
+ agent = self.app.session.get_agent(obj._qmf_agent_id)
+ broker = agent.getBroker()
+ session = broker.getAmqpSession()
+ return session
+
def get_negotiator_limits(self, negotiator):
assert negotiator
14 years, 5 months