Author: justi9
Date: 2009-07-02 11:40:22 -0400 (Thu, 02 Jul 2009)
New Revision: 3473
Added:
mgmt/trunk/cumin/python/cumin/config.py
mgmt/trunk/cumin/python/cumin/main.py
mgmt/trunk/cumin/python/cumin/main.strings
mgmt/trunk/cumin/python/cumin/server.py
Removed:
mgmt/trunk/cumin/python/cumin/modelwidgets.py
mgmt/trunk/cumin/python/cumin/modelwidgets.strings
mgmt/trunk/cumin/python/cumin/page.py
mgmt/trunk/cumin/python/cumin/page.strings
Modified:
mgmt/trunk/cumin/metadata/model.xml
mgmt/trunk/cumin/python/cumin/__init__.py
mgmt/trunk/cumin/python/cumin/account/main.py
mgmt/trunk/cumin/python/cumin/account/model.py
mgmt/trunk/cumin/python/cumin/account/user.py
mgmt/trunk/cumin/python/cumin/grid/collector.py
mgmt/trunk/cumin/python/cumin/grid/job.py
mgmt/trunk/cumin/python/cumin/grid/job.strings
mgmt/trunk/cumin/python/cumin/grid/limit.py
mgmt/trunk/cumin/python/cumin/grid/main.py
mgmt/trunk/cumin/python/cumin/grid/model.py
mgmt/trunk/cumin/python/cumin/grid/negotiator.py
mgmt/trunk/cumin/python/cumin/grid/pool.py
mgmt/trunk/cumin/python/cumin/grid/pool.strings
mgmt/trunk/cumin/python/cumin/grid/scheduler.py
mgmt/trunk/cumin/python/cumin/grid/slot.py
mgmt/trunk/cumin/python/cumin/grid/submission.py
mgmt/trunk/cumin/python/cumin/grid/submission.strings
mgmt/trunk/cumin/python/cumin/grid/submitter.py
mgmt/trunk/cumin/python/cumin/inventory/system.py
mgmt/trunk/cumin/python/cumin/inventory/system.strings
mgmt/trunk/cumin/python/cumin/managementserver.py
mgmt/trunk/cumin/python/cumin/messaging/binding.py
mgmt/trunk/cumin/python/cumin/messaging/broker.py
mgmt/trunk/cumin/python/cumin/messaging/broker.strings
mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py
mgmt/trunk/cumin/python/cumin/messaging/connection.py
mgmt/trunk/cumin/python/cumin/messaging/exchange.py
mgmt/trunk/cumin/python/cumin/messaging/main.py
mgmt/trunk/cumin/python/cumin/messaging/model.py
mgmt/trunk/cumin/python/cumin/messaging/queue.py
mgmt/trunk/cumin/python/cumin/messaging/queue.strings
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/parameters.py
mgmt/trunk/cumin/python/cumin/tools.py
mgmt/trunk/cumin/python/cumin/usergrid/main.py
mgmt/trunk/cumin/python/cumin/usergrid/submission.py
mgmt/trunk/cumin/python/cumin/widgets.py
mgmt/trunk/cumin/python/cumin/widgets.strings
mgmt/trunk/rosemary/python/rosemary/model.py
Log:
* Add CuminSubmission to the ui metadata
* Add Submission views
* Implement submission add
* Move submitters under the scheduler frame
* Make the first tab the user sees simply the overview
* Remove some duplicate code from previous merges
* Repair task defs, which now take session
* Remove the last vestiges of old-style status boxes
* Move cumin app code out of __init__.py and into main.py
* Add methods to rosemary model for extending the base qmf metadata
* Move CuminServer and CuminConfig to their own files, server.py and
config.py respectively
* Factor more of the actions out of the old model and into the new
tasks
* Remove modelwidgets.py, and move remaining widgets to widgets.py
* Move some more classes to widgets.py
Modified: mgmt/trunk/cumin/metadata/model.xml
===================================================================
--- mgmt/trunk/cumin/metadata/model.xml 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/metadata/model.xml 2009-07-02 15:40:22 UTC (rev 3473)
@@ -7,21 +7,3 @@
</class>
</package>
</model>
-<model>
- <package name="org.apache.qpid.broker">
- <class name="System">
- <property name="systemId">
- <title>System ID</title>
- </property>
- </class>
- </package>
-</model>
-<model>
- <package name="org.apache.qpid.broker">
- <class name="System">
- <property name="systemId">
- <title>System ID</title>
- </property>
- </class>
- </package>
-</model>
Modified: mgmt/trunk/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/__init__.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/__init__.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,199 +1 @@
-import sys, os, logging
-
-from random import randint
-from parsley.config import Config, ConfigParameter
-from parsley.loggingex import *
-from wooly import Application, Session, Page
-from wooly.pages import ResourcePage
-from wooly.server import WebServer
-from wooly.devel import DevelPage
-from wooly.parameters import IntegerParameter
-from mint import *
-from time import sleep
-from threading import Thread, Event
-from urllib import quote
-from model import CuminModel, CallPage
-from demo import DemoData
-from page import MainPage
-from stat import StatChartPage, StatStackedPage, SlotMapPage, StatFlashPage,
FlashFullPage
-from account.user import UserSession, UserSessionExpireThread
-from account import LoginPage, AccountPage
-from datetime import timedelta
-from qpid.util import URL
-from widgets import CuminFormPage
-
-from wooly import Session
-
-import account
-import messaging
-import grid
-import inventory
-import usergrid
-
-log = logging.getLogger("cumin")
-
-class Cumin(Application):
- def __init__(self, config):
- super(Cumin, self).__init__()
-
- self.config = config
-
- if self.config.debug:
- self.enable_debug()
-
- self.home = self.config.home
-
- self.add_resource_dir(os.path.join(self.home, "resources-wooly"))
- self.add_resource_dir(os.path.join(self.home, "resources"))
-
- self.model = CuminModel(self, self.config.data)
-
- self.main_page = MainPage(self, "index.html")
- self.add_page(self.main_page)
- self.set_default_page(self.main_page)
-
- self.form_page = FormPage(self, "form.html")
- self.add_page(self.form_page)
-
- # XXX move this to the account module
- self.account_page = AccountPage(self, "account.html")
- self.add_page(self.account_page)
-
- self.add_page(DevelPage(self, "devel.html"))
- self.add_page(CallPage(self, "call.xml"))
- self.add_page(StatChartPage(self, "stats.png"))
- self.add_page(StatStackedPage(self, "stacked.png"))
- self.add_page(SlotMapPage(self, "slots.png"))
- self.add_page(StatFlashPage(self, "chart.json"))
- self.add_page(FlashFullPage(self, "flashpage.html"))
-
- unprotected = set()
-
- unprotected.add(self.main_page.css_page)
- unprotected.add(self.main_page.javascript_page)
- unprotected.add(self.resource_page)
-
- self.login_page = LoginPage(self, "login.html")
- self.add_page(self.login_page)
- unprotected.add(self.login_page)
-
- self.unprotected_pages = unprotected
-
- self.user_sessions_by_id = dict()
- self.user_session_expire_thread = UserSessionExpireThread(self)
-
- def check(self):
- if not os.path.isdir(self.home):
- raise Exception \
- ("Error: cumin home '%s' not found or not a directory"
\
- % self.home)
-
- self.model.check()
-
- def init(self):
- modules = list()
- modules.append(account.module)
- modules.append(messaging.module)
- modules.append(grid.module)
- modules.append(inventory.module)
- modules.append(usergrid.module)
-
- for module in modules:
- module.init(self)
-
- self.model.init()
-
- super(Cumin, self).init()
-
- def start(self):
- self.model.start()
- self.user_session_expire_thread.start()
-
- def stop(self):
- self.model.stop()
-
-class CuminServer(WebServer):
- def authorized(self, session):
- auth = False
- page = session.page
-
- if page in self.app.unprotected_pages:
- return True
-
- id = session.get_cookie("session")
-
- if id is not None:
- usess = self.app.user_sessions_by_id.get(id)
-
- if usess is not None:
- timeout = timedelta(seconds=3600)
- now = datetime.now()
-
- if now > usess.created and now < usess.created + timeout:
- setattr(session, "user_session", usess)
-
- return True
-
- if self.app.config.user:
- user = Subject.getByName(self.app.config.user)
-
- assert user
-
- usess = UserSession(self.app, user)
- session.set_cookie("session", usess.id)
-
- page.set_redirect_url(session, session.marshal())
-
- return False
-
- lpage = self.app.login_page
- lsess = Session(lpage)
- lpage.origin.set(lsess, session.marshal())
-
- page.set_redirect_url(session, lsess.marshal())
-
- return False
-
-class CuminConfig(Config):
- def __init__(self):
- super(CuminConfig, self).__init__()
-
- hdef = os.path.normpath("/var/lib/cumin")
- self.home = os.environ.get("CUMIN_HOME", hdef)
-
- sdef = os.path.normpath("/usr/share/amqp/amqp.0-10-qpid-errata.xml")
- self.spec = os.environ.get("AMQP_SPEC", sdef)
-
- if not os.path.isdir(self.home):
- raise Exception("Home path '%s' is not a directory")
-
- param = ConfigParameter(self, "data", str)
- param.default = "postgresql://cumin@localhost/cumin"
-
- param = ConfigParameter(self, "log-file", str)
- param.default = os.path.join(self.home, "log", "cumin.log")
-
- param = ConfigParameter(self, "log-level", str)
- param.default = "warn"
-
- param = ConfigParameter(self, "debug", bool)
- param.default = False
-
- param = ConfigParameter(self, "user", str)
-
- param = ConfigParameter(self, "operator-email", str)
-
- def init(self):
- super(CuminConfig, self).init()
-
- self.load_file(os.path.join(self.home, "etc", "cumin.conf"))
- self.load_file(os.path.join(os.path.expanduser("~"),
".cumin.conf"))
-
- enable_logging("cumin", self.log_level, self.log_file)
-
- if self.debug:
- enable_logging("cumin", "debug", sys.stderr)
-
-class FormPage(CuminFormPage):
- def __init__(self, app, name):
- super(FormPage, self).__init__(app, name)
+from main import *
Modified: mgmt/trunk/cumin/python/cumin/account/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/main.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/account/main.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -2,10 +2,9 @@
from wooly.widgets import *
from wooly.resources import *
+from cumin import *
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.util import *
-from user import UserSession
from model import *
Modified: mgmt/trunk/cumin/python/cumin/account/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/model.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/account/model.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,4 +1,4 @@
-from cumin.model import Task
+from cumin.model import *
from user import *
Modified: mgmt/trunk/cumin/python/cumin/account/user.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/account/user.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/account/user.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,11 +1,6 @@
from wooly import *
from wooly.widgets import *
from wooly.resources import *
-from time import sleep
-from threading import Thread, Event
-from datetime import datetime, timedelta
-from crypt import crypt
-from qpid.datatypes import uuid4
from cumin.widgets import *
from cumin.util import *
@@ -14,41 +9,6 @@
log = logging.getLogger("cumin.user")
-class UserSession(object):
- def __init__(self, app, subject):
- self.app = app
- self.subject = subject
- self.id = str(uuid4())
- self.created = datetime.now()
-
- self.app.user_sessions_by_id[self.id] = self
-
- def delete(self):
- del self.app.user_sessions_by_id[self.id]
-
-class UserSessionExpireThread(Thread):
- def __init__(self, app):
- super(UserSessionExpireThread, self).__init__()
-
- self.app = app
- self.setDaemon(True)
-
- def run(self):
- while True:
- self.expire_sessions()
- sleep(60)
-
- def expire_sessions(self):
- when = datetime.now() - timedelta(hours=2)
- count = 0
-
- for session in self.app.user_sessions_by_id.values():
- if session.created < when:
- session.delete()
- count += 1
-
- log.info("Expired %i user sessions", count)
-
class ChangePasswordForm(CuminFieldForm):
def __init__(self, app, name, task):
super(ChangePasswordForm, self).__init__(app, name)
Added: mgmt/trunk/cumin/python/cumin/config.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/config.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/config.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -0,0 +1,48 @@
+import os
+import sys
+import logging
+
+from parsley.config import Config, ConfigParameter
+from parsley.loggingex import *
+
+log = logging.getLogger("cumin.config")
+
+class CuminConfig(Config):
+ def __init__(self):
+ super(CuminConfig, self).__init__()
+
+ hdef = os.path.normpath("/var/lib/cumin")
+ self.home = os.environ.get("CUMIN_HOME", hdef)
+
+ sdef = os.path.normpath("/usr/share/amqp/amqp.0-10-qpid-errata.xml")
+ self.spec = os.environ.get("AMQP_SPEC", sdef)
+
+ if not os.path.isdir(self.home):
+ raise Exception("Home path '%s' is not a directory")
+
+ param = ConfigParameter(self, "data", str)
+ param.default = "postgresql://cumin@localhost/cumin"
+
+ param = ConfigParameter(self, "log-file", str)
+ param.default = os.path.join(self.home, "log", "cumin.log")
+
+ param = ConfigParameter(self, "log-level", str)
+ param.default = "warn"
+
+ param = ConfigParameter(self, "debug", bool)
+ param.default = False
+
+ param = ConfigParameter(self, "user", str)
+
+ param = ConfigParameter(self, "operator-email", str)
+
+ def init(self):
+ super(CuminConfig, self).init()
+
+ self.load_file(os.path.join(self.home, "etc", "cumin.conf"))
+ self.load_file(os.path.join(os.path.expanduser("~"),
".cumin.conf"))
+
+ enable_logging("cumin", self.log_level, self.log_file)
+
+ if self.debug:
+ enable_logging("cumin", "debug", sys.stderr)
Modified: mgmt/trunk/cumin/python/cumin/grid/collector.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/collector.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/collector.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -7,7 +7,6 @@
from wooly.tables import *
from cumin.stat import *
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.parameters import *
from cumin.formats import *
from cumin.util import *
@@ -105,19 +104,12 @@
def __init__(self, app, name, collector):
super(CollectorView, self).__init__(app, name)
- status = self.CollectorStatus(app, "status")
- self.add_child(status)
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
+ self.tabs.add_tab(CollectorStats(app, "stats"))
+ self.tabs.add_tab(CuminDetails(app, "details"))
- self.__tabs.add_tab(CollectorStats(app, "stats"))
- self.__tabs.add_tab(CuminDetails(app, "details"))
-
- class CollectorStatus(CuminStatus):
- def render_title(self, session, object):
- return "Collector Status"
-
class CollectorStartForm(CuminTaskForm):
def __init__(self, app, name, task):
super(CollectorStartForm, self).__init__(app, name, task)
Modified: mgmt/trunk/cumin/python/cumin/grid/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/job.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/job.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -6,7 +6,6 @@
from wooly.tables import *
from time import time
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.parameters import *
from cumin.stat import *
from cumin.formats import *
@@ -448,15 +447,6 @@
str = super(JobGroupJobSet, self).render_count(session)
return "%s in Job Group '%s'" % (str, group.get_id())
-class JobGroupStatus(CuminStatus):
- def render_color(self, session, job_group):
- #return JobStatusInfo.get_status_color(job.JobStatus)
- return "green"
-
- def render_job_status(self, session, job_group):
- #return JobStatusInfo.get_status_string(job.JobStatus)
- return "Status"
-
class JobGroupSystemSet(SystemSet):
def render_sql_where(self, session):
subquery = """
@@ -503,7 +493,6 @@
frame.set_object(session, system)
return self.page.set_frame(session, frame)
-
class JobView(CuminView):
def __init__(self, app, name):
super(JobView, self).__init__(app, name)
@@ -511,17 +500,14 @@
summary = CuminSummary(app, "summary")
self.add_child(summary)
- status = JobStatus(app, "status")
- self.add_child(status)
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
+ self.tabs.add_tab(JobAdsViewer(app, "jobads"))
+ self.tabs.add_tab(JobOutput(app, "output"))
+ self.tabs.add_tab(JobSystemSet(app, "systems"))
+ self.tabs.add_tab(CuminDetails(app, "details"))
- self.__tabs.add_tab(JobAdsViewer(app, "jobads"))
- self.__tabs.add_tab(JobOutput(app, "output"))
- self.__tabs.add_tab(JobSystemSet(app, "systems"))
- self.__tabs.add_tab(CuminDetails(app, "details"))
-
class JobSystemSet(SystemSet):
def get_args(self, session):
return self.frame.get_args(session)
@@ -949,15 +935,6 @@
self.add_state("t", "Tail", "Display end of
file")
self.add_state("h", "Head", "Display beginning of
file")
-class JobStatus(CuminStatus):
- def render_color(self, session, job):
- if job:
- return JobStatusInfo.get_status_color(job.JobStatus)
-
- def render_job_status(self, session, job):
- if job:
- return JobStatusInfo.get_status_string(job.JobStatus)
-
class JobGroupSet(CuminTable):
def __init__(self, app, name, pool):
super(JobGroupSet, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/grid/job.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/job.strings 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/job.strings 2009-07-02 15:40:22 UTC (rev 3473)
@@ -143,13 +143,6 @@
<ul class="radiotabs tabs">{tabs}</ul>
<div class="radiotabs mode">{content}</div>
-[JobStatus.html]
-<div id="{id}" class="CuminStatus {color}">
- <h2>Job Status</h2>
- {job_status}
-</div>
-
-
[JobAdsViewer.html]
<div id="{id}">
<ul class="actions">
Modified: mgmt/trunk/cumin/python/cumin/grid/limit.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/limit.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/limit.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -234,22 +234,15 @@
def __init__(self, app, name, pool):
super(LimitsView, self).__init__(app, name)
- status = LimitsStatus(app, "status")
- self.add_child(status)
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
-
jobs = LimitsJobSet(app, "jobs", pool)
- self.__tabs.add_tab(jobs)
+ self.tabs.add_tab(jobs)
details = CuminDetails(app, "details")
- self.__tabs.add_tab(details)
+ self.tabs.add_tab(details)
-class LimitsStatus(CuminStatus):
- def render_title(self, session, *args):
- return "Limits Status"
-
class LimitsJobSet(JobTab):
def get_visible_columns(self, session):
return self.get_request_visible_columns(session,
Modified: mgmt/trunk/cumin/python/cumin/grid/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/main.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/main.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -11,6 +11,7 @@
class GridModule(object):
def init(self, app):
+ self.see_pools = SeePoolsTask(app, None)
job = app.model.job
self.job_hold = JobHoldTask(app, job)
@@ -25,6 +26,7 @@
self.scheduler_stop = SchedulerStopTask(app, scheduler)
self.scheduler_set_start = SchedulerSetStartTask(app, scheduler)
self.scheduler_set_stop = SchedulerSetStopTask(app, scheduler)
+ self.submission_add = SubmissionAddTask(app, scheduler)
collector = app.model.collector
self.collector_start = CollectorStartTask(app, collector)
Modified: mgmt/trunk/cumin/python/cumin/grid/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/model.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/model.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,13 +1,56 @@
from wooly import Session
+from cumin.model import *
from cumin.util import *
-from cumin.model import Task, SetTask
from job import *
+from submission import *
from scheduler import *
from collector import *
from negotiator import *
+class SeePoolsTask(Task):
+ def get_title(self, session):
+ return "Create submission"
+
+ def do_enter(self, session, scheduler):
+ self.app.main_page.grid.view.show(branch)
+
+class SubmissionAddTask(QmfTask):
+ EXPR_TYPE, INTEGER_TYPE, FLOAT_TYPE, STRING_TYPE = 0, 1, 2, 3
+ UNIVERSE = {"VANILLA": 5,
+ "SCHEDULER": 7,
+ "GRID": 9,
+ "JAVA": 10,
+ "PARALLEL": 11,
+ "LOCAL": 12,
+ "VM": 13}
+
+ def __init__(self, app, cls):
+ super(SubmissionAddTask, self).__init__(app, cls)
+
+ self.form = SubmissionAddForm(app, "submission_add", self)
+
+ def get_title(self, session):
+ return "Create submission"
+
+ def get_description(self, session, scheduler):
+ return "Create submission to scheduler '%s'" % scheduler.Name
+
+ def do_enter(self, session, scheduler):
+ self.form.scheduler.set(session, scheduler)
+
+ def do_invoke(self, completion, session, scheduler, command, args):
+ ad = {"Cmd": {"TYPE": self.STRING_TYPE,
"VALUE": command},
+ "Args": {"TYPE": self.STRING_TYPE,
"VALUE": args},
+ "Requirements": {"TYPE": self.EXPR_TYPE,
"VALUE": "TRUE"},
+ "JobUniverse": {"TYPE": self.INTEGER_TYPE,
+ "VALUE": "%s" %
(self.UNIVERSE["VANILLA"],)},
+ "Iwd": {"TYPE": self.STRING_TYPE,
"VALUE": "/tmp"},
+ "Owner": {"TYPE": self.STRING_TYPE,
"VALUE": "nobody"}}
+
+ scheduler.Submit(self.app.model.mint.model, completion, ad, None)
+
class NegotiatorStartTask(QmfTask):
def __init__(self, app, cls):
super(NegotiatorStartTask, self).__init__(app, cls)
@@ -288,4 +331,3 @@
self.form = JobSetTaskForm(app, "job_set_remove", self,
"Remove")
self.item_task = JobRemoveTask(app, cls)
-
Modified: mgmt/trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/negotiator.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/negotiator.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -7,7 +7,6 @@
from wooly.tables import *
from cumin.stat import *
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.parameters import *
from cumin.formats import *
from cumin.util import *
@@ -85,24 +84,12 @@
def __init__(self, app, name):
super(NegotiatorView, self).__init__(app, name)
- status = self.NegotiatorStatus(app, "status")
- self.add_child(status)
-
self.__tabs = TabbedModeSet(app, "tabs")
self.add_child(self.__tabs)
details = CuminDetails(app, "details")
self.__tabs.add_tab(details)
- class NegotiatorStatus(StartStopStatus):
- def get_url(self, session):
- negotiator = self.get_args(session)[0]
- if negotiator:
- return "call.xml?class=negotiator;id=%i;method=GetStarted" %
negotiator.id
-
- def render_title(self, session, *args):
- return "Negotiator Status"
-
class NegotiatorStartForm(CuminTaskForm):
def __init__(self, app, name, task):
super(NegotiatorStartForm, self).__init__(app, name, task)
Modified: mgmt/trunk/cumin/python/cumin/grid/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/pool.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/pool.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -20,7 +20,7 @@
from limit import LimitsSet, LimitsFrame
from slot import SlotSet, SlotFrame
-import cumin.model
+import cumin.model
strings = StringCatalog(__file__)
@@ -86,15 +86,12 @@
self.job_group = JobGroupFrame(app, "jobgroup", self.object)
self.add_mode(self.job_group)
- self.scheduler = SchedulerFrame(app, "sched", self.object)
- self.add_mode(self.scheduler)
-
- self.submitter = SubmitterFrame(app, "sub", self.object)
- self.add_mode(self.submitter)
-
self.slot = SlotFrame(app, "slot")
self.add_mode(self.slot)
+ self.scheduler = SchedulerFrame(app, "sched", self.object)
+ self.add_mode(self.scheduler)
+
self.collector = CollectorFrame(app, "coll")
self.add_mode(self.collector)
@@ -112,35 +109,31 @@
def __init__(self, app, name, pool):
super(PoolView, self).__init__(app, name)
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
+ self.pool = pool
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
+
stats = PoolStats(app, "stats")
- self.__tabs.add_tab(stats)
+ self.tabs.add_tab(stats)
- self.jobs = JobsAndGroupsTab(app, "jobs", pool)
- self.__tabs.add_tab(self.jobs)
+ self.submissions = PoolSubmissionSet(app, "submissions", self.pool)
+ self.tabs.add_tab(self.submissions)
- self.submissions = SubmissionSet(app, "submissions")
- self.__tabs.add_tab(self.submissions)
+ self.slots = PoolSlotSet(app, "slots")
+ self.tabs.add_tab(self.slots)
self.scheds = PoolSchedulerSet(app, "scheds", pool)
- self.__tabs.add_tab(self.scheds)
+ self.tabs.add_tab(self.scheds)
- subs = PoolSubmitterSet(app, "subs")
- self.__tabs.add_tab(subs)
+ self.negs = PoolNegotiatorSet(app, "negs", pool)
+ self.tabs.add_tab(self.negs)
self.colls = PoolCollectorSet(app, "colls", pool)
- self.__tabs.add_tab(self.colls)
+ self.tabs.add_tab(self.colls)
- self.slots = PoolSlotSet(app, "slots")
- self.__tabs.add_tab(self.slots)
-
- self.negs = PoolNegotiatorSet(app, "negs", pool)
- self.__tabs.add_tab(self.negs)
-
self.limits = LimitsSet(app, "limits")
- self.__tabs.add_tab(self.limits)
+ self.tabs.add_tab(self.limits)
def do_process(self, session, *args):
self.limits.limit_count.process(session)
@@ -155,6 +148,19 @@
def set_scheduler_tab(self, session):
self.scheds.show(session)
+class PoolSubmissionSet(SubmissionSet):
+ def __init__(self, app, name, pool):
+ super(PoolSubmissionSet, self).__init__(app, name)
+
+ self.pool = pool
+
+ def render_sql_where(self, session):
+ return "where d.pool = %(pool)s"
+
+ def get_sql_values(self, session):
+ pool = self.pool.get(session)
+ return {"pool": pool.id}
+
class PoolSchedulerSet(SchedulerSet):
def render_sql_where(self, session):
return "where s.pool = %(pool)s"
@@ -167,20 +173,6 @@
count = self.get_item_count(session)
return "Schedulers %s" % fmt_count(count)
-class PoolSubmitterSet(SubmitterSet):
- def get_args(self, session):
- return self.frame.get_args(session)
-
- def get_sql_values(self, session, pool):
- return {"pool": pool.id}
-
- def render_title(self, session, pool):
- count = self.get_item_count(session, pool)
- return "Submitters %s" % fmt_count(count)
-
- def render_sql_where(self, session, pool):
- return "where d.pool = %(pool)s"
-
class PoolCollectorSet(CollectorSet):
def __init__(self, app, name, pool):
super(PoolCollectorSet, self).__init__(app, name)
@@ -372,27 +364,3 @@
def get_sql_values(self, session, pool):
values = {"pool": pool.id}
return values
-
-class PoolStatus(CuminStatus):
- def __init__(self, app, name):
- super(PoolStatus, self).__init__(app, name)
-
- self.item_tmpl = Template(self, "status_html")
-
- def render_title(self, session, pool):
- return "Pool Status"
-
- def render_status(self, session, pool):
- action = self.app.model.pool.poolstatus
- record = action.get_stat_record(session, pool)
- if record and ("available" in record) and ("all" in record):
- if record["available"] and record["all"]: # not None
- writer = Writer()
- self.item_tmpl.render(writer, session, record)
- return writer.to_string()
-
- def render_available(self, session, record):
- return record["available"]
-
- def render_total(self, session, record):
- return record["all"]
Modified: mgmt/trunk/cumin/python/cumin/grid/pool.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/pool.strings 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/pool.strings 2009-07-02 15:40:22 UTC (rev 3473)
@@ -33,18 +33,6 @@
[PoolJobStats.count_sql]
1
-[PoolStatus.html]
-<div id="{id}" class="CuminStatus {color}">
- <h2>{title}</h2>
-
- {status}
-</div>
-
-[PoolStatus.status_html]
-<div>
- <span>{available}</span> of <span>{total}</span> slots
available
-</div>
-
[PoolStats.css]
div#poolStats div.col1, div#poolStats div.col2 {
float: left;
@@ -75,4 +63,4 @@
<blockquote>
{jobs_chart}
{submit_chart}
- </blockquote>
\ No newline at end of file
+ </blockquote>
Modified: mgmt/trunk/cumin/python/cumin/grid/scheduler.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/scheduler.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/scheduler.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -11,6 +11,8 @@
from cumin.util import *
from job import *
+from submitter import *
+from submission import *
strings = StringCatalog(__file__)
@@ -91,37 +93,34 @@
self.object = SchedulerParameter(app, "id")
self.add_parameter(self.object)
- self.view = SchedulerView(app, "view", pool)
+ self.view = SchedulerView(app, "view", self.object)
self.add_mode(self.view)
+ self.submission = SubmissionFrame(app, "submission")
+ self.add_mode(self.submission)
+
+ self.submitter = SubmitterFrame(app, "sub", self.object)
+ self.add_mode(self.submitter)
+
class SchedulerView(CuminView):
- def __init__(self, app, name, pool):
+ def __init__(self, app, name, scheduler):
super(SchedulerView, self).__init__(app, name)
- status = self.SchedulerStatus(app, "status")
- self.add_child(status)
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
-
stats = SchedulerStats(app, "stats")
- self.__tabs.add_tab(stats)
+ self.tabs.add_tab(stats)
- jobs = SchedulerJobSet(app, "jobs", pool)
- self.__tabs.add_tab(jobs)
+ submissions = SchedulerSubmissionSet(app, "submissions", scheduler)
+ self.tabs.add_tab(submissions)
+ submitters = SchedulerSubmitterSet(app, "submitters", scheduler)
+ self.tabs.add_tab(submitters)
+
details = CuminDetails(app, "details")
- self.__tabs.add_tab(details)
+ self.tabs.add_tab(details)
- class SchedulerStatus(StartStopStatus):
- def get_url(self, session):
- scheduler = self.get_args(session)[0]
- if scheduler:
- return "call.xml?class=scheduler;id=%i;method=GetStarted" %
scheduler.id
-
- def render_title(self, session, *args):
- return "Scheduler Status"
-
class SchedulerStats(Widget):
def __init__(self, app, name):
super(SchedulerStats, self).__init__(app, name)
@@ -159,6 +158,38 @@
def render_title(self, session, sched):
return "Jobs"
+class SchedulerSubmissionSet(SubmissionSet):
+ def __init__(self, app, name, scheduler):
+ super(SchedulerSubmissionSet, self).__init__(app, name)
+
+ self.scheduler = scheduler
+
+ self.scheduler_col.visible = False
+
+ task = main.module.submission_add
+ link = TaskLink(app, "add", task, scheduler)
+ self.links.add_child(link)
+
+ def render_sql_where(self, session):
+ return "where d.id = %(id)r"
+
+ def get_sql_values(self, session):
+ scheduler = self.scheduler.get(session)
+ return {"id": scheduler.id}
+
+class SchedulerSubmitterSet(SubmitterSet):
+ def __init__(self, app, name, scheduler):
+ super(SchedulerSubmitterSet, self).__init__(app, name)
+
+ self.scheduler = scheduler
+
+ def render_sql_where(self, session):
+ return "where d.id = %(id)r"
+
+ def get_sql_values(self, session):
+ scheduler = self.scheduler.get(session)
+ return {"id": scheduler.id}
+
class SchedulerJobSet(JobTab):
def __init__(self, app, name, pool):
super(SchedulerJobSet, self).__init__(app, name, pool)
Modified: mgmt/trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/slot.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/slot.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -111,9 +111,6 @@
def __init__(self, app, name):
super(SlotView, self).__init__(app, name)
- status = self.SlotStatus(app, "status")
- self.add_child(status)
-
self.__tabs = TabbedModeSet(app, "tabs")
self.add_child(self.__tabs)
@@ -123,10 +120,6 @@
details = CuminDetails(app, "details")
self.__tabs.add_tab(details)
- class SlotStatus(CuminStatus):
- def render_title(self, session, *args):
- return "Slot Status"
-
class SlotStats(Widget):
def __init__(self, app, name):
super(SlotStats, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/submission.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/submission.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -3,6 +3,8 @@
from cumin.widgets import *
from cumin.util import *
+import main
+
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.grid.submission")
@@ -14,6 +16,12 @@
col = self.NameColumn(app, "name")
self.add_column(col)
+ self.scheduler_col = self.SchedulerColumn(app, "scheduler")
+ self.add_column(self.scheduler_col)
+
+ self.submitter_col = self.SubmitterColumn(app, "submitter")
+ self.add_column(self.submitter_col)
+
col = self.IdleColumn(app, "idle")
self.add_column(col)
@@ -24,10 +32,20 @@
self.add_column(col)
def get_submission_href(self, session, id):
+ submission = Identifiable(id)
+ return main.module.frame.pool.scheduler.submission.get_href \
+ (session, submission)
+
+ def get_submitter_href(self, session, id):
+ submitter = Identifiable(id)
+ return main.module.frame.pool.scheduler.submitter.get_href \
+ (session, submitter)
+
+ def get_scheduler_href(self, session, id):
pass
def render_title(self, session):
- return "Submissions %s" % fmt_count(Submission.select().count())
+ return "Submissions %s" % fmt_count(self.get_item_count(session))
class NameColumn(ClientTruncateColumn):
def render_title(self, session, data):
@@ -36,7 +54,25 @@
def render_content(self, session, data):
href = self.parent.get_submission_href(session, data["id"])
return fmt_link(href, data["name"])
-
+
+ class SchedulerColumn(SqlTableColumn):
+ def render_title(self, session, data):
+ return "Scheduler"
+
+ def render_content(self, session, data):
+ href = self.parent.get_scheduler_href \
+ (session, data["scheduler_id"])
+ return fmt_link(href, data["scheduler_name"])
+
+ class SubmitterColumn(SqlTableColumn):
+ def render_title(self, session, data):
+ return "Submitter"
+
+ def render_content(self, session, data):
+ href = self.parent.get_submitter_href \
+ (session, data["scheduler_id"])
+ return fmt_link(href, data["submitter_name"])
+
class IdleColumn(SqlTableColumn):
def render_title(self, session, data):
return "Idle Jobs"
@@ -48,3 +84,142 @@
class CompletedColumn(SqlTableColumn):
def render_title(self, session, data):
return "Completed Jobs"
+
+class SubmissionFrame(CuminFrame):
+ def __init__(self, app, name):
+ super(SubmissionFrame, self).__init__(app, name)
+
+ self.object = SubmissionParameter(app, "submission")
+ self.add_parameter(self.object)
+
+ self.view = SubmissionView(app, "view", self.object)
+ self.add_child(self.view)
+
+ def render_title(self, session):
+ return "Submission"
+
+class SubmissionView(CuminView):
+ def __init__(self, app, name, submission):
+ super(SubmissionView, self).__init__(app, name)
+
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
+
+ self.jobs = SubmissionJobSet(app, "jobs", submission)
+ self.tabs.add_tab(self.jobs)
+
+class SubmissionJobSet(Widget):
+ def __init__(self, app, name, submission):
+ super(SubmissionJobSet, self).__init__(app, name)
+
+ self.submission = submission
+
+ def render_title(self, session):
+ return "Jobs"
+
+class SubmissionAddForm(FieldSubmitForm):
+ def __init__(self, app, name, task):
+ super(SubmissionAddForm, self).__init__(app, name)
+
+ self.task = task
+
+ self.scheduler = SchedulerParameter(app, "scheduler")
+ self.add_parameter(self.scheduler)
+
+ self.description = self.DescriptionField(app, "description")
+ self.description.input.size = 50
+ self.add_field(self.description)
+
+ self.command = self.CommandField(app, "command")
+ self.command.input.size = 50
+ self.add_field(self.command)
+
+ self.args = self.ArgumentsField(app, "args")
+ self.args.input.size = 50
+ self.add_field(self.args)
+
+ self.inputs = self.InputsField(app, "inputs")
+ self.add_field(self.inputs)
+
+ self.outputs = self.OutputsField(app, "outputs")
+ self.add_field(self.outputs)
+
+ self.options = self.OptionsField(app, "options")
+ self.add_field(self.options)
+
+ def process_submit(self, session):
+ self.check(session)
+
+ if not self.errors.get(session):
+ scheduler = self.scheduler.get(session)
+
+ command = self.command.get(session)
+ args = self.args.get(session)
+
+ self.task.invoke(session, scheduler, command, args)
+ self.task.exit_with_redirect(session, scheduler)
+
+ def render_title(self, session):
+ scheduler = self.scheduler.get(session)
+ return self.task.get_description(session, scheduler)
+
+ class TemplateField(FormField):
+ def __init__(self, app, name):
+ super(SubmissionAddForm.TemplateField, self).__init__(app, name)
+
+ param = Parameter(app, "param")
+ self.add_parameter(param)
+
+ self.input = self.TemplateSet(app, "inputs", param)
+ self.add_child(self.input)
+
+ def render_title(self, session):
+ return "Template"
+
+ class TemplateSet(OptionInputSet):
+ def do_get_items(self, session):
+ return ("Standard scene render", "Experimental")
+
+ def render_item_value(self, session, item):
+ return item
+
+ def render_item_content(self, session, item):
+ return item
+
+ class DescriptionField(StringField):
+ def render_title(self, session):
+ return "Description"
+
+ class CommandField(StringField):
+ def render_title(self, session):
+ return "Command"
+
+ class ArgumentsField(StringField):
+ def render_title(self, session):
+ return "Arguments"
+
+ class InputsField(MultilineStringField):
+ def render_title(self, session):
+ return "Inputs"
+
+ class OutputsField(MultilineStringField):
+ def render_title(self, session):
+ return "Outputs"
+
+ class OptionsField(CheckboxField):
+ def __init__(self, app, name):
+ super(SubmissionAddForm.OptionsField, self).__init__(app, name)
+
+ self.add_option(self.SaveAsTemplate(app, "template"))
+ self.add_option(self.UseCloud(app, "cloud"))
+
+ def render_title(self, session):
+ return "Options"
+
+ class SaveAsTemplate(CheckboxFieldOption):
+ def render_title(self, session):
+ return "Save as template"
+
+ class UseCloud(CheckboxFieldOption):
+ def render_title(self, session):
+ return "Use cloud"
Modified: mgmt/trunk/cumin/python/cumin/grid/submission.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/submission.strings 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/grid/submission.strings 2009-07-02 15:40:22 UTC (rev
3473)
@@ -4,15 +4,23 @@
s.name,
c.idle,
c.running,
- c.completed
+ c.completed,
+ m.id as submitter_id,
+ m.name as submitter_name,
+ d.id as scheduler_id,
+ d.name as scheduler_name
from submission as s
inner join scheduler as d on s.scheduler_id = d.id
-left outer join submission_stats as c on s.stats_curr_id = c.id
+inner join submitter as m on s.submitter_id = m.id
+inner join submission_stats as c on s.stats_curr_id = c.id
{sql_where}
{sql_order_by}
{sql_limit}
[SubmissionSet.count_sql]
-select count(*) from submission as s
+select count(*)
+from submission as s
inner join scheduler as d on s.scheduler_id = d.id
+inner join submitter as m on s.submitter_id = m.id
+inner join submission_stats as c on s.stats_curr_id = c.id
{sql_where}
Modified: mgmt/trunk/cumin/python/cumin/grid/submitter.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/submitter.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/grid/submitter.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -11,7 +11,7 @@
from cumin.formats import *
from cumin.util import *
-from job import *
+from submission import *
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.grid.submitter")
@@ -34,7 +34,8 @@
def render_content(self, session, data):
sub = Identifiable(data["id"])
- href = self.page.main.grid.pool.submitter.get_href(session, sub)
+ href = self.page.main.grid.pool.scheduler.submitter.get_href \
+ (session, sub)
return fmt_link(href, data["name"])
class SubmitterFrame(CuminFrame):
@@ -44,32 +45,25 @@
self.object = SubmitterParameter(app, "id")
self.add_parameter(self.object)
- self.view = SubmitterView(app, "view", pool)
+ self.view = SubmitterView(app, "view", self.object)
self.add_mode(self.view)
class SubmitterView(CuminView):
- def __init__(self, app, name, pool):
+ def __init__(self, app, name, submitter):
super(SubmitterView, self).__init__(app, name)
- status = SubmitterStatus(app, "status")
- self.add_child(status)
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
- self.__tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.__tabs)
-
stats = SubmitterStats(app, "stats")
- self.__tabs.add_tab(stats)
+ self.tabs.add_tab(stats)
- jobs = SubmitterJobSet(app, "jobs", pool)
- self.__tabs.add_tab(jobs)
+ submissions = SubmitterSubmissionSet(app, "submissions", submitter)
+ self.tabs.add_tab(submissions)
details = CuminDetails(app, "details")
- self.__tabs.add_tab(details)
+ self.tabs.add_tab(details)
-class SubmitterStatus(CuminStatus):
- def render_title(self, session):
- return "Submitter Status"
-
class SubmitterStats(Widget):
def __init__(self, app, name):
super(SubmitterStats, self).__init__(app, name)
@@ -93,20 +87,18 @@
def render_title(self, session, sched):
return "Jobs"
-class SubmitterJobSet(JobTab):
- def __init__(self, app, name, pool):
- super(SubmitterJobSet, self).__init__(app, name, pool)
+class SubmitterSubmissionSet(SubmissionSet):
+ def __init__(self, app, name, submitter):
+ super(SubmitterSubmissionSet, self).__init__(app, name)
- def get_visible_columns(self, session):
- return self.get_request_visible_columns(session, ["custom_group",
"scheduler"])
+ self.submitter = submitter
+ self.scheduler_col.visible = False
+ self.submitter_col.visible = False
+
def render_sql_where(self, session):
- submitter = self.frame.object.get(session)
- phase_sql = self.get_phase_sql(session)
- submitter_sql = "j.submitter_id = %i" % submitter.id
- return "where %s" % " and ".join([phase_sql, submitter_sql])
+ return "where m.id = %(id)r"
- def render_title(self, session):
- submitter = self.frame.object.get(session)
- submitter_sql = "submitter_id = %i" % submitter.id
- return "Jobs %s" % fmt_count(Job.select(submitter_sql).count())
+ def get_sql_values(self, session):
+ submitter = self.submitter.get(session)
+ return {"id": submitter.id}
Modified: mgmt/trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/inventory/system.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/inventory/system.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -121,13 +121,6 @@
self.slot = SlotFrame(app, "slot")
self.add_mode(self.slot)
-class SystemStatus(CuminStatus):
- def render_mem_free(self, session, system):
- return self.app.model.system.memFree.value_html(system)
-
- def render_load_average(self, session, system):
- return self.app.model.system.loadAverage1Min.value_html(system)
-
from cumin.visualizations import SlotMap
class SystemStats(Widget):
@@ -168,9 +161,6 @@
summary = CuminSummary(app, "summary")
self.add_child(summary)
- status = SystemStatus(app, "status")
- self.add_child(status)
-
self.__tabs = TabbedModeSet(app, "tabs")
self.add_child(self.__tabs)
Modified: mgmt/trunk/cumin/python/cumin/inventory/system.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/inventory/system.strings 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/inventory/system.strings 2009-07-02 15:40:22 UTC (rev
3473)
@@ -46,20 +46,6 @@
[TopSystemSet.count_sql]
--
-[SystemStatus.html]
-<div id="{id}" class="CuminStatus {color}">
- <table>
- <tr>
- <th>Free Memory</th>
- <td class="ralign">{mem_free}</td>
- </tr>
- <tr>
- <th>Load Average</th>
- <td class="ralign">{load_average}</td>
- </tr>
- </table>
-</div>
-
[SystemStats.html]
<table class="twocol">
<tbody>
Added: mgmt/trunk/cumin/python/cumin/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/main.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/main.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -0,0 +1,216 @@
+import logging
+import os
+import sys
+
+from datetime import datetime, timedelta
+from mint import *
+from parsley.config import Config, ConfigParameter
+from parsley.loggingex import *
+from qpid.datatypes import uuid4
+from stat import StatChartPage, StatStackedPage, SlotMapPage, \
+ StatFlashPage, FlashFullPage
+from threading import Thread, Event
+from time import sleep
+from wooly import Application, Session, Page
+from wooly.devel import DevelPage
+from wooly.pages import ResourcePage
+from wooly.parameters import IntegerParameter
+
+from config import *
+from model import *
+from widgets import *
+from managementserver import *
+
+from wooly import Session
+
+# Modules
+
+import account
+import messaging
+import grid
+import inventory
+import usergrid
+
+strings = StringCatalog(__file__)
+
+log = logging.getLogger("cumin")
+
+class Cumin(Application):
+ def __init__(self, config):
+ super(Cumin, self).__init__()
+
+ self.config = config
+
+ if self.config.debug:
+ self.enable_debug()
+
+ self.home = self.config.home
+
+ self.add_resource_dir(os.path.join(self.home, "resources-wooly"))
+ self.add_resource_dir(os.path.join(self.home, "resources"))
+
+ self.model = CuminModel(self, self.config.data)
+
+ self.main_page = MainPage(self, "index.html")
+ self.add_page(self.main_page)
+ self.set_default_page(self.main_page)
+
+ self.form_page = CuminFormPage(self, "form.html")
+ self.add_page(self.form_page)
+
+ # XXX move this to the account module
+ self.account_page = account.AccountPage(self, "account.html")
+ self.add_page(self.account_page)
+
+ self.add_page(DevelPage(self, "devel.html"))
+ self.add_page(CallPage(self, "call.xml"))
+ self.add_page(StatChartPage(self, "stats.png"))
+ self.add_page(StatStackedPage(self, "stacked.png"))
+ self.add_page(SlotMapPage(self, "slots.png"))
+ self.add_page(StatFlashPage(self, "chart.json"))
+ self.add_page(FlashFullPage(self, "flashpage.html"))
+
+ unprotected = set()
+
+ unprotected.add(self.main_page.css_page)
+ unprotected.add(self.main_page.javascript_page)
+ unprotected.add(self.resource_page)
+
+ self.login_page = account.LoginPage(self, "login.html")
+ self.add_page(self.login_page)
+ unprotected.add(self.login_page)
+
+ self.unprotected_pages = unprotected
+
+ self.user_sessions_by_id = dict()
+ self.user_session_expire_thread = UserSessionExpireThread(self)
+
+ def check(self):
+ if not os.path.isdir(self.home):
+ raise Exception \
+ ("Error: cumin home '%s' not found or not a directory"
\
+ % self.home)
+
+ self.model.check()
+
+ def init(self):
+ modules = list()
+ modules.append(account.module)
+ modules.append(messaging.module)
+ modules.append(grid.module)
+ modules.append(inventory.module)
+ modules.append(usergrid.module)
+
+ for module in modules:
+ module.init(self)
+
+ self.model.init()
+
+ super(Cumin, self).init()
+
+ def start(self):
+ self.model.start()
+ self.user_session_expire_thread.start()
+
+ def stop(self):
+ self.model.stop()
+
+class UserSession(object):
+ def __init__(self, app, subject):
+ self.app = app
+ self.subject = subject
+ self.id = str(uuid4())
+ self.created = datetime.now()
+
+ self.app.user_sessions_by_id[self.id] = self
+
+ def delete(self):
+ del self.app.user_sessions_by_id[self.id]
+
+class UserSessionExpireThread(Thread):
+ def __init__(self, app):
+ super(UserSessionExpireThread, self).__init__()
+
+ self.app = app
+ self.setDaemon(True)
+
+ def run(self):
+ while True:
+ self.expire_sessions()
+ sleep(60)
+
+ def expire_sessions(self):
+ when = datetime.now() - timedelta(hours=2)
+ count = 0
+
+ for session in self.app.user_sessions_by_id.values():
+ if session.created < when:
+ session.delete()
+ count += 1
+
+ log.info("Expired %i user sessions", count)
+
+class MainPage(CuminPage, ModeSet):
+ def __init__(self, app, name):
+ super(MainPage, self).__init__(app, name)
+
+ self.main = MainView(app, "main")
+ self.add_mode(self.main)
+ self.set_default_frame(self.main)
+
+ def render_title(self, session):
+ return "MRG Management"
+
+class MainView(CuminMainView):
+ def __init__(self, app, name):
+ super(MainView, self).__init__(app, name)
+
+ self.overview = OverviewFrame(app, "overview")
+ self.add_tab(self.overview)
+
+class OverviewFrame(CuminFrame):
+ def __init__(self, app, name):
+ super(OverviewFrame, self).__init__(app, name)
+
+ self.view = OverviewView(app, "view")
+ self.add_mode(self.view)
+
+ self.mservers_add = ManagementServerSetAdd(app, "mserversadd")
+ self.add_mode(self.mservers_add)
+
+ def render_title(self, session):
+ return "Overview"
+
+class OverviewView(Widget):
+ def __init__(self, app, name):
+ super(OverviewView, self).__init__(app, name)
+
+ heading = self.Heading(app, "heading")
+ self.add_child(heading)
+
+ notice = self.ManagementServerNotice(app, "notice")
+ self.add_child(notice)
+
+ queues = messaging.queue.TopQueueSet(app, "queues")
+ self.add_child(queues)
+
+ jobs = grid.job.TopJobSet(app, "jobs")
+ self.add_child(jobs)
+
+ systems = inventory.system.TopSystemSet(app, "systems")
+ self.add_child(systems)
+
+ class Heading(CuminHeading):
+ def render_title(self, session):
+ return "Overview"
+
+ def render_icon_href(self, session):
+ return "resource?name=action-36.png"
+
+ class ManagementServerNotice(Widget):
+ def do_render(self, session):
+ count = BrokerRegistration.select().count()
+
+ if count == 0:
+ return super(OverviewView.ManagementServerNotice,
+ self).do_render(session)
Added: mgmt/trunk/cumin/python/cumin/main.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/main.strings (rev 0)
+++ mgmt/trunk/cumin/python/cumin/main.strings 2009-07-02 15:40:22 UTC (rev 3473)
@@ -0,0 +1,73 @@
+[OverviewView.css]
+div.OverviewView > table {
+ width: 100%;
+}
+
+div.OverviewView > table > tbody > tr > td {
+ width: 50%;
+ vertical-align: top;
+}
+
+div.OverviewView h2 > img {
+ vertical-align: bottom;
+ margin: 0 0.2em 0 0;
+}
+
+[OverviewView.html]
+<div class="oblock OverviewView">
+ {heading}
+
+ {notice}
+
+ <table>
+ <tbody>
+ <tr>
+ <td>
+<div class="fullpageable">
+ <h2><img src="resource?name=queue-20.png"/> Busiest
Message Queues</h2>
+
+ <div class="iblock">{queues}</div>
+</div>
+ </td>
+ <td>
+<div class="fullpageable">
+ <h2><img src="resource?name=job-20.png"/> Longest Running
Grid Jobs</h2>
+ <div class="iblock">{jobs}</div>
+</div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+<div class="fullpageable">
+ <h2><img src="resource?name=system-20.png"/> Busiest
Systems</h2>
+
+ <div class="iblock">{systems}</div>
+</div>
+ </td>
+ <td>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+
+[ManagementServerNotice.css]
+div.ManagementServerNotice {
+ margin: 0 0 1em 0;
+ border: 1px dotted #cec;
+ padding: 1em;
+ background-color: #dfd;
+}
+
+div.ManagementServerNotice img {
+ vertical-align: top;
+ float: left;
+ margin: 0 0.5em 0.5em 0;
+}
+
+[ManagementServerNotice.html]
+<div class="ManagementServerNotice">
+ <img src="resource?name=notice-36.png"/> This console is not
+ registered with any management servers. Go to the 'Management Servers'
+ tab above to add a new server.
+</div>
Modified: mgmt/trunk/cumin/python/cumin/managementserver.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/managementserver.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/managementserver.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -3,21 +3,20 @@
from wooly.widgets import *
from widgets import *
-from modelwidgets import *
from parameters import *
from formats import *
from util import *
strings = StringCatalog(__file__)
-class ManagementServerSet(CuminClassTable):
+class ManagementServerSet(CuminSelectionTable):
def __init__(self, app, name):
- cls = app.model.management_server
+ item = Parameter(app, "item")
+ super(ManagementServerSet, self).__init__(app, name, item)
- super(ManagementServerSet, self).__init__(app, name, cls)
-
col = self.NameColumn(app, "name")
self.add_column(col)
+ self.set_default_column(col)
col = self.UrlColumn(app, "url")
self.add_column(col)
@@ -25,238 +24,13 @@
col = self.StatusColumn(app, "status")
self.add_column(col)
- class NameColumn(SqlTableColumn):
- def render_title(self, session, data):
- return "Name"
+ #task = main.module.xxx
+ #button = TaskButton(app, "remove", task, self.selection)
+ #self.buttons.add_child(button)
- class UrlColumn(SqlTableColumn):
- def render_title(self, session, data):
- return "URL"
-
- class StatusColumn(ItemTableColumn):
- def render_title(self, session, data):
- return "Status"
-
- def render_content(self, session, data):
- url = data["url"]
-
- try:
- server = self.app.model.mint.model.mintBrokersByUrl[url]
-
- if server.connected:
- html = "Connected"
- else:
- html = "Disconnected"
- except KeyError:
- html = "Unreachable"
-
- return html
-
-class ManagementServerSetAdd(CuminForm, Frame):
- def __init__(self, app, name):
- super(ManagementServerSetAdd, self).__init__(app, name)
-
- self.name_param = Parameter(app, "name_param");
- self.add_parameter(self.name_param)
-
- self.names = ListParameter(app, "name", self.name_param)
- self.add_parameter(self.names)
-
- self.name_errors = self.Errors(self, "name_errors")
- self.add_attribute(self.name_errors)
-
- self.addr_param = Parameter(app, "addr_param")
- self.add_parameter(self.addr_param)
-
- self.addrs = ListParameter(app, "address", self.addr_param)
- self.add_parameter(self.addrs)
-
- self.addr_errors = self.Errors(self, "addr_errors")
- self.add_attribute(self.addr_errors)
-
- self.fields = IntegerParameter(app, "fields")
- self.fields.default = 3
- self.add_parameter(self.fields)
-
- self.field_tmpl = Template(self, "field_html")
-
- self.more_button = self.MoreEntries(app, "more_button")
- self.add_child(self.more_button)
-
- self.more = self.More(app, "more")
- self.add_parameter(self.more)
-
- def process_cancel(self, session):
- branch = session.branch()
- self.frame.view.show(branch)
- self.page.set_redirect_url(session, branch.marshal())
-
- def process_submit(self, session):
- action = self.app.model.management_server.add
-
- addrs = self.addrs.get(session)
- names = self.names.get(session)
- fields = self.fields.get(session)
-
- if self.validate(session, addrs, names):
- for i in range(0, fields):
- try:
- addr = addrs[i]
- except:
- addr = None
-
- if addr:
- name = names[i]
- url = "amqp://%s:%i" % parse_broker_addr(addr)
-
- args = {"name": name, "url": url}
- reg = action.invoke(None, args)
-
- self.process_cancel(session)
-
- def validate(self, session, addrs, names):
- nerrs = self.name_errors.get(session)
- aerrs = self.addr_errors.get(session)
- fields = self.fields.get(session)
-
- for i in range(0, fields):
- try:
- addr, name = addrs[i], names[i]
- except:
- addr = name = None
-
- if not addr and not name:
- pass # It's just an empty row
- else:
- if not name:
- errs = nerrs.setdefault(i, list())
- errs.append("The name field is empty; it is required")
- elif BrokerRegistration.selectBy(name=name).count():
- errs = nerrs.setdefault(i, list())
- errs.append("A broker called '%s' already exists" %
name)
-
- if not addr:
- errs = aerrs.setdefault(i, list())
- errs.append("The address field is empty; it is required")
- else:
- try:
- parse_broker_addr(addr)
- except:
- errs = aerrs.setdefault(i, list())
- errs.append("The address is malformed")
- break
-
- count = BrokerRegistration.selectBy \
- (url=addr).count()
-
- if count:
- errs = aerrs.setdefault(i, list())
- errs.append("The broker at %s " % (url) +
- "is already registered")
-
- return not len(nerrs) and not len(aerrs)
-
def render_title(self, session):
- return "Register New Brokers"
+ return "Managent Servers"
- class Errors(Attribute):
- def get_default(self, session):
- return dict()
-
- class More(Parameter):
- def get_default(self, session):
- return ""
-
- def process_display(self, session):
- if self.more.get(session):
- self.fields.set(session, self.fields.get(session) + 3)
-
- def render_fields(self, session):
- writer = Writer()
-
- for i in range(self.fields.get(session)):
- self.field_tmpl.render(writer, session, i)
-
- return writer.to_string()
-
- def render_field_name_name(self, session, index):
- return self.names.path
-
- def render_field_name_value(self, session, index):
- names = self.names.get(session)
- if len(names) > index:
- return names[index]
-
- def render_field_name_errors(self, session, index):
- errors = self.name_errors.get(session)
- if index in errors:
- return "<ul
class=\"errors\"><li>%s</li></ul>" % \
- "</li><li>".join(errors[index])
-
- def render_field_address_name(self, session, index):
- return self.addrs.path
-
- def render_field_address_value(self, session, index):
- addrs = self.addrs.get(session)
- if len(addrs) > index:
- return addrs[index]
-
- def render_field_address_errors(self, session, index):
- errors = self.addr_errors.get(session)
- if index in errors:
- return "<ul
class=\"errors\"><li>%s</li></ul>" % \
- "</li><li>".join(errors[index])
-
- def render_more_id(self, session):
- return self.more_button.path
-
- def render_more_name(self, session):
- return self.more.path
-
- class MoreEntries(FormButton):
- def render_content(self, session):
- return "More Entries"
-
- def render_class(self, session):
- return "more"
-
- def render_type(self, session):
- return "button"
-
-class ManagementServerSetRemove(CuminSetActionForm, Frame):
- def __init__(self, app, name):
- action = app.model.management_server.remove_set
- object = BrokerRegistrationParameter(app, "item")
-
- super(ManagementServerSetRemove, self).__init__ \
- (app, name, action, object)
-from mint import *
-from wooly import *
-from wooly.widgets import *
-
-from widgets import *
-from modelwidgets import *
-from parameters import *
-from formats import *
-from util import *
-
-strings = StringCatalog(__file__)
-
-class ManagementServerSet(CuminClassTable):
- def __init__(self, app, name):
- cls = app.model.management_server
-
- super(ManagementServerSet, self).__init__(app, name, cls)
-
- col = self.NameColumn(app, "name")
- self.add_column(col)
-
- col = self.UrlColumn(app, "url")
- self.add_column(col)
-
- col = self.StatusColumn(app, "status")
- self.add_column(col)
-
class NameColumn(SqlTableColumn):
def render_title(self, session, data):
return "Name"
@@ -454,11 +228,3 @@
def render_type(self, session):
return "button"
-
-class ManagementServerSetRemove(CuminSetActionForm, Frame):
- def __init__(self, app, name):
- action = app.model.management_server.remove_set
- object = BrokerRegistrationParameter(app, "item")
-
- super(ManagementServerSetRemove, self).__init__ \
- (app, name, action, object)
Modified: mgmt/trunk/cumin/python/cumin/messaging/binding.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/binding.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/binding.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -6,7 +6,6 @@
from wooly.resources import StringCatalog
from cumin.util import sorted_by
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.formats import *
import main
Modified: mgmt/trunk/cumin/python/cumin/messaging/broker.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/broker.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/broker.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -3,7 +3,6 @@
from wooly.widgets import *
from random import random
from psycopg2 import IntegrityError
-from cumin.modelwidgets import *
from cumin.widgets import *
from cumin.parameters import *
from cumin.formats import *
@@ -148,50 +147,12 @@
for vhost in Vhost.selectBy(broker=broker, name="/"):
return vhost
-class BrokerStatus(CuminStatus):
- def __init__(self, app, name, vhost):
- super(BrokerStatus, self).__init__(app, name)
-
- self.vhost = vhost
-
- self.connected = self.ConnectedAttribute(app, "conn")
- self.add_attribute(self.connected)
-
- def render_status(self, session, object):
- if self.connected.get(session):
- return "Connected"
- else:
- return "Disconnected"
-
- def render_color(self, session, object):
- if self.connected.get(session):
- return "green"
- else:
- return "yellow"
-
- class ConnectedAttribute(Attribute):
- def get_default(self, session):
- connected = False
- broker = self.widget.frame.get_object(session)
-
- try:
- id = broker.qmfBrokerId
- mbroker = self.app.model.mint.model.mintBrokersById[id]
- connected = mbroker.connected
- except KeyError:
- pass
-
- return connected
-
class BrokerView(CuminView):
def __init__(self, app, name, vhost):
super(BrokerView, self).__init__(app, name)
self.vhost = vhost
- status = BrokerStatus(app, "status", vhost)
- self.add_child(status)
-
tabs = TabbedModeSet(app, "tabs")
self.add_child(tabs)
Modified: mgmt/trunk/cumin/python/cumin/messaging/broker.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/broker.strings 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/broker.strings 2009-07-02 15:40:22 UTC (rev
3473)
@@ -35,13 +35,6 @@
</tbody>
</table>
-[BrokerStatus.html]
-<div id="{id}" class="CuminStatus {color}">
- <h2>Broker Status</h2>
-
- <div>{status}</div>
-</div>
-
[BrokerStats.html]
<table class="twocol">
<tbody>
Modified: mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/brokergroup.py 2009-07-02 15:40:22 UTC (rev
3473)
@@ -4,7 +4,6 @@
from wooly.forms import *
from cumin.model import *
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.parameters import *
from cumin.formats import *
from cumin.util import *
@@ -15,19 +14,36 @@
strings = StringCatalog(__file__)
-class BrokerGroupSet(CuminClassTable):
+class BrokerGroupSet(CuminSelectionTable):
def __init__(self, app, name):
- cls = app.model.broker_group
+ item = BrokerGroupParameter(app, "item")
+ super(BrokerGroupSet, self).__init__(app, name, item)
- super(BrokerGroupSet, self).__init__(app, name, cls)
-
- col = CuminClassNameColumn(app, "name", cls)
+ col = self.NameColumn(app, "name")
self.add_column(col)
+ self.set_default_column(col)
- self.add = TaskLink \
- (self.app, "add", main.module.broker_group_add, None)
- self.add_child(self.add)
+ task = main.module.broker_group_set_remove
+ button = TaskButton(self.app, "remove", task, self.selection)
+ self.buttons.add_child(button)
+ task = main.module.broker_group_add
+ link = TaskLink(self.app, "add", task, None)
+ self.links.add_child(link)
+
+ def render_title(self, session):
+ return "Broker Groups"
+
+ class NameColumn(SqlTableColumn):
+ def render_title(self, session, data):
+ return "Name"
+
+ def render_content(self, session, data):
+ group = Identifiable(data["id"])
+ href = self.page.main.messaging.broker_group.get_href \
+ (session, group)
+ return fmt_link(href, data["name"])
+
class BrokerGroupInputSet(CheckboxInputSet):
def __init__(self, app, name):
super(BrokerGroupInputSet, self).__init__(app, name, None)
@@ -132,7 +148,7 @@
def render_title(self, session):
group = self.group.get(session)
- return self.task.get_title(session, group)
+ return self.task.get_description(session, group)
class BrokerGroupRemoveForm(CuminTaskForm):
def __init__(self, app, name, task):
@@ -140,3 +156,12 @@
self.object = BrokerGroupParameter(app, "group")
self.add_parameter(self.object)
+
+class BrokerGroupSetTaskForm(CuminTaskForm):
+ def __init__(self, app, name, task):
+ super(BrokerGroupSetTaskForm, self).__init__(app, name, task)
+
+ item = BrokerGroupParameter(app, "item")
+
+ self.object = ListParameter(app, "brokergroup", item)
+ self.add_parameter(self.object)
Modified: mgmt/trunk/cumin/python/cumin/messaging/connection.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/connection.py 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/connection.py 2009-07-02 15:40:22 UTC (rev
3473)
@@ -4,7 +4,6 @@
from datetime import datetime
from cumin.stat import *
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.parameters import *
from cumin.formats import *
from cumin.util import *
Modified: mgmt/trunk/cumin/python/cumin/messaging/exchange.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/exchange.py 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/exchange.py 2009-07-02 15:40:22 UTC (rev
3473)
@@ -6,7 +6,6 @@
from wooly.resources import *
from cumin.stat import *
from cumin.model import *
-from cumin.modelwidgets import *
from cumin.widgets import *
from cumin.parameters import *
from cumin.formats import *
Modified: mgmt/trunk/cumin/python/cumin/messaging/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/main.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/main.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -24,6 +24,8 @@
self.broker_group_add = BrokerGroupAddTask(app, broker_group)
self.broker_group_edit = BrokerGroupEditTask(app, broker_group)
self.broker_group_remove = BrokerGroupRemoveTask(app, broker_group)
+ self.broker_group_set_remove = BrokerGroupSetRemoveTask \
+ (app, broker_group)
queue = app.model.queue
Modified: mgmt/trunk/cumin/python/cumin/messaging/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/model.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/model.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,8 +1,8 @@
from wooly import Session
+from cumin.model import *
from cumin.util import *
-from cumin.model import Task
from broker import *
from brokergroup import *
from brokerlink import *
@@ -176,7 +176,7 @@
def do_enter(self, session, queue):
self.form.queue.set(session, queue)
- def do_invoke(self, queue, exchange, binding_key, arguments):
+ def do_invoke(self, session, queue, exchange, binding_key, arguments):
session = self.app.model.get_session_by_object(queue)
session.exchange_bind(queue=queue.name, exchange=exchange.name,
binding_key=binding_key, arguments=arguments)
@@ -194,7 +194,7 @@
def do_enter(self, session, binding):
self.form.binding.set(session, binding)
- def do_invoke(self, binding):
+ def do_invoke(self, session, binding):
assert isinstance(binding, Binding)
session = self.app.model.get_session_by_object(binding)
@@ -326,7 +326,7 @@
host, port, durable, mech, username, password,
transport)
-class LinkRemoveTask(Task):
+class LinkRemoveTask(QmfTask):
def __init__(self, app, cls):
super(LinkRemoveTask, self).__init__(app, cls)
@@ -398,7 +398,7 @@
def get_title(self, session):
return "Add broker group"
- def do_invoke(self, object, name):
+ def do_invoke(self, session, object, name):
group = BrokerGroup(name=name)
group.syncUpdate()
return group
@@ -415,7 +415,7 @@
def do_enter(self, session, group):
self.form.group.set(session, group)
- def do_invoke(self, group, name):
+ def do_invoke(self, session, group, name):
assert isinstance(group, BrokerGroup)
group.set(name=name)
@@ -436,7 +436,7 @@
def do_exit(self, session, group):
self.app.main_page.main.messaging.view.show(session)
- def do_invoke(self, group):
+ def do_invoke(self, session, group):
assert isinstance(group, BrokerGroup)
group.destroySelf()
@@ -446,11 +446,11 @@
def __init__(self, app, cls):
super(BrokerGroupSetRemoveTask, self).__init__(app, cls)
- self.form = BrokerGroupSetRemoveForm(app, "broker_groups_remove",
self)
+ self.form = BrokerGroupSetTaskForm(app, "broker_groups_remove", self)
self.item_task = BrokerGroupRemoveTask(app, cls)
def do_enter(self, session, groups):
- self.form.groups.set(session, groups)
+ self.form.object.set(session, groups)
class BrokerEngroupTask(Task):
def get_title(self, session):
@@ -473,7 +473,7 @@
def do_enter(self, session, brokers):
self.form.object.set(session, brokers)
- def do_invoke(self, brokers):
+ def do_invoke(self, session, brokers):
pass
def get_vhost_name(vhost):
Modified: mgmt/trunk/cumin/python/cumin/messaging/queue.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -10,7 +10,6 @@
from sqlobject.sqlbuilder import LEFTJOINOn
from cumin.stat import *
from cumin.widgets import *
-from cumin.modelwidgets import *
from cumin.parameters import *
from cumin.formats import *
from cumin.util import *
Modified: mgmt/trunk/cumin/python/cumin/messaging/queue.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/queue.strings 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/messaging/queue.strings 2009-07-02 15:40:22 UTC (rev
3473)
@@ -51,32 +51,6 @@
[TopQueueSet.count_sql]
--
-[QueueStatus.html]
-<div id="{id}" class="CuminStatus {color}">
- <table>
- <tr>
- <th></th>
- <th style="width: 35%;"
class="ralign">Messages</th>
- <th style="width: 35%;" class="ralign">Bytes</th>
- </tr>
- <tr>
- <th>Enqueued</th>
- <td class="ralign">{messages_enqueued}</td>
- <td class="ralign">{bytes_enqueued}</td>
- </tr>
- <tr>
- <th>Dequeued</th>
- <td class="ralign">{messages_dequeued}</td>
- <td class="ralign">{bytes_dequeued}</td>
- </tr>
- <tr>
- <th>Depth</th>
- <td class="ralign">{message_depth}</td>
- <td class="ralign">{byte_depth}</td>
- </tr>
- </table>
-</div>
-
[QueueStats.html]
<ul class="radiotabs tabs">{tabs}</ul>
<div class="radiotabs mode">{content}</div>
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/model.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,4 +1,5 @@
import logging
+
from datetime import datetime, timedelta
from mint import Mint, MintConfig
from struct import unpack, calcsize
@@ -60,6 +61,7 @@
# Grid
CuminScheduler(self)
+ CuminSubmission(self)
CuminSubmitter(self)
CuminJob(self)
CuminJobGroup(self)
@@ -68,7 +70,6 @@
CuminPool(self)
CuminCollector(self)
CuminNegotiator(self)
- CuminMaster(self)
# Systems
@@ -149,6 +150,188 @@
return broker.getAmqpSession()
+class Task(object):
+ def __init__(self, app, cls):
+ self.app = app
+ self.cls = cls
+
+ self.form = None
+
+ self.aggregate = False
+
+ if self.cls:
+ if self.__class__ not in self.cls.tasks_by_class:
+ self.cls.add_task(self)
+
+ # make this take app? XXX
+ def init(self):
+ if self.form:
+ self.app.form_page.modes.add_mode(self.form)
+ else:
+ log.debug("Task %s has no form associated with it", self)
+
+ def get_title(self, session):
+ raise Exception("Not implemented")
+
+ def is_enabled(self, session, object):
+ return True
+
+ def get_description(self, session, object):
+ verb = self.get_title(session)
+
+ if object is None:
+ text = verb
+ else:
+ cls = self.cls.get_title(session)
+ obj = self.cls.get_object_name(object)
+ text = "%s %s '%s'" % (verb, cls, obj)
+
+ return text
+
+ def get_href(self, session, object):
+ return self.enter(session, object).marshal()
+
+ def enter(self, session, object):
+ nsession = wooly.Session(self.app.form_page)
+
+ self.form.return_url.set(nsession, session.marshal())
+ self.form.show(nsession)
+
+ self.do_enter(nsession, object)
+
+ return nsession
+
+ def do_enter(self, session, object):
+ pass
+
+ def exit_with_redirect(self, session, object):
+ osession = self.exit(session, object)
+ self.form.page.set_redirect_url(session, osession.marshal())
+
+ def exit(self, session, object):
+ url = self.form.return_url.get(session)
+ osession = wooly.Session.unmarshal(self.app, url)
+
+ self.do_exit(osession, object)
+
+ return osession
+
+ def do_exit(self, session, object):
+ pass
+
+ def invoke(self, session, object, *args, **kwargs):
+ invoc = self.start(session, object)
+
+ try:
+ result = self.do_invoke(session, object, *args, **kwargs)
+
+ self.end(invoc)
+ except Exception, e:
+ self.exception(invoc, e)
+
+ def do_invoke(self, *args, **kwargs):
+ raise Exception("Not implemented")
+
+ def start(self, session, object):
+ now = datetime.now()
+ subject = session.user_session.subject
+
+ invoc = TaskInvocation(self, subject, object)
+ invoc.status = invoc.PENDING
+ invoc.start_time = now
+ invoc.last_change_time = now
+
+ self.app.model.task_invocations.append(invoc)
+
+ return invoc
+
+ def end(self, invoc):
+ now = datetime.now()
+
+ invoc.status = invoc.OK
+ invoc.end_time = now
+ invoc.last_change_time = now
+
+ def exception(self, invoc, e):
+ now = datetime.now()
+
+ invoc.status = invoc.FAILED
+ invoc.end_time = now
+ invoc.last_change_time = now
+ invoc.exception = e
+
+ log.exception(e)
+
+ def __str__(self):
+ return "%s.%s" % (self.__module__, self.__class__.__name__)
+
+class SetTask(Task):
+ def __init__(self, app, cls):
+ super(SetTask, self).__init__(app, cls)
+
+ self.item_task = None
+ self.aggregate = True
+
+ def init(self):
+ super(SetTask, self).init()
+
+ if not self.item_task:
+ raise Exception("Task %s has no item task" % self)
+
+ def get_title(self, session):
+ return self.item_task.get_title(session)
+
+ def get_description(self, session, objects):
+ verb = self.item_task.get_title(session)
+ cls = self.cls.get_title(session)
+ count = len(objects)
+ return "%s %i %s" % (verb, count, conjugate(cls, count))
+
+ def invoke(self, session, objects, *args, **kwargs):
+ for object in objects:
+ self.item_task.invoke(session, object, *args, **kwargs)
+
+class QmfTask(Task):
+ def invoke(self, session, object, *args, **kwargs):
+ invoc = self.start(session, object)
+
+ def completion(status_code, output_args):
+ invoc.last_change_time = datetime.now()
+
+ if status_code == 0:
+ invoc.status = invoc.OK
+ else:
+ invoc.status = invoc.FAILED
+
+ invoc.status_code = status_code
+ invoc.output_args = output_args
+
+ try:
+ self.do_invoke(completion, session, object, *args, **kwargs)
+ except Exception, e:
+ self.exception(invoc, e)
+
+ def do_invoke(self, completion, session, object, *args, **kwargs):
+ raise Exception("Not implemented")
+
+class TaskInvocation(object):
+ PENDING = "pending"
+ FAILED = "failed"
+ OK = "ok"
+
+ def __init__(self, task, subject, object):
+ self.task = task
+ self.subject = subject
+ self.object = object
+ self.start_time = None
+ self.end_time = None
+ self.last_change_time = None
+ self.status = None
+ self.exception = None
+
+ self.status_code = None
+ self.output_args = None
+
class CuminProperty(object):
def __init__(self, cls, name):
self.model = cls.model
@@ -830,10 +1013,6 @@
stat = CuminStat(self, "procRunning")
stat.title = "Running processes"
- #action = CuminAction(self, "ping")
- #action.title = "Send Ping"
- #action.summary = True
-
def init(self):
super(CuminSystem, self).init()
@@ -854,43 +1033,6 @@
text = value and "%0.2f" % value or ""
return text
-class CuminMaster(RemoteClass):
- def __init__(self, model):
- super(CuminMaster, self).__init__(model, "master", Master,
MasterStats)
-
- self.Start(self, "start")
- self.Stop(self, "stop")
-
- def get_title(self, session):
- return "System"
-
- def get_icon_href(self, session):
- return "resource?name=system-36.png"
-
- def show_object(self, session, system):
- return self.model.frame.inventory.system.show_object(session, system)
-
- def get_object_name(self, object):
- return object.Name
-
- class Start(CuminAction):
- def do_invoke(self, object, args, completion):
- system_name = object.System
- try:
- master = Master.select("System = '%s'" %
system_name)[0]
- except IndexError:
- raise Exception("Master daemon not running")
- master.Start(self.mint.model, completion, args["subsystem"])
-
- class Stop(CuminAction):
- def do_invoke(self, object, args, completion):
- system_name = object.System
- try:
- master = Master.select("System = '%s'" %
system_name)[0]
- except IndexError:
- raise Exception("Master daemon not running")
- #master.Stop(self.mint.model, completion, args["subsystem"])
-
class CuminBroker(RemoteClass):
def __init__(self, model):
super(CuminBroker, self).__init__(model, "broker", Broker,
BrokerStats)
@@ -937,10 +1079,6 @@
def get_title(self, session):
return "Broker"
-# def show_object(self, session, broker):
-# reg = broker.registration
-# return super(CuminBroker, self).show_object(session, reg)
-
def get_object_name(self, broker):
try:
host, port = broker.system.nodeName, broker.port
@@ -1368,50 +1506,9 @@
stat.title = "Attached"
stat.category = "general"
- self.ResetLifespan(self, "resetLifespan")
- self.SolicitAck(self, "solicitAck")
-
def get_title(self, session):
return "Session"
- class Close(CuminAction):
- def get_title(self, session):
- return "Close"
-
- def do_invoke(self, sess, args, completion):
- for broker in self.mint.model.mintBrokersByQmfBroker:
- if sess.name == broker.getSessionId():
- raise Exception \
- ("Cannot close management session %s" % sess.name)
-
- sess.close(self.mint.model, completion)
-
- class Detach(CuminAction):
- def get_title(self, session):
- return "Detach"
-
- def do_invoke(self, sess, args, completion):
- for broker in self.mint.model.mintBrokersByQmfBroker:
- if sess.name == broker.getSessionId():
- raise Exception \
- ("Cannot detach management session %s" % sess.name)
-
- sess.detach(self.mint.model, completion)
-
- class ResetLifespan(CuminAction):
- def get_title(self, session):
- return "Reset Lifespan"
-
- def do_invoke(self, object, args, completion):
- object.resetLifespan(self.mint.model, completion)
-
- class SolicitAck(CuminAction):
- def get_title(self, session):
- return "Solicit Acknowledgment"
-
- def do_invoke(self, object, args, completion):
- object.solicitAck(self.mint.model, completion)
-
class CuminLink(RemoteClass):
def __init__(self, model):
super(CuminLink, self).__init__(model, "link", Link, LinkStats)
@@ -1596,11 +1693,6 @@
prop.title = "URL"
prop.summary = True
- action = self.AddSet(self, "add")
- action.navigable = False
-
- action = self.RemoveSet(self, "remove_set")
-
def init(self):
super(CuminManagementServer, self).init()
@@ -1612,41 +1704,6 @@
def get_icon_href(self, session):
return "resource?name=broker-36.png"
- class AddSet(CuminAction):
- def get_title(self, session):
- return "Add Management Servers"
-
- def show(self, session, object):
- frame = self.model.frame.home.mservers_add
- frame.show(session)
-
- def do_invoke(self, object, args, completion):
- try:
- object = self.cumin_class.mint_class(**args)
-
- completion("OK")
-
- return object
- except Exception, e:
- log.exception("Action failed")
- completion(e.message or "failed")
-
- class RemoveSet(CuminSetAction):
- def get_title(self, session):
- return "Remove"
-
- def show(self, session, objects):
- frame = self.model.frame.home.mservers_remove
- frame.objects.set(session, objects)
- return frame.show(session)
-
- def do_invoke(self, servers, args, completion):
- for server in servers:
- server.destroySelf()
- server.syncUpdate()
-
- completion("OK")
-
class CuminBrokerGroup(CuminClass):
def __init__(self, model):
super(CuminBrokerGroup, self).__init__ \
@@ -1687,9 +1744,6 @@
prop.title = "Collector"
prop.summary = True
- action = self.SeeAllPools(self, "allpools")
- action.summary = True
-
def init(self):
super(CuminPool, self).init()
@@ -1709,15 +1763,6 @@
def get_icon_href(self, session):
return "resource?name=pool-36.png"
- class SeeAllPools(CuminAction):
- def get_title(self, session):
- return "See All Pools"
-
- def get_href(self, session, object):
- branch = session.branch()
- self.model.frame.grid.view.show(branch)
- return branch.marshal()
-
class StatusStat(CuminStat):
def value_text(self, record):
if record:
@@ -2103,56 +2148,6 @@
return self.job_output and
"<fetch><output>%s</output><tail>%s</tail></fetch>"
% (escape_entity(self.job_output), tail)
- class Hold(CuminAction):
- def show(self, session, job):
- frame = self.model.frame.grid.pool.jobs_hold.show(session)
- frame.ids.set(session, [job.id])
- return frame
-
- def get_title(self, session):
- return "Hold"
-
- def do_invoke(self, job, reason, completion):
- job.Hold(self.mint.model, completion, reason)
-
- def get_enabled(self, session, job):
- is_held = JobStatusInfo.get_status_int("Held") == job.JobStatus
- is_deleted = job.qmfDeleteTime is not None
- return not (is_held or is_deleted)
-
- class Release(CuminAction):
- def show(self, session, job):
- frame = self.model.frame.grid.pool.jobs_release.show(session)
- frame.ids.set(session, [job.id])
- return frame
-
- def get_title(self, session):
- return "Release"
-
- def do_invoke(self, job, reason, completion):
- job.Release(self.mint.model, completion, reason)
-
- def get_enabled(self, session, job):
- is_held = JobStatusInfo.get_status_int("Held") == job.JobStatus
- is_deleted = job.qmfDeleteTime is not None
- return is_held and not is_deleted
-
- class Remove(CuminAction):
- def show(self, session, job):
- frame = self.model.frame.grid.pool.jobs_remove.show(session)
- frame.ids.set(session, [job.id])
- return frame
-
- def get_title(self, session):
- return "Remove"
-
- def do_invoke(self, job, reason, completion):
- job.Remove(self.mint.model, completion, reason)
-
- def get_enabled(self, session, job):
- is_deleted = job.qmfDeleteTime is not None
- return not is_deleted
-
class SetAttribute(CuminAction):
def show(self, session, job):
pass
@@ -2234,6 +2229,35 @@
def get_object_name(self, sched):
return sched.Name
+class CuminSubmission(RemoteClass):
+ def __init__(self, model):
+ super(CuminSubmission, self).__init__(model, "submission",
+ Submission, SubmissionStats)
+
+ prop = CuminProperty(self, "Name")
+ prop.title = "Name"
+
+ stat = CuminStat(self, "Idle")
+ stat.title = "Idle Jobs"
+
+ stat = CuminStat(self, "Running")
+ stat.title = "Running Jobs"
+
+ stat = CuminStat(self, "Removed")
+ stat.title = "Removed Jobs"
+
+ stat = CuminStat(self, "Completed")
+ stat.title = "Completed Jobs"
+
+ stat = CuminStat(self, "Held")
+ stat.title = "Held Jobs"
+
+ def get_title(self, session):
+ return "Submission"
+
+ def get_object_name(self, sub):
+ return sub.Name
+
class CuminSubmitter(RemoteClass):
def __init__(self, model):
super(CuminSubmitter, self).__init__(model, "submitter",
@@ -2254,7 +2278,7 @@
def init(self):
super(CuminSubmitter, self).init()
- self.frame = self.model.frame.grid.pool.submitter
+ self.frame = self.model.frame.grid.pool.scheduler.submitter
def get_title(self, session):
return "Submitter"
@@ -2398,227 +2422,16 @@
def get_title(self, session):
return "Subject"
-class CallPage(Page):
- def __init__(self, app, name):
- super(CallPage, self).__init__(app, name)
+class JobGroup(object):
+ def __init__(self, id):
+ self.id = id
- self.__class = CuminClassParameter(app, "class")
- self.add_parameter(self.__class)
+ def get_id(self):
+ return self.id
- self.__id = IntegerParameter(app, "id")
- self.add_parameter(self.__id)
+class Limit(object):
+ def __init__(self, id):
+ self.id = id
- self.__method = Parameter(app, "method")
- self.add_parameter(self.__method)
-
- self.__args = Parameter(app, "xargs")
- self.add_parameter(self.__args)
-
- def get_content_type(self, session):
- return Page.xml_content_type
-
- def do_render(self, session):
- writer = Writer()
- writer.write(Page.xml_1_0_declaration)
-
- cls = self.__class.get(session)
- id = self.__id.get(session)
- xargs = self.__args.get(session)
-
- if cls:
- object = cls.mint_class.get(id)
- method = self.__method.get(session)
- for action in cls.actions:
- if action.name == method:
- args = xargs and xargs.split("&") or list()
- data = action.get_xml_response(session, object, *args)
- self.write_xml(writer, data)
-
- return writer.to_string()
-
- def write_xml(self, writer, data):
- writer.write("<data>")
- writer.write(data)
- writer.write("</data>")
-
-class Task(object):
- def __init__(self, app, cls):
- self.app = app
- self.cls = cls
-
- self.form = None
-
- self.aggregate = False
-
- if self.cls:
- if self.__class__ not in self.cls.tasks_by_class:
- self.cls.add_task(self)
-
- # make this take app? XXX
- def init(self):
- if self.form:
- self.app.form_page.modes.add_mode(self.form)
- else:
- log.debug("Task %s has no form associated with it", self)
-
- def get_title(self, session):
- raise Exception("Not implemented")
-
- def is_enabled(self, session, object):
- return True
-
- def get_description(self, session, object):
- verb = self.get_title(session)
-
- if object is None:
- text = verb
- else:
- cls = self.cls.get_title(session)
- obj = self.cls.get_object_name(object)
- text = "%s %s '%s'" % (verb, cls, obj)
-
- return text
-
- def get_href(self, session, object):
- return self.enter(session, object).marshal()
-
- def enter(self, session, object):
- nsession = wooly.Session(self.app.form_page)
-
- self.form.return_url.set(nsession, session.marshal())
- self.form.show(nsession)
-
- self.do_enter(nsession, object)
-
- return nsession
-
- def do_enter(self, session, object):
- pass
-
- def exit_with_redirect(self, session, object):
- osession = self.exit(session, object)
- self.form.page.set_redirect_url(session, osession.marshal())
-
- def exit(self, session, object):
- url = self.form.return_url.get(session)
- osession = wooly.Session.unmarshal(self.app, url)
-
- self.do_exit(osession, object)
-
- return osession
-
- def do_exit(self, session, object):
- pass
-
- def invoke(self, session, object, *args, **kwargs):
- invoc = self.start(session, object)
-
- try:
- result = self.do_invoke(session, object, *args, **kwargs)
-
- self.end(invoc)
- except Exception, e:
- self.exception(invoc, e)
-
- def do_invoke(self, *args, **kwargs):
- raise Exception("Not implemented")
-
- def start(self, session, object):
- now = datetime.now()
- subject = session.user_session.subject
-
- invoc = TaskInvocation(self, subject, object)
- invoc.status = invoc.PENDING
- invoc.start_time = now
- invoc.last_change_time = now
-
- self.app.model.task_invocations.append(invoc)
-
- return invoc
-
- def end(self, invoc):
- now = datetime.now()
-
- invoc.status = invoc.OK
- invoc.end_time = now
- invoc.last_change_time = now
-
- def exception(self, invoc, e):
- now = datetime.now()
-
- invoc.status = invoc.FAILED
- invoc.end_time = now
- invoc.last_change_time = now
- invoc.exception = e
-
- log.exception(e)
-
- def __str__(self):
- return "%s.%s" % (self.__module__, self.__class__.__name__)
-
-class SetTask(Task):
- def __init__(self, app, cls):
- super(SetTask, self).__init__(app, cls)
-
- self.item_task = None
- self.aggregate = True
-
- def init(self):
- super(SetTask, self).init()
-
- if not self.item_task:
- raise Exception("Task %s has no item task" % self)
-
- def get_title(self, session):
- return self.item_task.get_title(session)
-
- def get_description(self, session, objects):
- verb = self.item_task.get_title(session)
- cls = self.cls.get_title(session)
- count = len(objects)
- return "%s %i %s" % (verb, count, conjugate(cls, count))
-
- def invoke(self, session, objects, *args, **kwargs):
- for object in objects:
- self.item_task.invoke(session, object, *args, **kwargs)
-
-class QmfTask(Task):
- def invoke(self, session, object, *args, **kwargs):
- invoc = self.start(session, object)
-
- def completion(status_code, output_args):
- invoc.last_change_time = datetime.now()
-
- if status_code == 0:
- invoc.status = invoc.OK
- else:
- invoc.status = invoc.FAILED
-
- invoc.status_code = status_code
- invoc.output_args = output_args
-
- try:
- self.do_invoke(completion, session, object, *args, **kwargs)
- except Exception, e:
- self.exception(invoc, e)
-
- def do_invoke(self, completion, session, object, *args, **kwargs):
- raise Exception("Not implemented")
-
-class TaskInvocation(object):
- PENDING = "pending"
- FAILED = "failed"
- OK = "ok"
-
- def __init__(self, task, subject, object):
- self.task = task
- self.subject = subject
- self.object = object
- self.start_time = None
- self.end_time = None
- self.last_change_time = None
- self.status = None
- self.exception = None
-
- self.status_code = None
- self.output_args = None
+ def get_id(self):
+ return self.id
Deleted: mgmt/trunk/cumin/python/cumin/modelwidgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/modelwidgets.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/modelwidgets.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,212 +0,0 @@
-from wooly import *
-from wooly.forms import *
-
-from widgets import *
-from model import *
-from util import *
-
-from wooly.widgets import Link
-
-strings = StringCatalog(__file__)
-
-class CuminActionButton(FormButton):
- def __init__(self, app, name, action, object=None):
- super(CuminActionButton, self).__init__(app, name)
-
- self.action = action
- self.object = object
-
- def process_submit(self, session, *args):
- object = None
-
- if self.object:
- object = self.object.get(session)
-
- url = self.action.get_href(session, object)
- self.page.set_redirect_url(session, url)
-
- def render_content(self, session, *args):
- return self.action.get_title(session)
-
-class CuminActionLink(Link):
- def __init__(self, app, name, action, object=None):
- super(CuminActionLink, self).__init__(app, name)
-
- self.action = action
- self.object = object
-
- def edit_session(self, session, *args):
- object = None
-
- if self.object:
- object = self.object.get(session)
-
- self.action.show(session, object)
-
- def render_content(self, session, *args):
- return self.action.get_title(session)
-
-class CuminActionForm(CuminFieldForm):
- def __init__(self, app, name, action, object=None):
- super(CuminActionForm, self).__init__(app, name)
-
- self.action = action
- self.object = object
-
- def render_title(self, session, *args):
- return self.action.get_summary(session, self.object.get(session))
-
- def process_submit(self, session, *args):
- object = None
-
- if self.object:
- object = self.object.get(session)
-
- self.action.invoke(object)
-
- self.process_cancel(session, *args)
-
-class CuminSetActionForm(CuminForm):
- def __init__(self, app, name, action, object):
- super(CuminSetActionForm, self).__init__(app, name)
-
- assert isinstance(action, CuminAction)
- assert action.aggregate
- assert isinstance(object, Parameter)
-
- self.action = action
-
- self.objects = ListParameter(app, "param", object)
- self.add_parameter(self.objects)
-
- body = self.SetActionBody(app, "body")
- self.add_child(body)
-
- def render_title(self, session, *args):
- return self.action.get_summary(session, self.objects.get(session))
-
- def process_submit(self, session, *args):
- self.action.invoke(self.objects.get(session))
-
- self.objects.set(session, None)
-
- self.process_cancel(session, *args)
-
- class SetActionBody(ItemSet):
- def render_message(self, session, *args):
- verb = self.parent.action.get_title(session)
- noun = self.parent.action.cumin_class.get_plural_title(session)
-
- return "%s the following %s" % (verb, noun)
-
- def do_get_items(self, session, *args):
- return self.parent.objects.get(session)
-
- def render_item_content(self, session, item):
- cls = self.parent.action.cumin_class
- return cls.get_object_title(session, item)
-
-class CuminClassTable(CuminTableWithControls, Form):
- def __init__(self, app, name, cumin_class):
- super(CuminClassTable, self).__init__(app, name)
-
- self.cumin_class = cumin_class
-
- self.selection = CuminClassCheckboxColumn(app, "id", self.cumin_class)
- self.add_column(self.selection)
-
- self.actions = WidgetSet(app, "actions")
- self.actions.html_class = "actions"
- self.add_child(self.actions)
-
- actions = [x for x in self.cumin_class.actions if x.aggregate]
-
- for action in actions:
- button = CuminActionButton \
- (app, action.name, action, self.selection.param)
- self.actions.add_child(button)
-
- self.add = None
-
- if hasattr(self.cumin_class, "add"):
- self.add = CuminActionLink(app, "add", self.cumin_class.add)
- self.add.html_class = "action"
- self.add_child(self.add)
-
- def render_title(self, session, *args):
- title = self.cumin_class.get_plural_title(session)
- count = fmt_count(self.cumin_class.mint_class.select().count())
-
- return "%s %s" % (title, count)
-
- def render_plural_title(self, session, *args):
- return self.cumin_class.get_plural_title(session)
-
- def render_add_link(self, session, *args):
- if self.add:
- return self.add.render(session, *args)
-
- def render_actions(self, session, *args):
- if self.actions.children:
- return self.actions.render(session, *args)
-
-class CuminClassCheckboxColumn(CheckboxInputColumn):
- def __init__(self, app, name, cumin_class):
- item = CuminObjectParameter(app, "item", cumin_class)
-
- super(CuminClassCheckboxColumn, self).__init__(app, name, item)
-
- self.cumin_class = cumin_class
-
-class CuminClassNameColumn(SqlTableColumn):
- def __init__(self, app, name, cumin_class):
- super(CuminClassNameColumn, self).__init__(app, name)
-
- self.cumin_class = cumin_class
-
- self.id_column = "id"
- self.name_column = "name"
-
- def render_title(self, session, data):
- return "Name"
-
- def render_content(self, session, data):
- id = data[self.id_column]
- name = data[self.name_column]
-
- href = self.cumin_class.get_object_href_by_id(session, id)
-
- return fmt_link(href, name)
-
-class TaskLink(Link):
- def __init__(self, app, name, task, param):
- super(TaskLink, self).__init__(app, name)
-
- self.task = task
- self.param = param
-
- def get(self, session):
- if self.param:
- return self.param.get(session)
-
- def render_href(self, session):
- return self.task.get_href(session, self.get(session))
-
- def render_content(self, session):
- return self.task.get_title(session)
-
-class TaskButton(FormButton):
- def __init__(self, app, name, task, set_param):
- super(TaskButton, self).__init__(app, name)
-
- self.task = task
- self.set_param = set_param
-
- def process_submit(self, session):
- items = self.set_param.get(session)
-
- href = self.task.get_href(session, items)
- self.page.set_redirect_url(session, href)
-
- def render_content(self, session):
- return self.task.get_title(session)
Deleted: mgmt/trunk/cumin/python/cumin/modelwidgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/modelwidgets.strings 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/modelwidgets.strings 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,43 +0,0 @@
-[SetActionBody.html]
-<h2>{message}</h2>
-<ul>{items}</ul>
-
-[CuminClassTable.css]
-.CuminClassTable div.addlink {
- margin: 0 0 1em 0;
-}
-
-.CuminClassTable ul.actions {
- margin: 0;
- display: inline;
-}
-
-.CuminClassTable ul.actions li {
- display: inline;
-}
-
-[CuminClassTable.html]
-<form class="CuminClassTable" id="{id}" method="post"
action="?">
- <div class="addlink">{add_link}</div>
-
- {switches}
-
- {filters}
-
- <div class="sactions">Act on Selected {plural_title}:
{actions}</div>
-
- <table class="mobjects">
- <thead>
- <tr>
- <th class="setnav" colspan="{column_count}">
- <div class="rfloat">{page}</div>
- {count}
- </th>
- </tr>
- <tr>{headers}</tr>
- </thead>
- <tbody>{items}</tbody>
- </table>
-
- <div>{hidden_inputs}</div>
-</form>
Deleted: mgmt/trunk/cumin/python/cumin/page.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/page.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/page.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,97 +0,0 @@
-from wooly import *
-from wooly.widgets import *
-from wooly.resources import *
-
-from managementserver import *
-from user import *
-from action import *
-from widgets import *
-from util import *
-
-# XXX For the top-N sets; these should go away soon
-import messaging
-import grid
-import inventory
-
-strings = StringCatalog(__file__)
-
-class MainPage(CuminPage, ModeSet):
- def __init__(self, app, name):
- super(MainPage, self).__init__(app, name)
-
- self.main = MainView(app, "main")
- self.add_mode(self.main)
- self.set_default_frame(self.main)
-
- def render_title(self, session):
- return "MRG Management"
-
-class MainView(CuminMainView):
- def __init__(self, app, name):
- super(MainView, self).__init__(app, name)
-
- self.home = HomeFrame(app, "home")
- self.add_tab(self.home)
-
-class HomeFrame(CuminFrame):
- def __init__(self, app, name):
- super(HomeFrame, self).__init__(app, name)
-
- self.view = HomeView(app, "view")
- self.add_mode(self.view)
-
- self.mservers_add = ManagementServerSetAdd(app, "mserversadd")
- self.add_mode(self.mservers_add)
-
- self.mservers_remove = ManagementServerSetRemove(app,
"mserversremove")
- self.add_mode(self.mservers_remove)
-
- def render_title(self, session):
- return "Home"
-
-class HomeView(TabbedModeSet):
- def __init__(self, app, name):
- super(HomeView, self).__init__(app, name)
-
- heading = self.Heading(app, "heading")
- self.add_child(heading)
-
- self.add_tab(self.OverviewTab(app, "over"))
- self.add_tab(ManagementServerSet(app, "servers"))
-
- def render_change_password_href(self, session):
- return self.app.change_password.get_href(session, None)
-
- class Heading(CuminHeading):
- def render_title(self, session):
- return "Management Home"
-
- def render_icon_href(self, session):
- return "resource?name=action-36.png"
-
- class OverviewTab(Widget):
- def __init__(self, app, name):
- super(HomeView.OverviewTab, self).__init__(app, name)
-
- notice = self.ManagementServerNotice(app, "notice")
- self.add_child(notice)
-
- queues = messaging.queue.TopQueueSet(app, "queues")
- self.add_child(queues)
-
- jobs = grid.job.TopJobSet(app, "jobs")
- self.add_child(jobs)
-
- systems = inventory.system.TopSystemSet(app, "systems")
- self.add_child(systems)
-
- def render_title(self, session):
- return "Overview"
-
- class ManagementServerNotice(Widget):
- def do_render(self, session):
- count = BrokerRegistration.select().count()
-
- if count == 0:
- return super(HomeView.OverviewTab.ManagementServerNotice,
- self).do_render(session)
Deleted: mgmt/trunk/cumin/python/cumin/page.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/page.strings 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/page.strings 2009-07-02 15:40:22 UTC (rev 3473)
@@ -1,101 +0,0 @@
-[HomeView.html]
-<div class="oblock">
- {heading}
-
- <ul class="TabbedModeSet tabs">{tabs}</ul>
- <div class="TabbedModeSet mode">{content}</div>
-</div>
-
-[OverviewTab.css]
-table.OverviewTab {
- width: 100%;
-}
-
-table.OverviewTab > tbody > tr > td {
- width: 50%;
- vertical-align: top;
-}
-
-h2 img {
- vertical-align: bottom;
- margin: 0 0.2em 0 0;
-}
-
-[OverviewTab.html]
-{notice}
-
-<table class="OverviewTab">
- <tbody>
- <tr>
- <td>
-<div class="fullpageable">
- <h2><img src="resource?name=queue-20.png"/> Busiest Message
Queues</h2>
-
- <div class="iblock">{queues}</div>
-</div>
- </td>
- <td>
-<div class="fullpageable">
- <h2><img src="resource?name=job-20.png"/> Longest Running
Grid Jobs</h2>
- <div class="iblock">{jobs}</div>
-</div>
- </td>
- </tr>
- <tr>
- <td>
-<div class="fullpageable">
- <h2><img src="resource?name=system-20.png"/> Busiest
Systems</h2>
-
- <div class="iblock">{systems}</div>
-</div>
- </td>
- <td>
- </td>
- </tr>
- </tbody>
-</table>
-
-[ManagementServerNotice.css]
-div.ManagementServerNotice {
- margin: 0 0 1em 0;
- border: 1px dotted #cec;
- padding: 1em;
- background-color: #dfd;
-}
-
-div.ManagementServerNotice img {
- vertical-align: top;
- float: left;
- margin: 0 0.5em 0.5em 0;
-}
-
-[ManagementServerNotice.html]
-<div class="ManagementServerNotice">
- <img src="resource?name=notice-36.png"/> This console is not
- registered with any management servers. Go to the 'Management Servers'
- tab above to add a new server.
-</div>
-
-[MessagingView.html]
-<div class="oblock">
- {heading}
-
- <ul class="TabbedModeSet tabs">{tabs}</ul>
- <div class="TabbedModeSet mode">{content}</div>
-</div>
-
-[GridView.html]
-<div class="oblock">
- {heading}
-
- <ul class="TabbedModeSet tabs">{tabs}</ul>
- <div class="TabbedModeSet mode">{content}</div>
-</div>
-
-[SystemsView.html]
-<div class="oblock">
- {heading}
-
- <ul class="TabbedModeSet tabs">{tabs}</ul>
- <div class="TabbedModeSet mode">{content}</div>
-</div>
Modified: mgmt/trunk/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/parameters.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/parameters.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -83,13 +83,6 @@
def do_marshal(self, job):
return str(job.id)
-class JobGroup(object):
- def __init__(self, id):
- self.id = id
-
- def get_id(self):
- return self.id
-
class JobGroupParameter(Parameter):
def do_unmarshal(self, string):
return JobGroup(string)
@@ -97,13 +90,6 @@
def do_marshal(self, job_group):
return str(job_group.id)
-class Limit(object):
- def __init__(self, id):
- self.id = id
-
- def get_id(self):
- return self.id
-
class LinkParameter(Parameter):
def do_unmarshal(self, string):
return Link.get(int(string))
Added: mgmt/trunk/cumin/python/cumin/server.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/server.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/server.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -0,0 +1,52 @@
+import logging
+
+from datetime import datetime, timedelta
+from wooly import *
+from wooly.server import WebServer
+
+from mint import Subject
+from cumin import UserSession
+
+log = logging.getLogger("cumin.server")
+
+class CuminServer(WebServer):
+ def authorized(self, session):
+ auth = False
+ page = session.page
+
+ if page in self.app.unprotected_pages:
+ return True
+
+ id = session.get_cookie("session")
+
+ if id is not None:
+ usess = self.app.user_sessions_by_id.get(id)
+
+ if usess is not None:
+ timeout = timedelta(seconds=3600)
+ now = datetime.now()
+
+ if now > usess.created and now < usess.created + timeout:
+ setattr(session, "user_session", usess)
+
+ return True
+
+ if self.app.config.user:
+ user = Subject.getByName(self.app.config.user)
+
+ assert user
+
+ usess = UserSession(self.app, user)
+ session.set_cookie("session", usess.id)
+
+ page.set_redirect_url(session, session.marshal())
+
+ return False
+
+ lpage = self.app.login_page
+ lsess = Session(lpage)
+ lpage.origin.set(lsess, session.marshal())
+
+ page.set_redirect_url(session, lsess.marshal())
+
+ return False
Modified: mgmt/trunk/cumin/python/cumin/tools.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/tools.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/tools.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -11,7 +11,9 @@
from time import sleep
from util import *
-from cumin import Cumin, CuminServer, CuminConfig
+from cumin import Cumin
+from cumin.config import CuminConfig
+from cumin.server import CuminServer
from test import *
def prompt_password():
Modified: mgmt/trunk/cumin/python/cumin/usergrid/main.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/usergrid/main.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/usergrid/main.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -3,9 +3,8 @@
from cumin.widgets import *
from cumin.util import *
+from cumin.grid.submission import *
-from submission import *
-
from wooly.widgets import Link
strings = StringCatalog(__file__)
@@ -15,9 +14,6 @@
app.user_grid_page = MainPage(app, "usergrid.html")
app.add_page(app.user_grid_page)
- app.form_page.submission_add = SubmissionForm(app, "submissionadd")
- app.form_page.modes.add_mode(app.form_page.submission_add)
-
module = UserGridModule()
class MainPage(CuminPage, ModeSet):
@@ -28,9 +24,6 @@
self.add_mode(self.main)
self.set_default_frame(self.main)
- self.submission_add = SubmissionForm(app, "submissionadd")
- self.add_mode(self.submission_add)
-
def render_title(self, session):
return "MRG Grid"
@@ -41,44 +34,23 @@
self.overview = OverviewFrame(app, "overview")
self.add_tab(self.overview)
- self.submission = SubmissionFrame(app, "submission")
+ self.submission = UserSubmissionSet(app, "submissions")
self.add_tab(self.submission)
- self.template = TemplateFrame(app, "template")
- self.add_tab(self.template)
-
- self.account = AccountFrame(app, "account")
- self.add_tab(self.account)
-
class OverviewFrame(Widget):
def render_title(self, session):
return "Overview"
-class SubmissionFrame(Widget):
+class UserSubmissionSet(SubmissionSet):
def __init__(self, app, name):
- super(SubmissionFrame, self).__init__(app, name)
+ super(UserSubmissionSet, self).__init__(app, name)
- link = self.SubmissionAddLink(app, "add")
- self.add_child(link)
+ self.scheduler_col.visible = False
+ self.submitter_col.visible = False
- def render_title(self, session):
- return "Submissions"
+ def render_sql_where(self, session):
+ pass
+ #return "where m.name = %(name)s"
- class SubmissionAddLink(Link):
- def render_content(self, session):
- return "Create New Submission"
-
- def render_href(self, session):
- form = self.app.form_page.submission_add
- sess = Session(self.app.form_page)
- form.show(sess)
- form.return_url.set(session, session.marshal())
- return sess.marshal()
-
-class TemplateFrame(Widget):
- def render_title(self, session):
- return "Templates"
-
-class AccountFrame(Widget):
- def render_title(self, session):
- return "Your Account"
+ def get_sql_values(self, session):
+ return {"name": session.user_session.subject.name}
Modified: mgmt/trunk/cumin/python/cumin/usergrid/submission.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/usergrid/submission.py 2009-07-01 17:30:11 UTC (rev
3472)
+++ mgmt/trunk/cumin/python/cumin/usergrid/submission.py 2009-07-02 15:40:22 UTC (rev
3473)
@@ -1,107 +0,0 @@
-import logging
-
-from wooly import *
-from cumin.widgets import *
-from cumin.util import *
-
-#strings = StringCatalog(__file__)
-log = logging.getLogger("cumin.usergrid.submission")
-
-class SubmissionForm(FieldSubmitForm):
- def __init__(self, app, name):
- super(SubmissionForm, self).__init__(app, name)
-
- self.template = self.TemplateField(app, "template")
- self.add_field(self.template)
-
- self.description = self.DescriptionField(app, "description")
- self.description.input.size = 50
- self.add_field(self.description)
-
- self.command = self.CommandField(app, "command")
- self.command.input.size = 50
- self.add_field(self.command)
-
- self.args = self.ArgumentsField(app, "args")
- self.args.input.size = 50
- self.add_field(self.args)
-
- self.inputs = self.InputsField(app, "inputs")
- self.add_field(self.inputs)
-
- self.outputs = self.OutputsField(app, "outputs")
- self.add_field(self.outputs)
-
- self.options = self.OptionsField(app, "options")
- self.add_field(self.options)
-
- def render_title(self, session):
- return "Create submission to pool 'wingspan'"
-
- class TemplateField(FormField):
- def __init__(self, app, name):
- super(SubmissionForm.TemplateField, self).__init__(app, name)
-
- param = Parameter(app, "param")
- self.add_parameter(param)
-
- self.input = self.TemplateSet(app, "inputs", param)
- self.add_child(self.input)
-
- def render_title(self, session):
- return "Template"
-
- class TemplateSet(OptionInputSet):
- def do_get_items(self, session):
- return ("Standard scene render", "Experimental")
-
- def render_item_value(self, session, item):
- return item
-
- def render_item_content(self, session, item):
- return item
-
- class DescriptionField(StringField):
- def render_title(self, session):
- return "Description"
-
- class CommandField(StringField):
- def render_title(self, session):
- return "Command"
-
- class ArgumentsField(StringField):
- def render_title(self, session):
- return "Arguments"
-
- class InputsField(MultilineStringField):
- def render_title(self, session):
- return "Inputs"
-
- class OutputsField(MultilineStringField):
- def render_title(self, session):
- return "Outputs"
-
- class OptionsField(CheckboxField):
- def __init__(self, app, name):
- super(SubmissionForm.OptionsField, self).__init__(app, name)
-
- self.add_option(self.SaveAsTemplate(app, "template"))
- self.add_option(self.UseCloud(app, "cloud"))
-
- def render_title(self, session):
- return "Options"
-
- class SaveAsTemplate(CheckboxFieldOption):
- def render_title(self, session):
- return "Save as template"
-
- class UseCloud(CheckboxFieldOption):
- def render_title(self, session):
- return "Use cloud"
-
-class SubmissionAdd(SubmissionForm):
- def __init__(self, app, name):
- super(SubmissionAdd, self).__init__(app, name)
-
- def process_submit(self, session):
- pass
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -9,42 +9,18 @@
from action import *
from parameters import *
+from widgets import *
from charts import *
from formats import *
from util import *
import time
+
from wooly import Session
+from wooly.widgets import Link
strings = StringCatalog(__file__)
-class CuminPage(HtmlPage):
- def __init__(self, app, name):
- super(CuminPage, self).__init__(app, name)
-
- self.__frames = self.FramesAttribute(app, "frames")
- self.add_attribute(self.__frames)
-
- self.__modal = Attribute(app, "modal")
- self.add_attribute(self.__modal)
-
- def save_session(self, session):
- if self.app.debug:
- self.app.debug.sessions.append(session)
-
- def set_modal(self, session, modal):
- self.__modal.set(session, modal)
-
- def get_frames(self, session):
- return self.__frames.get(session)
-
- def render_class(self, session):
- return self.__modal.get(session) and "modal" or "_"
-
- class FramesAttribute(Attribute):
- def get_default(self, session):
- return list()
-
class CuminHeartBeat(Widget):
""" the intent is to add stuff here """
pass
@@ -205,27 +181,6 @@
def render_type(self, session):
return self.type
-class CuminFormPage(HtmlPage):
- def __init__(self, app, name):
- super(CuminFormPage, self).__init__(app, name)
-
- background = self.Background(app, "background")
- background.type = "text/html"
- self.add_child(background)
-
- self.modes = ModeSet(app, "modes")
- self.add_child(self.modes)
-
- # XXX look into this
- # for form in model tasks:
- # self.add_mode(form)
-
- class Background(BackgroundInclude):
- def render_data(self, session):
- form = self.parent.modes.mode.get(session)
- url = form.return_url.get(session)
- return url
-
class CuminTaskForm(SubmitForm, Frame):
def __init__(self, app, name, task):
super(CuminTaskForm, self).__init__(app, name)
@@ -280,98 +235,6 @@
self.check(session)
return self.errors.get(session)
-class CuminConfirmForm(CuminForm):
- def __init__(self, app, name):
- super(CuminConfirmForm, self).__init__(app, name)
-
-class CuminActionSetForm(ItemSet, CuminForm, Frame):
- def __init__(self, app, name):
- super(CuminActionSetForm, self).__init__(app, name)
-
-class CuminIntIdList(Widget):
- def __init__(self, app, name):
- super(CuminIntIdList, self).__init__(app, name)
-
- param = IntegerParameter(app, "param")
- self.add_parameter(param)
-
- self.ids = ListParameter(app, "id", param)
- self.add_parameter(self.ids)
-
- def render_item_content(self, session, id):
- return "Act on object %i" % id
-
-class CuminStringIdList(Widget):
- def __init__(self, app, name):
- super(CuminStringIdList, self).__init__(app, name)
-
- param = Parameter(app, "param")
- self.add_parameter(param)
-
- self.ids = ListParameter(app, "id", param)
- self.add_parameter(self.ids)
-
- def render_item_content(self, session, id):
- return "Act on object %s" % id
-
-class CuminBulk(ItemSet, CuminForm, Frame):
- def get_href(self, session, ids):
- branch = session.branch()
- self.ids.set(branch, ids)
- self.show(branch)
- return branch.marshal()
-
- def process_submit(self, session, *args):
- items = self.get_items(session, *args)
-
- for item in items:
- self.process_item(session, item)
-
- self.process_return(session, *args)
-
- def process_item(self, session, item):
- pass
-
- def process_return(self, session, *args):
- self.page.set_redirect_url(session, self.get_origin(session))
-
- def process_cancel(self, session, *args):
- self.process_return(session, *args)
-
- def render_form_heading(self, session, *args):
- return "Actions"
-
-class CuminBulkActionForm(CuminBulk, CuminIntIdList):
- def get_items(self, session, *args):
- return self.ids.get(session)
-
-class CuminBulkStringActionForm(CuminBulk, CuminStringIdList):
- def get_items(self, session, *args):
- return self.ids.get(session)
-
-class CuminStatus(Widget):
- def __init__(self, app, name):
- super(CuminStatus, self).__init__(app, name)
-
- self.update_enabled = True
-
- def get_args(self, session):
- return self.frame.get_args(session)
-
- def render_title(self, session, object):
- return "Status"
-
- def render_color(self, session, object):
- if hasattr(object, "errors"):
- if object.errors:
- return "red"
- elif object.warnings:
- return "yellow"
- else:
- return "green"
- else:
- return "green"
-
class CuminEditableProperties(PropertySet):
def __init__(self, app, name):
self.item_renderer=EditablePropertyRenderer(self, "property_html")
@@ -534,7 +397,7 @@
cls = self.app.model.get_class_by_object(object)
return [(x.get_href(session, object),
- x.get_title(session, object),
+ x.get_title(session),
True)
for x in cls.tasks if not x.aggregate]
@@ -1298,19 +1161,6 @@
def elem_id(self, session):
return self.name
-class StartStopStatus(CuminStatus, AjaxField):
- def render_start_stop_script(self, session, scheduler):
- return self.render_script(session)
-
- def render_color(self, session, scheduler):
- return "clear"
-
- def got_fn(self, session):
- return "startstop_status"
-
- def elem_id(self, session):
- return self.render_id(session)
-
class MoreFieldSet(FormFieldSet, FormField):
""" Displays a button that opens and closes a set of fields
@@ -1358,6 +1208,149 @@
class Wait(Widget):
pass
+class CuminPage(HtmlPage):
+ def __init__(self, app, name):
+ super(CuminPage, self).__init__(app, name)
+
+ self.__frames = self.FramesAttribute(app, "frames")
+ self.add_attribute(self.__frames)
+
+ self.__modal = Attribute(app, "modal")
+ self.add_attribute(self.__modal)
+
+ def save_session(self, session):
+ if self.app.debug:
+ self.app.debug.sessions.append(session)
+
+ def set_modal(self, session, modal):
+ self.__modal.set(session, modal)
+
+ def get_frames(self, session):
+ return self.__frames.get(session)
+
+ def render_class(self, session):
+ return self.__modal.get(session) and "modal" or "_"
+
+ class FramesAttribute(Attribute):
+ def get_default(self, session):
+ return list()
+
+class CuminFormPage(HtmlPage):
+ def __init__(self, app, name):
+ super(CuminFormPage, self).__init__(app, name)
+
+ background = self.Background(app, "background")
+ background.type = "text/html"
+ self.add_child(background)
+
+ self.modes = ModeSet(app, "modes")
+ self.add_child(self.modes)
+
+ # XXX look into this
+ # for form in model tasks:
+ # self.add_mode(form)
+
+ class Background(BackgroundInclude):
+ def render_data(self, session):
+ form = self.parent.modes.mode.get(session)
+ url = form.return_url.get(session)
+ return url
+
+class CallPage(Page):
+ def __init__(self, app, name):
+ super(CallPage, self).__init__(app, name)
+
+ self.__class = CuminClassParameter(app, "class")
+ self.add_parameter(self.__class)
+
+ self.__id = IntegerParameter(app, "id")
+ self.add_parameter(self.__id)
+
+ self.__method = Parameter(app, "method")
+ self.add_parameter(self.__method)
+
+ self.__args = Parameter(app, "xargs")
+ self.add_parameter(self.__args)
+
+ def get_content_type(self, session):
+ return Page.xml_content_type
+
+ def do_render(self, session):
+ writer = Writer()
+ writer.write(Page.xml_1_0_declaration)
+
+ cls = self.__class.get(session)
+ id = self.__id.get(session)
+ xargs = self.__args.get(session)
+
+ if cls:
+ object = cls.mint_class.get(id)
+ method = self.__method.get(session)
+ for action in cls.actions:
+ if action.name == method:
+ args = xargs and xargs.split("&") or list()
+ data = action.get_xml_response(session, object, *args)
+ self.write_xml(writer, data)
+
+ return writer.to_string()
+
+ def write_xml(self, writer, data):
+ writer.write("<data>")
+ writer.write(data)
+ writer.write("</data>")
+
+# XXX for later consideration
+class CuminClassTable(CuminSelectionTable):
+ def __init__(self, app, name, cumin_class):
+ super(CuminClassTable, self).__init__(app, name)
+
+ self.cumin_class = cumin_class
+
+ tasks = [x for x in self.cumin_class.tasks if x.aggregate]
+
+ for task in tasks:
+ button = TaskButton(app, action.name, task, self.selection)
+ self.buttons.add_child(button)
+
+ def render_title(self, session, *args):
+ title = self.cumin_class.get_plural_title(session)
+ count = fmt_count(self.cumin_class.mint_class.select().count())
+
+ return "%s %s" % (title, count)
+
+class TaskLink(Link):
+ def __init__(self, app, name, task, param):
+ super(TaskLink, self).__init__(app, name)
+
+ self.task = task
+ self.param = param
+
+ def get(self, session):
+ if self.param:
+ return self.param.get(session)
+
+ def render_href(self, session):
+ return self.task.get_href(session, self.get(session))
+
+ def render_content(self, session):
+ return self.task.get_title(session)
+
+class TaskButton(FormButton):
+ def __init__(self, app, name, task, set_param):
+ super(TaskButton, self).__init__(app, name)
+
+ self.task = task
+ self.set_param = set_param
+
+ def process_submit(self, session):
+ items = self.set_param.get(session)
+
+ href = self.task.get_href(session, items)
+ self.page.set_redirect_url(session, href)
+
+ def render_content(self, session):
+ return self.task.get_title(session)
+
class TaskInvocationSet(ItemSet):
def __init__(self, app, name):
super(TaskInvocationSet, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings 2009-07-02 15:40:22 UTC (rev 3473)
@@ -158,7 +158,6 @@
<ul id="tabs">{tabs}</ul>
</div>
<div id="body">
-
{tasks}
<div id="messages" style="display: {action_display};"><p
title="close"
onclick="cumin.hideActions()">x</p>{actions}</div>
@@ -223,131 +222,6 @@
//]]>
</script>
-[CuminConfirmForm.html]
-<form id="{id}" method="post" action="?">
- <div class="head">
- <h1>{title}</h1>
- </div>
- <div class="body">
- <div>{submit}</div>
- <div>{cancel}</div>
- {hidden_inputs}
- </div>
-</form>
-<script type="text/javascript">
-//<![CDATA[
- $("{id}").elements[1].focus();
-//]]>
-</script>
-
-[CuminActionSetForm.html]
-<form id="{id}" class="mform" method="post"
action="?">
- <div class="head">
- <h1>{title}</h1>
- </div>
- <div class="body">
- <span class="legend">Actions</span>
- <fieldset>
- <ul>{items}</ul>
- </fieldset>
-
- {hidden_inputs}
- </div>
- <div class="foot">
- {help}
- {submit}
- {cancel}
- </div>
-</form>
-<script type="text/javascript">
-//<![CDATA[
- $("{id}").elements[0].focus();
-//]]>
-</script>
-
-[CuminActionSetForm.item_html]
-<li>{item_content}</li>
-
-[CuminBulkActionForm.html]
-<form id="{id}" class="mform" method="post"
action="?">
- <div class="head">
- <h1>{title}</h1>
- </div>
- <div class="body">
- <span class="legend">{form_heading}</span>
- <fieldset>
- <ul>{items}</ul>
- </fieldset>
-
- {hidden_inputs}
- </div>
- <div class="foot">
- {help}
- {submit}
- {cancel}
- </div>
-</form>
-<script type="text/javascript">
-//<![CDATA[
- $("{id}").elements[0].focus();
-//]]>
-</script>
-
-[CuminBulkActionForm.item_html]
-<li>{item_content}</li>
-
-[CuminStatus.css]
-div.CuminStatus {
- float: right;
- margin: 0.5em 0;
- padding: 0.5em 0.75em;
- width: 15em;
- display: none;
-}
-
-div.CuminStatus h2 {
- font-weight: bold;
-}
-
-div.CuminStatus div, div.CuminStatus h2 {
- margin: 0 0 0.5em 0;
-}
-
-div.CuminStatus.red {
- border: 1px dotted #c99;
- background-color: #fcc;
-}
-
-div.CuminStatus.yellow {
- border: 1px dotted #cc9;
- background-color: #ffc;
-}
-
-div.CuminStatus.green {
- border: 1px dotted #9c9;
- background-color: #cfc;
-}
-
-div.CuminStatus.clear {
- border: 1px dotted #9c9;
- background-color: transparent;
-}
-
-div.CuminStatus table {
- width: 100%;
- font-size: 0.9em;
-}
-
-div.CuminStatus table th, div.CuminStatus table td {
- font-weight: normal;
- text-align: left;
-}
-
-[CuminStatus.html]
-<div id="{id}" class="CuminStatus {color}">
- <h2>{title}</h2>
-</div>
-
[CuminDetails.css]
table.CuminDetails {
width: 100%;
@@ -758,23 +632,6 @@
[BackgroundInclude.html]
<object class="BackgroundInclude" data="{data}"
type="{type}"/>
-[CuminFormPage.css]
-body {
- background-color: #000;
- z-index: 0;
-}
-
-body > object.BackgroundInclude {
- opacity: 0.2;
-}
-
-body > form {
- z-index: 1;
- width: 48em;
- margin: 6em auto;
- background-color: #fff;
-}
-
[FormHelp.javascript]
function help_window(href) {
var left = screen.availWidth / 2;
@@ -872,50 +729,66 @@
</td>
</tr>
-[StartStopStatus.css]
-div.status_time {
- font-size: 0.80em;
- color: #444444;
+[Wait.html]
+ <div class="loading"
style="visibility:visible;"><span>Loading...</span></div>
+
+[CuminFormPage.css]
+body {
+ background-color: #000;
+ z-index: 0;
}
-[StartStopStatus.javascript]
-function got_startstop_status(obj, id) {
- var elem = document.getElementById(id);
+body > object.BackgroundInclude {
+ opacity: 0.2;
+}
- if (elem) {
- var updateTime = obj.updatetime;
- var age = obj.age;
- var color = "clear";
+body > form {
+ z-index: 1;
+ width: 48em;
+ margin: 6em auto;
+ background-color: #fff;
+}
- var oUpdateTime = document.getElementById("updateTime");
+[CuminClassTable.css]
+.CuminClassTable div.addlink {
+ margin: 0 0 1em 0;
+}
- if (oUpdateTime) {
- oUpdateTime.innerHTML = updateTime;
+.CuminClassTable ul.actions {
+ margin: 0;
+ display: inline;
+}
- if (age > 150) { /* hasn't changed in 2.5 minutes */
- color = "yellow";
- } else {
- color = "green";
- }
+.CuminClassTable ul.actions li {
+ display: inline;
+}
- elem.className = "CuminStatus " + color;
- }
+[CuminClassTable.html]
+<form class="CuminClassTable" id="{id}" method="post"
action="?">
+ <div class="addlink">{add_link}</div>
- setTimeout("get_status()", 5000);
- }
-}
+ {switches}
-[StartStopStatus.html]
-<div id="{id}" class="CuminStatus {color}">
- <h2>{title}</h2>
- <div class="status_time">
- Last update was <span id="updateTime"></span>
- </div>
-</div>{start_stop_script}
+ {filters}
-[Wait.html]
- <div class="loading"
style="visibility:visible;"><span>Loading...</span></div>
+ <div class="sactions">Act on Selected {plural_title}:
{actions}</div>
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+ </table>
+
+ <div>{hidden_inputs}</div>
+</form>
+
[TaskInvocationSet.css]
ul.TaskInvocationSet {
background-color: #fe0;
Modified: mgmt/trunk/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/model.py 2009-07-01 17:30:11 UTC (rev 3472)
+++ mgmt/trunk/rosemary/python/rosemary/model.py 2009-07-02 15:40:22 UTC (rev 3473)
@@ -38,6 +38,11 @@
pkg = RosemaryPackage(self, elem.get("package"))
pkg.load(elem)
+ def extend(self, elem):
+ for child in elem.findall("package"):
+ pkg = self.packages_by_name[child.get("name")]
+ pkg.extend(child)
+
class RosemaryPackage(object):
def __init__(self, model, name):
self.model = model
@@ -55,6 +60,11 @@
cls = RosemaryClass(self, child.get("name"))
cls.load(child)
+ def extend(self, elem):
+ for child in elem.findall("class"):
+ cls = self.classes_by_name[child.get("name")]
+ cls.extend(child)
+
class RosemaryClass(object):
def __init__(self, package, name):
self.package = package
@@ -86,6 +96,19 @@
meth = RosemaryMethod(self, child.get("name"))
meth.load(child)
+ def extend(self, elem):
+ for child in elem.findall("property"):
+ prop = self.properties_by_name[child.get("name")]
+ prop.extend(child)
+
+ for child in elem.findall("statistic"):
+ stat = self.statistics_by_name[child.get("name")]
+ stat.extend(child)
+
+ for child in elem.findall("method"):
+ meth = self.methods_by_name[child.get("name")]
+ meth.extend(child)
+
class RosemaryProperty(object):
def __init__(self, cls, name):
self.cls = cls
@@ -112,6 +135,9 @@
self.is_optional = elem.get("optional", "n") == "y"
and True
self.description = elem.get("desc")
+ def extend(self, elem):
+ self.title = elem.findtext("title")
+
class RosemaryStatistic(object):
def __init__(self, cls, name):
self.cls = cls
@@ -152,6 +178,9 @@
arg = RosemaryArgument(self, child.get("name"))
arg.load(child)
+ def extend(self, elem):
+ pass
+
def call(self, console, object, callback, **kwargs):
pass
@@ -172,6 +201,9 @@
self.direction = elem.get("dir")
self.description = elem.get("desc")
+ def extend(self, elem):
+ pass
+
class RosemaryObject(object):
def __init__(self, cls):
self.cls = cls