r4561 - trunk/cumin/python/cumin/grid
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-28 19:36:14 +0000 (Mon, 28 Feb 2011)
New Revision: 4561
Modified:
trunk/cumin/python/cumin/grid/negotiator.py
trunk/cumin/python/cumin/grid/scheduler.py
trunk/cumin/python/cumin/grid/slot.py
trunk/cumin/python/cumin/grid/slot.strings
Log:
Remove the checkboxes from some tables that don't need them
Modified: trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.py 2011-02-25 20:10:28 UTC (rev 4560)
+++ trunk/cumin/python/cumin/grid/negotiator.py 2011-02-28 19:36:14 UTC (rev 4561)
@@ -3,7 +3,7 @@
from cumin.objectframe import ObjectFrame, ObjectFrameTask,\
ObjectFrameTaskFeedbackForm
from cumin.objectselector import ObjectSelector, ObjectLinkColumn,\
- MonitorSelfStatColumn
+ MonitorSelfStatColumn, ObjectTable
from wooly import Widget, Attribute, Parameter
from parsley.stringex import rpartition
from cumin.parameters import RosemaryObjectParameter
@@ -53,6 +53,11 @@
self.enable_csv_export(pool)
+ def create_table(self, app, name, cls):
+ # avoid the checkboxes
+ return ObjectTable(app, name, cls)
+
+
class GroupHelper(Widget):
def __init__(self, app, name, negotiator):
super(GroupHelper, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/grid/scheduler.py
===================================================================
--- trunk/cumin/python/cumin/grid/scheduler.py 2011-02-25 20:10:28 UTC (rev 4560)
+++ trunk/cumin/python/cumin/grid/scheduler.py 2011-02-28 19:36:14 UTC (rev 4561)
@@ -106,6 +106,10 @@
self.enable_csv_export(pool)
+ def create_table(self, app, name, cls):
+ # avoid the checkboxes
+ return ObjectTable(app, name, cls)
+
class SchedulerGeneralStatSet(StatSet):
def __init__(self, app, name, object):
super(SchedulerGeneralStatSet, self).__init__(app, name, object)
Modified: trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- trunk/cumin/python/cumin/grid/slot.py 2011-02-25 20:10:28 UTC (rev 4560)
+++ trunk/cumin/python/cumin/grid/slot.py 2011-02-28 19:36:14 UTC (rev 4561)
@@ -35,6 +35,10 @@
self.enable_csv_export(pool)
+ def create_table(self, app, name, cls):
+ # avoid the checkboxes
+ return ObjectTable(app, name, cls)
+
class SlotFrame(ObjectFrame):
def __init__(self, app, name):
cls = app.model.com_redhat_grid.Slot
@@ -336,6 +340,7 @@
el = Element()
el.name = "slot_info"
el.category = category_group
+ el.category_group = category_group
el.count = category_groups[category_group]["_count"]
el.value = "%s.%s" % (records[plist[0]][groups[level-1]], category_group) # uid
level_list.append(el)
Modified: trunk/cumin/python/cumin/grid/slot.strings
===================================================================
--- trunk/cumin/python/cumin/grid/slot.strings 2011-02-25 20:10:28 UTC (rev 4560)
+++ trunk/cumin/python/cumin/grid/slot.strings 2011-02-28 19:36:14 UTC (rev 4561)
@@ -409,14 +409,14 @@
</div>
[SlotLegend.item_html]
- <dt>{category}</dt>
+ <dt onmouseover="vis_treemap_over('category_group', '{category}')" onmouseout="vis_treemap_out('category_group', '{category}')">{category}</dt>
{category_items}
[SlotCategories.html]
{items}
[SlotCategories.item_html]
-<dd onmouseover="vis_treemap_over('{item_title}')" onmouseout="vis_treemap_out('{item_title}')">
+<dd onmouseover="vis_treemap_over('category', '{item_title}')" onmouseout="vis_treemap_out('category', '{item_title}')">
<img src="{item_href}" width="{item_size}" height="{item_size}" title="{item_title}" alt="{item_title}"/>
{item_title}
13 years, 1 month
r4560 - trunk/cumin/bin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-25 20:10:28 +0000 (Fri, 25 Feb 2011)
New Revision: 4560
Modified:
trunk/cumin/bin/cumin-admin
Log:
Add export-users and import-users commands to cumin-admin.
BZ680260
Modified: trunk/cumin/bin/cumin-admin
===================================================================
--- trunk/cumin/bin/cumin-admin 2011-02-25 14:24:52 UTC (rev 4559)
+++ trunk/cumin/bin/cumin-admin 2011-02-25 20:10:28 UTC (rev 4560)
@@ -2,6 +2,7 @@
import os
import sys
+import csv
from psycopg2 import IntegrityError
@@ -70,6 +71,9 @@
finally:
cursor.close()
+def warn(msg):
+ print "Warning: %s" % msg
+
def error(msg):
print "Error: %s" % msg
sys.exit(1)
@@ -88,6 +92,8 @@
lines.append(" change-password USER Change USER's password")
lines.append(" list-users List users")
lines.append(" list-roles List roles")
+ lines.append(" export-users FILE Export user list to file")
+ lines.append(" import-users FILE Import user list from file")
lines.append("")
lines.append("Schema commands:")
lines.append("")
@@ -119,7 +125,7 @@
print "The schema is dropped"
-def handle_list_users(app, cursor, opts, args):
+def get_users(app, cursor):
user_cls = app.model.com_redhat_cumin.User
role_cls = app.model.com_redhat_cumin.Role
mapping_cls = app.model.com_redhat_cumin.UserRoleMapping
@@ -143,9 +149,15 @@
for id, name in cursor.fetchall():
roles_by_user_id[id].append(name)
+ return users, roles_by_user_id
+
+def handle_list_users(app, cursor, opts, args):
+
print " ID Name Roles"
print "---- -------------------- --------------------"
+ users, roles_by_user_id = get_users(app, cursor)
+
for user in users:
try:
roles = ", ".join(roles_by_user_id[user._id])
@@ -183,6 +195,80 @@
print "User '%s' is added" % name
+def handle_export_users(app, cursor, opts, args):
+
+ try:
+ fname = args[0]
+ except IndexError:
+ error("Export file name is required")
+
+ try:
+ f = open(fname,"wb")
+ except:
+ error("Failed to open file " + fname)
+
+ users, roles_by_user_id = get_users(app, cursor)
+
+ w = csv.writer(f)
+ for user in users:
+ w.writerow([user.name, user.password] + roles_by_user_id[user._id])
+
+def handle_import_users(app, cursor, opts, args):
+
+ try:
+ fname = args[0]
+ except IndexError:
+ error("Import file name is required")
+
+ try:
+ f = open(fname,"rb")
+ except:
+ error("Failed to open file " + fname)
+
+ user_data = csv.reader(f)
+
+ # Before we make any changes, check the format to be nice
+ line = 0
+ for info in user_data:
+ line += 1
+
+ for field in info:
+ # Don't suppose it's possible for data to be anything other than
+ # strings from csv, but this is where such type checking goes
+ if type(field) != str:
+ error("Data error, line %u, fields must be strings" % line)
+ if len(field) == 0:
+ error("Data error, line %u, importer "\
+ "does not allow empty fields" % line)
+
+ if len(info) < 2:
+ error("Data error, line %u, not enough fields. "\
+ " User and password are required" % (line))
+
+ # Reset the reader
+ f.seek(0)
+ for info in user_data:
+ #name, password, [role, ...]
+ if app.admin.get_user(cursor, info[0]):
+ # Well, we might be extending an existing user database
+ # and there *might* be overlap between the two. Check first
+ # before we get an integrity error
+ warn("A user called '%s' already exists, skipping" % info[0])
+ continue
+
+ try:
+ user = app.admin.add_user(cursor, info[0], info[1])
+ except IntegrityError:
+ error("Unable to add user")
+
+ for role_name in info[2:]:
+ role = app.admin.get_role(cursor, role_name)
+ if role != None:
+ app.admin.add_assignment(cursor, user, role)
+ else:
+ warn("Role '%s' does not exist, "\
+ "skipping this role for user '%s'" % (role_name, info[0]))
+
def handle_remove_user(app, cursor, opts, args):
try:
name = args[0]
13 years, 1 month
r4559 - trunk/cumin/bin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-25 14:24:52 +0000 (Fri, 25 Feb 2011)
New Revision: 4559
Modified:
trunk/cumin/bin/cumin
Log:
Tweak master.log output for --init-only.
Indent content from subprocess, record any stderr output on success, too, not just failure.
Modified: trunk/cumin/bin/cumin
===================================================================
--- trunk/cumin/bin/cumin 2011-02-24 20:52:13 UTC (rev 4558)
+++ trunk/cumin/bin/cumin 2011-02-25 14:24:52 UTC (rev 4559)
@@ -125,12 +125,17 @@
arg = [app[PROGRAM], "--init-only", "--section=" + app[SECTION]]
app[PROCESS] = subprocess.Popen(arg, stderr=subprocess.PIPE)
errors = app[PROCESS].communicate()[1]
- if app[PROCESS].wait() != 0:
- msg = "Subprocess failed:" + "".join([" "+x for x in arg])
- if len(errors) > 0:
- msg += "\n" + errors
- log.error(msg)
- return 1
+ # Indent any output we received
+ if len(errors) > 0:
+ errors = "\n " + errors.replace("\n","\n ")
+ result = app[PROCESS].wait()
+ if len(errors) > 0 or result != 0:
+ msg = "".join([" "+x for x in arg]) + errors
+ if result != 0:
+ log.error("Subprocess failed:" + msg)
+ else:
+ log.info("Subprocess output:" + msg)
+ return result
else:
# Launch and babysit
try:
13 years, 1 month
r4558 - trunk/cumin/bin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-24 20:52:13 +0000 (Thu, 24 Feb 2011)
New Revision: 4558
Modified:
trunk/cumin/bin/cumin
Log:
Resubmit 4557 with blank line removed.
BZ number in comment is wrong. Since I do not have access to
the svn server and can't change properties, I can't undo the
comment.
BZ680265
Modified: trunk/cumin/bin/cumin
===================================================================
--- trunk/cumin/bin/cumin 2011-02-24 20:44:18 UTC (rev 4557)
+++ trunk/cumin/bin/cumin 2011-02-24 20:52:13 UTC (rev 4558)
@@ -1,5 +1,4 @@
#!/usr/bin/python
-
from optparse import OptionParser
from time import sleep
import subprocess
13 years, 1 month
r4557 - trunk/cumin/bin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-24 20:44:18 +0000 (Thu, 24 Feb 2011)
New Revision: 4557
Modified:
trunk/cumin/bin/cumin
Log:
Provide options for cumin master script to control stdin, stderr, and stdout
for operation as a daemon or operation as a standard app.
BZ680625
Modified: trunk/cumin/bin/cumin
===================================================================
--- trunk/cumin/bin/cumin 2011-02-24 18:37:10 UTC (rev 4556)
+++ trunk/cumin/bin/cumin 2011-02-24 20:44:18 UTC (rev 4557)
@@ -36,22 +36,22 @@
break
msg += t
r.close()
- if msg:
+ if len(msg) > 0:
msg = "\n"+msg
- log.error("Error in options"+msg)
+ log.error("Error in options"+msg)
+ return True
def main():
-
+
# tuple indices, for clarity
PROCESS = 0
SECTION = 1
PROGRAM = 2
- enable_logging("cumin.master", logging.INFO, os.path.join(home, "log", "master.log"))
-
parser = OptionParser()
- parser.add_option("--init-only", dest="init_only", action="store_true", default=False)
+ parser.add_option("--init-only", dest="init_only", action="store_true", default=False,
+ help="Check options and initialization, then return.")
parser.add_option("--webs", dest="webs", default="web",
help="Configuration section names for cumin-web instances."\
@@ -61,24 +61,50 @@
help="Configuration section names for cumin-data instances."\
"\nEach value implies a separate cumin-data instance.")
+ parser.add_option("--console", dest="console", action="store_true", default=False,
+ help="Do not redirect stderr or stdout, and log to stderr.")
+
+ parser.add_option("--devel", dest="devel", action="store_true", default=False,
+ help="Option is ignored if --console is set."\
+ "\nRedirect stderr and stdout to files in "\
+ "$CUMIN_HOME/log if set and to /dev/null if not set.")
+
# Trap exit from parser and save standard error for logging
# Then put stderr back to original value
- err = sys.stderr
r, w = os.pipe()
sys.stderr = os.fdopen(w,"w")
try:
(options, args) = parser.parse_args()
except:
- parse_errors = True
- else:
- parse_errors = False
+ options = args = None
sys.stderr.close()
- sys.stderr = err
+ sys.stderr = sys.__stderr__
- if parse_errors:
- log_parse_errors(r)
- return 1
+ # Parse may have failed, in which case make a quick check for options ourselves
+ if options != None:
+ console = options.console
+ devel = options.devel
+ else:
+ console = "--console" in sys.argv[1:]
+ devel = "--devel" in sys.argv[1:]
+ # Set up logging and IO before we go any further
+ new_stdout = new_stderr = new_stdin = None
+ if console:
+ enable_logging("cumin.master", logging.INFO, sys.stderr)
+ else:
+ enable_logging("cumin.master", logging.INFO, os.path.join(home, "log", "master.log"))
+ new_stdin = open(os.devnull,"r")
+ if devel:
+ new_stderr = open(os.path.join(home, "log", "master.stderr"), "a")
+ new_stdout = open(os.path.join(home, "log", "master.stdout"), "a")
+ else:
+ new_stderr = new_stdout = open(os.devnull,"w")
+
+ # Parser exited, either on --help or with errors
+ if options == None:
+ return log_parse_errors(r)
+
if len(args) != 0:
log.error("Extra arguments:" + "".join([" "+arg for arg in args]))
return 1
@@ -118,9 +144,11 @@
log.warn("Restarting:" + prog_string)
else:
log.info("Starting:" + prog_string)
- app[PROCESS] = subprocess.Popen(arg)
+ app[PROCESS] = subprocess.Popen(arg,
+ stderr=new_stderr,
+ stdout=new_stdout)
sleep(30)
-
+
finally:
for app in apps:
if app[PROCESS]:
13 years, 1 month
r4556 - trunk/cumin/python/cumin/grid
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-24 18:37:10 +0000 (Thu, 24 Feb 2011)
New Revision: 4556
Modified:
trunk/cumin/python/cumin/grid/slot.strings
Log:
Tweak the slot legend css.
Modified: trunk/cumin/python/cumin/grid/slot.strings
===================================================================
--- trunk/cumin/python/cumin/grid/slot.strings 2011-02-24 18:30:08 UTC (rev 4555)
+++ trunk/cumin/python/cumin/grid/slot.strings 2011-02-24 18:37:10 UTC (rev 4556)
@@ -375,6 +375,8 @@
div.SlotLegend dl {
margin: auto;
padding: 0;
+ position: relative;
+ top: -0.5em;
}
div.SlotLegend dt {
margin: 0;
13 years, 1 month
r4555 - trunk/cumin/python/cumin/grid
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-24 18:30:08 +0000 (Thu, 24 Feb 2011)
New Revision: 4555
Modified:
trunk/cumin/python/cumin/grid/pool.strings
trunk/cumin/python/cumin/grid/slot.strings
Log:
Fix mouseover highlight on slot legend.
Modified: trunk/cumin/python/cumin/grid/pool.strings
===================================================================
--- trunk/cumin/python/cumin/grid/pool.strings 2011-02-23 16:37:20 UTC (rev 4554)
+++ trunk/cumin/python/cumin/grid/pool.strings 2011-02-24 18:30:08 UTC (rev 4555)
@@ -95,18 +95,18 @@
chart.src = branch.marshal();
updatePoolSlotVis("{id}", "load");
}
- function vis_treemap_over(type, value) {
+ function vis_treemap_over(value) {
var chart = cumin.getFlashChart("{id}");
if (chart) {
if (typeof chart.highlight != "undefined")
- chart.highlight(type, value);
+ chart.highlight("category", value);
}
}
- function vis_treemap_out(type, value) {
+ function vis_treemap_out(value) {
var chart = cumin.getFlashChart("{id}");
if (chart) {
if (typeof chart.lowlight != "undefined")
- chart.lowlight(type, value);
+ chart.lowlight("category", value);
}
}
function slot_vis(state, a, id, href) {
Modified: trunk/cumin/python/cumin/grid/slot.strings
===================================================================
--- trunk/cumin/python/cumin/grid/slot.strings 2011-02-23 16:37:20 UTC (rev 4554)
+++ trunk/cumin/python/cumin/grid/slot.strings 2011-02-24 18:30:08 UTC (rev 4555)
@@ -370,7 +370,7 @@
}
div.SlotLegend {
margin: 0 0 0 8em;
- width: 11em;
+ width: 12em;
}
div.SlotLegend dl {
margin: auto;
@@ -419,10 +419,3 @@
{item_title}
</dd>
-
-[SlotActivities.item_html]
-<li onmouseover="vis_treemap_over('activity', '{item_title}')" onmouseout="vis_treemap_out('activity', '{item_title}')">
- <img src="{item_href}" width="{item_size}" height="{item_size}" title="{item_title}" alt="{item_title}"/>
-
- {item_title}
-</li>
13 years, 1 month
r4554 - trunk/parsley/python/parsley
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-23 16:37:20 +0000 (Wed, 23 Feb 2011)
New Revision: 4554
Modified:
trunk/parsley/python/parsley/collectionsex.py
Log:
Replace implementation of defaultdict for Python 2.4
Modified: trunk/parsley/python/parsley/collectionsex.py
===================================================================
--- trunk/parsley/python/parsley/collectionsex.py 2011-02-22 20:28:38 UTC (rev 4553)
+++ trunk/parsley/python/parsley/collectionsex.py 2011-02-23 16:37:20 UTC (rev 4554)
@@ -1,19 +1,39 @@
try:
from collections import defaultdict
-except ImportError:
+except:
class defaultdict(dict):
- def __init__(self, default_factory=None):
- super(dict, self).__init__()
-
+ def __init__(self, default_factory=None, *a, **kw):
+ if (default_factory is not None and
+ not hasattr(default_factory, '__call__')):
+ raise TypeError('first argument must be callable')
+ dict.__init__(self, *a, **kw)
self.default_factory = default_factory
-
def __getitem__(self, key):
try:
- dict.__getitem__(self, key)
+ return dict.__getitem__(self, key)
except KeyError:
- if self.default_factory is None:
- raise
- else:
- return self.default_factory()
+ return self.__missing__(key)
+ def __missing__(self, key):
+ if self.default_factory is None:
+ raise KeyError(key)
+ self[key] = value = self.default_factory()
+ return value
+ def __reduce__(self):
+ if self.default_factory is None:
+ args = tuple()
+ else:
+ args = self.default_factory,
+ return type(self), args, None, None, self.items()
+ def copy(self):
+ return self.__copy__()
+ def __copy__(self):
+ return type(self)(self.default_factory, self)
+ def __deepcopy__(self, memo):
+ import copy
+ return type(self)(self.default_factory,
+ copy.deepcopy(self.items()))
+ def __repr__(self):
+ return 'defaultdict(%s, %s)' % (self.default_factory,
+ dict.__repr__(self))
from collections import *
13 years, 1 month
r4553 - in trunk/cumin: python/cumin/grid resources
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-22 20:28:38 +0000 (Tue, 22 Feb 2011)
New Revision: 4553
Modified:
trunk/cumin/python/cumin/grid/slot.strings
trunk/cumin/resources/shade.png
trunk/cumin/resources/shade1.png
Log:
A more prettier version of the slot legend
Modified: trunk/cumin/python/cumin/grid/slot.strings
===================================================================
--- trunk/cumin/python/cumin/grid/slot.strings 2011-02-22 19:41:54 UTC (rev 4552)
+++ trunk/cumin/python/cumin/grid/slot.strings 2011-02-22 20:28:38 UTC (rev 4553)
@@ -365,12 +365,11 @@
</tr>
[SlotLegend.css]
+div.SlotLegend div.slot_container {
+ background-image: url(resource?name=shade1.png);
+}
div.SlotLegend {
- -moz-border-radius: 0.5em;
- background-color: #FCFCCC;
- border: 1px solid #BABA00;
margin: 0 0 0 8em;
- padding: 0 0 1em 2em;
width: 11em;
}
div.SlotLegend dl {
@@ -394,9 +393,17 @@
[SlotLegend.html]
<div id="{id}" class="{class}">
- <dl>
- {items}
- </dl>
+ <div class="outerpair1" id="{id}">
+ <div class="outerpair2">
+ <div class="shadowbox">
+ <div class="innerbox slot_container">
+ <dl>
+ {items}
+ </dl>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
[SlotLegend.item_html]
Modified: trunk/cumin/resources/shade.png
===================================================================
(Binary files differ)
Modified: trunk/cumin/resources/shade1.png
===================================================================
(Binary files differ)
13 years, 2 months
r4552 - trunk/cumin/etc
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-22 19:41:54 +0000 (Tue, 22 Feb 2011)
New Revision: 4552
Modified:
trunk/cumin/etc/cumin.conf
Log:
Add comments with defaults for log-max-mb and log-max-archives
Modified: trunk/cumin/etc/cumin.conf
===================================================================
--- trunk/cumin/etc/cumin.conf 2011-02-22 19:11:15 UTC (rev 4551)
+++ trunk/cumin/etc/cumin.conf 2011-02-22 19:41:54 UTC (rev 4552)
@@ -4,6 +4,8 @@
# database: dbname=cumin user=cumin host=localhost
# brokers: localhost:5672
# log-level: info
+# log-max-mb: 10
+# log-max-archives: 1
[web]
# log-file: $CUMIN_HOME/log/web.log
13 years, 2 months