[rhmessaging-commits] rhmessaging commits: r3771 - in mgmt/trunk/mint: sql and 1 other directory.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Fri Jan 8 13:48:28 EST 2010
Author: justi9
Date: 2010-01-08 13:48:28 -0500 (Fri, 08 Jan 2010)
New Revision: 3771
Modified:
mgmt/trunk/mint/python/mint/model.py
mgmt/trunk/mint/python/mint/schema.py
mgmt/trunk/mint/python/mint/schemaparser.py
mgmt/trunk/mint/sql/Makefile
mgmt/trunk/mint/sql/schema.sql
Log:
Move callMethod to MintAgent and simplify schema methods
Modified: mgmt/trunk/mint/python/mint/model.py
===================================================================
--- mgmt/trunk/mint/python/mint/model.py 2010-01-08 16:28:35 UTC (rev 3770)
+++ mgmt/trunk/mint/python/mint/model.py 2010-01-08 18:48:28 UTC (rev 3771)
@@ -1,108 +1,25 @@
from parsley.collectionsex import defaultdict
from parsley.threadingex import Lifecycle
-from qpid.datatypes import UUID
-from qpid.util import URL
from sqlobject import *
from mint import update
from mint.cache import MintCache
from mint.schema import *
+from mint.schemalocal import *
from mint.util import *
+import mint.schema
+
from qmf.console import ClassKey, Console, Session
log = logging.getLogger("mint.model")
-thisModule = __import__(__name__)
-
-for item in dir(mint.schema):
- cls = getattr(mint.schema, item)
-
- try:
- if issubclass(cls, SQLObject) and cls is not SQLObject:
- setattr(thisModule, item, cls)
- except TypeError:
- pass
-
-class Subject(SQLObject):
- class sqlmeta:
- lazyUpdate = True
-
- name = StringCol(unique=True, notNone=True)
- password = StringCol()
- lastChallenged = TimestampCol(default=None)
- lastLoggedIn = TimestampCol(default=None)
- lastLoggedOut = TimestampCol(default=None)
- roles = SQLRelatedJoin("Role", intermediateTable="subject_role_mapping",
- createRelatedTable=False)
-
- def getByName(cls, name):
- try:
- return Subject.selectBy(name=name)[0]
- except IndexError:
- pass
-
- getByName = classmethod(getByName)
-
-class Role(SQLObject):
- class sqlmeta:
- lazyUpdate = True
-
- name = StringCol(unique=True, notNone=True)
- subjects = SQLRelatedJoin("Subject",
- intermediateTable="subject_role_mapping",
- createRelatedTable=False)
-
- def getByName(cls, name):
- try:
- return Role.selectBy(name=name)[0]
- except IndexError:
- pass
-
- getByName = classmethod(getByName)
-
-class SubjectRoleMapping(SQLObject):
- class sqlmeta:
- lazyUpdate = True
-
- subject = ForeignKey("Subject", notNull=True, cascade=True)
- role = ForeignKey("Role", notNull=True, cascade=True)
- unique = DatabaseIndex(subject, role, unique=True)
-
-class ObjectNotFound(Exception):
- pass
-
-class MintInfo(SQLObject):
- class sqlmeta:
- lazyUpdate = True
-
- version = StringCol(default="0.1", notNone=True)
-
-class BrokerGroup(SQLObject):
- class sqlmeta:
- lazyUpdate = True
-
- name = StringCol(unique=True, notNone=True)
- brokers = SQLRelatedJoin("Broker",
- intermediateTable="broker_group_mapping",
- createRelatedTable=False)
-
-class BrokerGroupMapping(SQLObject):
- class sqlmeta:
- lazyUpdate = True
-
- broker = ForeignKey("Broker", notNull=True, cascade=True)
- brokerGroup = ForeignKey("BrokerGroup", notNull=True, cascade=True)
- unique = DatabaseIndex(broker, brokerGroup, unique=True)
-
class MintModel(Console, Lifecycle):
- staticInstance = None
-
def __init__(self, app):
self.log = log
- assert MintModel.staticInstance is None
- MintModel.staticInstance = self
+ assert mint.schema.model is None
+ mint.schema.model = self
self.app = app
@@ -288,25 +205,6 @@
""" Invoked when an event is raised. """
pass
- def callMethod(self, mintObject, methodName, callback, args):
- classKey = ClassKey(mintObject.qmfClassKey)
- objectId = QmfObjectId.fromString(mintObject.qmfObjectId).toObjectId()
-
- self.lock.acquire()
- try:
- agent = self.agents[mintObject.qmfAgentId]
- broker = agent.agent.getBroker()
-
- seq = self.qmfSession._sendMethodRequest \
- (broker, classKey, objectId, methodName, args)
-
- if seq is not None:
- self.outstandingMethodCalls[seq] = callback
-
- return seq
- finally:
- self.lock.release()
-
def methodResponse(self, broker, seq, response):
log.debug("Method response for request %i received from %s", seq, broker)
log.debug("Response: %s", response)
@@ -333,5 +231,23 @@
# qmfObjectId => list of ModelUpdate objects
self.deferredUpdates = defaultdict(list)
+ def callMethod(self, mintObject, methodName, callback, args):
+ classKey = ClassKey(mintObject.qmfClassKey)
+ objectId = QmfObjectId.fromString(mintObject.qmfObjectId).toObjectId()
+
+ self.model.lock.acquire()
+ try:
+ broker = self.agent.getBroker()
+
+ seq = self.model.qmfSession._sendMethodRequest \
+ (broker, classKey, objectId, methodName, args)
+
+ if seq is not None:
+ self.model.outstandingMethodCalls[seq] = callback
+
+ return seq
+ finally:
+ self.model.lock.release()
+
def __repr__(self):
return "%s(%s)" % (self.__class__.__name__, self.id)
Modified: mgmt/trunk/mint/python/mint/schema.py
===================================================================
--- mgmt/trunk/mint/python/mint/schema.py 2010-01-08 16:28:35 UTC (rev 3770)
+++ mgmt/trunk/mint/python/mint/schema.py 2010-01-08 18:48:28 UTC (rev 3771)
@@ -1,13 +1,8 @@
-import mint
from sqlobject import *
-from datetime import datetime
-from qmf.console import ObjectId
-class Pool(SQLObject):
- class sqlmeta:
- lazyUpdate = True
- sourceId = StringCol(default=None, unique=True)
+from mint.util import *
+model = None
class Slot(SQLObject):
class sqlmeta:
@@ -157,96 +152,166 @@
DaemonStartTime = TimestampCol(default=None)
- def Submit(self, model, callback, Ad, Id):
- actualArgs = list()
+ def Submit(self, callback, Ad, Id):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Ad is not None:
- actualArgs.append(Ad)
+ args.append(Ad)
if Id is not None:
- actualArgs.append(Id)
- model.callMethod(self, "Submit", callback, args=actualArgs)
+ args.append(Id)
- def GetAd(self, model, callback, Id, JobAd):
- actualArgs = list()
+ agent.callMethod(self, "Submit", callback, args)
+
+ def GetAd(self, callback, Id, JobAd):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Id is not None:
- actualArgs.append(Id)
+ args.append(Id)
if JobAd is not None:
- actualArgs.append(JobAd)
- model.callMethod(self, "GetAd", callback, args=actualArgs)
+ args.append(JobAd)
- def SetAttribute(self, model, callback, Id, Name, Value):
- actualArgs = list()
+ agent.callMethod(self, "GetAd", callback, args)
+
+ def SetAttribute(self, callback, Id, Name, Value):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Id is not None:
- actualArgs.append(Id)
+ args.append(Id)
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if Value is not None:
- actualArgs.append(Value)
- model.callMethod(self, "SetAttribute", callback, args=actualArgs)
+ args.append(Value)
- def Hold(self, model, callback, Id, Reason):
- actualArgs = list()
+ agent.callMethod(self, "SetAttribute", callback, args)
+
+ def Hold(self, callback, Id, Reason):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Id is not None:
- actualArgs.append(Id)
+ args.append(Id)
if Reason is not None:
- actualArgs.append(Reason)
- model.callMethod(self, "Hold", callback, args=actualArgs)
+ args.append(Reason)
- def Release(self, model, callback, Id, Reason):
- actualArgs = list()
+ agent.callMethod(self, "Hold", callback, args)
+
+ def Release(self, callback, Id, Reason):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Id is not None:
- actualArgs.append(Id)
+ args.append(Id)
if Reason is not None:
- actualArgs.append(Reason)
- model.callMethod(self, "Release", callback, args=actualArgs)
+ args.append(Reason)
- def Remove(self, model, callback, Id, Reason):
- actualArgs = list()
+ agent.callMethod(self, "Release", callback, args)
+
+ def Remove(self, callback, Id, Reason):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Id is not None:
- actualArgs.append(Id)
+ args.append(Id)
if Reason is not None:
- actualArgs.append(Reason)
- model.callMethod(self, "Remove", callback, args=actualArgs)
+ args.append(Reason)
- def Fetch(self, model, callback, Id, File, Start, End, Data):
- actualArgs = list()
+ agent.callMethod(self, "Remove", callback, args)
+
+ def Fetch(self, callback, Id, File, Start, End, Data):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Id is not None:
- actualArgs.append(Id)
+ args.append(Id)
if File is not None:
- actualArgs.append(File)
+ args.append(File)
if Start is not None:
- actualArgs.append(Start)
+ args.append(Start)
if End is not None:
- actualArgs.append(End)
+ args.append(End)
if Data is not None:
- actualArgs.append(Data)
- model.callMethod(self, "Fetch", callback, args=actualArgs)
+ args.append(Data)
- def GetStates(self, model, callback, Submission, State, Count):
- actualArgs = list()
+ agent.callMethod(self, "Fetch", callback, args)
+
+ def GetStates(self, callback, Submission, State, Count):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Submission is not None:
- actualArgs.append(Submission)
+ args.append(Submission)
if State is not None:
- actualArgs.append(State)
+ args.append(State)
if Count is not None:
- actualArgs.append(Count)
- model.callMethod(self, "GetStates", callback, args=actualArgs)
+ args.append(Count)
- def GetJobs(self, model, callback, Submission, Jobs):
- actualArgs = list()
+ agent.callMethod(self, "GetStates", callback, args)
+
+ def GetJobs(self, callback, Submission, Jobs):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Submission is not None:
- actualArgs.append(Submission)
+ args.append(Submission)
if Jobs is not None:
- actualArgs.append(Jobs)
- model.callMethod(self, "GetJobs", callback, args=actualArgs)
+ args.append(Jobs)
- def echo(self, model, callback, sequence, body):
- actualArgs = list()
+ agent.callMethod(self, "GetJobs", callback, args)
+
+ def echo(self, callback, sequence, body):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if sequence is not None:
- actualArgs.append(sequence)
+ args.append(sequence)
if body is not None:
- actualArgs.append(body)
- model.callMethod(self, "echo", callback, args=actualArgs)
+ args.append(body)
+ agent.callMethod(self, "echo", callback, args)
+
class SchedulerStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -329,72 +394,135 @@
DaemonStartTime = TimestampCol(default=None)
- def GetLimits(self, model, callback, Limits):
- actualArgs = list()
+ def GetLimits(self, callback, Limits):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Limits is not None:
- actualArgs.append(Limits)
- model.callMethod(self, "GetLimits", callback, args=actualArgs)
+ args.append(Limits)
- def SetLimit(self, model, callback, Name, Max):
- actualArgs = list()
+ agent.callMethod(self, "GetLimits", callback, args)
+
+ def SetLimit(self, callback, Name, Max):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if Max is not None:
- actualArgs.append(Max)
- model.callMethod(self, "SetLimit", callback, args=actualArgs)
+ args.append(Max)
- def GetStats(self, model, callback, Name, Ad):
- actualArgs = list()
+ agent.callMethod(self, "SetLimit", callback, args)
+
+ def GetStats(self, callback, Name, Ad):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if Ad is not None:
- actualArgs.append(Ad)
- model.callMethod(self, "GetStats", callback, args=actualArgs)
+ args.append(Ad)
- def SetPriority(self, model, callback, Name, Priority):
- actualArgs = list()
+ agent.callMethod(self, "GetStats", callback, args)
+
+ def SetPriority(self, callback, Name, Priority):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if Priority is not None:
- actualArgs.append(Priority)
- model.callMethod(self, "SetPriority", callback, args=actualArgs)
+ args.append(Priority)
- def SetPriorityFactor(self, model, callback, Name, PriorityFactor):
- actualArgs = list()
+ agent.callMethod(self, "SetPriority", callback, args)
+
+ def SetPriorityFactor(self, callback, Name, PriorityFactor):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if PriorityFactor is not None:
- actualArgs.append(PriorityFactor)
- model.callMethod(self, "SetPriorityFactor", callback, args=actualArgs)
+ args.append(PriorityFactor)
- def SetUsage(self, model, callback, Name, Usage):
- actualArgs = list()
+ agent.callMethod(self, "SetPriorityFactor", callback, args)
+
+ def SetUsage(self, callback, Name, Usage):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if Usage is not None:
- actualArgs.append(Usage)
- model.callMethod(self, "SetUsage", callback, args=actualArgs)
+ args.append(Usage)
- def GetRawConfig(self, model, callback, Name, Value):
- actualArgs = list()
+ agent.callMethod(self, "SetUsage", callback, args)
+
+ def GetRawConfig(self, callback, Name, Value):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if Value is not None:
- actualArgs.append(Value)
- model.callMethod(self, "GetRawConfig", callback, args=actualArgs)
+ args.append(Value)
- def SetRawConfig(self, model, callback, Name, Value):
- actualArgs = list()
+ agent.callMethod(self, "GetRawConfig", callback, args)
+
+ def SetRawConfig(self, callback, Name, Value):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Name is not None:
- actualArgs.append(Name)
+ args.append(Name)
if Value is not None:
- actualArgs.append(Value)
- model.callMethod(self, "SetRawConfig", callback, args=actualArgs)
+ args.append(Value)
- def Reconfig(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "Reconfig", callback, args=actualArgs)
+ agent.callMethod(self, "SetRawConfig", callback, args)
+ def Reconfig(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
+
+ agent.callMethod(self, "Reconfig", callback, args)
+
class NegotiatorStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -477,18 +605,32 @@
DaemonStartTime = TimestampCol(default=None)
- def Start(self, model, callback, Subsystem):
- actualArgs = list()
+ def Start(self, callback, Subsystem):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Subsystem is not None:
- actualArgs.append(Subsystem)
- model.callMethod(self, "Start", callback, args=actualArgs)
+ args.append(Subsystem)
- def Stop(self, model, callback, Subsystem):
- actualArgs = list()
+ agent.callMethod(self, "Start", callback, args)
+
+ def Stop(self, callback, Subsystem):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if Subsystem is not None:
- actualArgs.append(Subsystem)
- model.callMethod(self, "Stop", callback, args=actualArgs)
+ args.append(Subsystem)
+ agent.callMethod(self, "Stop", callback, args)
+
class MasterStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -601,11 +743,18 @@
lastAclLoad = TimestampCol(default=None)
- def reloadACLFile(self, model, callback):
+ def reloadACLFile(self, callback):
"""Reload the ACL file"""
- actualArgs = list()
- model.callMethod(self, "reloadACLFile", callback, args=actualArgs)
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+ args = list()
+
+
+ agent.callMethod(self, "reloadACLFile", callback, args)
+
class AclStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -642,16 +791,30 @@
memberIDs = StringCol(default=None)
- def stopClusterNode(self, model, callback, brokerId):
- actualArgs = list()
+ def stopClusterNode(self, callback, brokerId):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if brokerId is not None:
- actualArgs.append(brokerId)
- model.callMethod(self, "stopClusterNode", callback, args=actualArgs)
+ args.append(brokerId)
- def stopFullCluster(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "stopFullCluster", callback, args=actualArgs)
+ agent.callMethod(self, "stopClusterNode", callback, args)
+ def stopFullCluster(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
+
+ agent.callMethod(self, "stopFullCluster", callback, args)
+
class ClusterStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -737,13 +900,20 @@
dataFileSize = BigIntCol(default=None)
- def expand(self, model, callback, by):
+ def expand(self, callback, by):
"""Increase number of files allocated for this journal"""
- actualArgs = list()
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if by is not None:
- actualArgs.append(by)
- model.callMethod(self, "expand", callback, args=actualArgs)
+ args.append(by)
+ agent.callMethod(self, "expand", callback, args)
+
class JournalStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -840,45 +1010,66 @@
dataDir = StringCol(default=None)
- def echo(self, model, callback, sequence, body):
+ def echo(self, callback, sequence, body):
"""Request a response to test the path to the management broker"""
- actualArgs = list()
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if sequence is not None:
- actualArgs.append(sequence)
+ args.append(sequence)
if body is not None:
- actualArgs.append(body)
- model.callMethod(self, "echo", callback, args=actualArgs)
+ args.append(body)
- def connect(self, model, callback, host, port, durable, authMechanism, username, password, transport):
+ agent.callMethod(self, "echo", callback, args)
+
+ def connect(self, callback, host, port, durable, authMechanism, username, password, transport):
"""Establish a connection to another broker"""
- actualArgs = list()
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if host is not None:
- actualArgs.append(host)
+ args.append(host)
if port is not None:
- actualArgs.append(port)
+ args.append(port)
if durable is not None:
- actualArgs.append(durable)
+ args.append(durable)
if authMechanism is not None:
- actualArgs.append(authMechanism)
+ args.append(authMechanism)
if username is not None:
- actualArgs.append(username)
+ args.append(username)
if password is not None:
- actualArgs.append(password)
+ args.append(password)
if transport is not None:
- actualArgs.append(transport)
- model.callMethod(self, "connect", callback, args=actualArgs)
+ args.append(transport)
- def queueMoveMessages(self, model, callback, srcQueue, destQueue, qty):
+ agent.callMethod(self, "connect", callback, args)
+
+ def queueMoveMessages(self, callback, srcQueue, destQueue, qty):
"""Move messages from one queue to another"""
- actualArgs = list()
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if srcQueue is not None:
- actualArgs.append(srcQueue)
+ args.append(srcQueue)
if destQueue is not None:
- actualArgs.append(destQueue)
+ args.append(destQueue)
if qty is not None:
- actualArgs.append(qty)
- model.callMethod(self, "queueMoveMessages", callback, args=actualArgs)
+ args.append(qty)
+ agent.callMethod(self, "queueMoveMessages", callback, args)
+
class BrokerStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -974,13 +1165,20 @@
exchange = ForeignKey('Exchange', cascade='null', default=None)
- def purge(self, model, callback, request):
+ def purge(self, callback, request):
"""Discard all or some messages on a queue"""
- actualArgs = list()
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if request is not None:
- actualArgs.append(request)
- model.callMethod(self, "purge", callback, args=actualArgs)
+ args.append(request)
+ agent.callMethod(self, "purge", callback, args)
+
class QueueStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -1155,10 +1353,17 @@
remoteParentPid = BigIntCol(default=None)
- def close(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "close", callback, args=actualArgs)
+ def close(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+ args = list()
+
+
+ agent.callMethod(self, "close", callback, args)
+
class ClientConnectionStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -1195,35 +1400,49 @@
durable = BoolCol(default=None)
- def close(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "close", callback, args=actualArgs)
+ def close(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
- def bridge(self, model, callback, durable, src, dest, key, tag, excludes, srcIsQueue, srcIsLocal, dynamic, sync):
+ args = list()
+
+
+ agent.callMethod(self, "close", callback, args)
+
+ def bridge(self, callback, durable, src, dest, key, tag, excludes, srcIsQueue, srcIsLocal, dynamic, sync):
"""Bridge messages over the link"""
- actualArgs = list()
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
if durable is not None:
- actualArgs.append(durable)
+ args.append(durable)
if src is not None:
- actualArgs.append(src)
+ args.append(src)
if dest is not None:
- actualArgs.append(dest)
+ args.append(dest)
if key is not None:
- actualArgs.append(key)
+ args.append(key)
if tag is not None:
- actualArgs.append(tag)
+ args.append(tag)
if excludes is not None:
- actualArgs.append(excludes)
+ args.append(excludes)
if srcIsQueue is not None:
- actualArgs.append(srcIsQueue)
+ args.append(srcIsQueue)
if srcIsLocal is not None:
- actualArgs.append(srcIsLocal)
+ args.append(srcIsLocal)
if dynamic is not None:
- actualArgs.append(dynamic)
+ args.append(dynamic)
if sync is not None:
- actualArgs.append(sync)
- model.callMethod(self, "bridge", callback, args=actualArgs)
+ args.append(sync)
+ agent.callMethod(self, "bridge", callback, args)
+
class LinkStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -1264,10 +1483,17 @@
syncRsv = IntCol(default=None)
- def close(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "close", callback, args=actualArgs)
+ def close(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+ args = list()
+
+
+ agent.callMethod(self, "close", callback, args)
+
class BridgeStats(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -1302,22 +1528,50 @@
maxClientRate = BigIntCol(default=None)
- def solicitAck(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "solicitAck", callback, args=actualArgs)
+ def solicitAck(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
- def detach(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "detach", callback, args=actualArgs)
+ args = list()
- def resetLifespan(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "resetLifespan", callback, args=actualArgs)
- def close(self, model, callback):
- actualArgs = list()
- model.callMethod(self, "close", callback, args=actualArgs)
+ agent.callMethod(self, "solicitAck", callback, args)
+ def detach(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
+
+ agent.callMethod(self, "detach", callback, args)
+
+ def resetLifespan(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
+
+ agent.callMethod(self, "resetLifespan", callback, args)
+
+ def close(self, callback):
+ try:
+ agent = model.agents[self.qmfAgentId]
+ except KeyError:
+ raise Exception("Agent not found")
+
+ args = list()
+
+
+ agent.callMethod(self, "close", callback, args)
+
class SessionStats(SQLObject):
class sqlmeta:
lazyUpdate = True
Modified: mgmt/trunk/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/trunk/mint/python/mint/schemaparser.py 2010-01-08 16:28:35 UTC (rev 3770)
+++ mgmt/trunk/mint/python/mint/schemaparser.py 2010-01-08 18:48:28 UTC (rev 3771)
@@ -177,21 +177,25 @@
else:
comment = ""
formalArgs = ", "
- actualArgs = " actualArgs = list()\n"
+ actualArgs = " args = list()\n\n"
for arg in elem.query["arg"]:
formalArgs += "%s, " % (arg["@name"])
actualArgs += " if %s is not None:\n" % (arg["@name"])
- actualArgs += " actualArgs.append(%s)\n" % (arg["@name"])
+ actualArgs += " args.append(%s)\n" % (arg["@name"])
if (formalArgs != ", "):
formalArgs = formalArgs[:-2]
else:
formalArgs = ""
- self.pythonOutput += "\n def %s(self, model, callback%s):\n" % (elem["@name"], formalArgs)
+ self.pythonOutput += "\n def %s(self, callback%s):\n" % (elem["@name"], formalArgs)
self.pythonOutput += comment
- self.pythonOutput += actualArgs
- self.pythonOutput += " model.callMethod(self, \"%s\", " % elem["@name"]
- self.pythonOutput += "callback, args=actualArgs)\n"
+ self.pythonOutput += " try:\n"
+ self.pythonOutput += " agent = model.agents[self.qmfAgentId]\n"
+ self.pythonOutput += " except KeyError:\n"
+ self.pythonOutput += " raise Exception(\"Agent not found\")\n\n"
+ self.pythonOutput += actualArgs + "\n"
+ self.pythonOutput += " agent.callMethod(self, \"%s\", " % elem["@name"]
+ self.pythonOutput += "callback, args)\n"
def endClass(self):
if (self.additionalPythonOutput != ""):
@@ -202,14 +206,13 @@
self.currentClass = ""
def generateCode(self):
- self.pythonOutput += "import mint\n"
- self.pythonOutput += "from sqlobject import *\n"
- self.pythonOutput += "from datetime import datetime\n"
- self.pythonOutput += "from qmf.console import ObjectId\n\n"
- self.pythonOutput += "class Pool(SQLObject):\n"
- self.pythonOutput += " class sqlmeta:\n"
- self.pythonOutput += " lazyUpdate = True\n"
- self.pythonOutput += " sourceId = StringCol(default=None, unique=True)\n\n"
+# self.pythonOutput += "import mint\n\n"
+# self.pythonOutput += "from qmf.console import ObjectId\n\n"
+ self.pythonOutput += "from sqlobject import *\n\n"
+ self.pythonOutput += "from mint.util import *\n\n"
+
+ self.pythonOutput += "model = None\n"
+
self.finalPythonOutput += "\nclassToSchemaNameMap = dict()\n"
self.finalPythonOutput += "schemaNameToClassMap = dict()\n"
self.finalPythonOutput += 'schemaReservedWordsMap = {"in": "inRsv", "In": "InRsv", \n'
Modified: mgmt/trunk/mint/sql/Makefile
===================================================================
--- mgmt/trunk/mint/sql/Makefile 2010-01-08 16:28:35 UTC (rev 3770)
+++ mgmt/trunk/mint/sql/Makefile 2010-01-08 18:48:28 UTC (rev 3771)
@@ -5,7 +5,7 @@
schema: schema.sql
schema.sql: ../python/mint/*.py
- sqlobject-admin sql -m mint.model -m mint.schema -c ${dsn} | sed -e '1,2d' > schema.sql
+ sqlobject-admin sql -m mint.schema -m mint.schemalocal -c ${dsn} | sed -e '1,2d' > schema.sql
clean:
rm -f schema.sql
Modified: mgmt/trunk/mint/sql/schema.sql
===================================================================
--- mgmt/trunk/mint/sql/schema.sql 2010-01-08 16:28:35 UTC (rev 3770)
+++ mgmt/trunk/mint/sql/schema.sql 2010-01-08 18:48:28 UTC (rev 3771)
@@ -1,41 +1,3 @@
-CREATE TABLE broker_group (
- id SERIAL PRIMARY KEY,
- name TEXT NOT NULL UNIQUE
-);
-
-CREATE TABLE broker_group_mapping (
- id SERIAL PRIMARY KEY,
- broker_id INT NOT NULL,
- broker_group_id INT NOT NULL
-);
-CREATE UNIQUE INDEX broker_group_mapping_unique ON broker_group_mapping (broker_id, broker_group_id);
-
-CREATE TABLE mint_info (
- id SERIAL PRIMARY KEY,
- version TEXT NOT NULL
-);
-
-CREATE TABLE role (
- id SERIAL PRIMARY KEY,
- name TEXT NOT NULL UNIQUE
-);
-
-CREATE TABLE subject (
- id SERIAL PRIMARY KEY,
- name TEXT NOT NULL UNIQUE,
- password TEXT,
- last_challenged TIMESTAMP,
- last_logged_in TIMESTAMP,
- last_logged_out TIMESTAMP
-);
-
-CREATE TABLE subject_role_mapping (
- id SERIAL PRIMARY KEY,
- subject_id INT NOT NULL,
- role_id INT NOT NULL
-);
-CREATE UNIQUE INDEX subject_role_mapping_unique ON subject_role_mapping (subject_id, role_id);
-
CREATE TABLE acl (
id SERIAL PRIMARY KEY,
qmf_agent_id TEXT NOT NULL,
@@ -531,11 +493,6 @@
monitor_self_time TIMESTAMP
);
-CREATE TABLE pool (
- id SERIAL PRIMARY KEY,
- source_id TEXT UNIQUE
-);
-
CREATE TABLE queue (
id SERIAL PRIMARY KEY,
qmf_agent_id TEXT NOT NULL,
@@ -1010,14 +967,44 @@
vhost_id INT
);
-ALTER TABLE broker_group_mapping ADD CONSTRAINT broker_id_exists FOREIGN KEY (broker_id) REFERENCES broker (id) ON DELETE CASCADE;
+CREATE TABLE broker_group (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL UNIQUE
+);
-ALTER TABLE broker_group_mapping ADD CONSTRAINT broker_group_id_exists FOREIGN KEY (broker_group_id) REFERENCES broker_group (id) ON DELETE CASCADE;
+CREATE TABLE broker_group_mapping (
+ id SERIAL PRIMARY KEY,
+ broker_id INT NOT NULL,
+ broker_group_id INT NOT NULL
+);
+CREATE UNIQUE INDEX broker_group_mapping_unique ON broker_group_mapping (broker_id, broker_group_id);
-ALTER TABLE subject_role_mapping ADD CONSTRAINT subject_id_exists FOREIGN KEY (subject_id) REFERENCES subject (id) ON DELETE CASCADE;
+CREATE TABLE mint_info (
+ id SERIAL PRIMARY KEY,
+ version TEXT NOT NULL
+);
-ALTER TABLE subject_role_mapping ADD CONSTRAINT role_id_exists FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE;
+CREATE TABLE role (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL UNIQUE
+);
+CREATE TABLE subject (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL UNIQUE,
+ password TEXT,
+ last_challenged TIMESTAMP,
+ last_logged_in TIMESTAMP,
+ last_logged_out TIMESTAMP
+);
+
+CREATE TABLE subject_role_mapping (
+ id SERIAL PRIMARY KEY,
+ subject_id INT NOT NULL,
+ role_id INT NOT NULL
+);
+CREATE UNIQUE INDEX subject_role_mapping_unique ON subject_role_mapping (subject_id, role_id);
+
ALTER TABLE acl ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id) REFERENCES acl_stats (id) ON DELETE SET NULL;
ALTER TABLE acl ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES acl_stats (id) ON DELETE SET NULL;
@@ -1214,3 +1201,11 @@
ALTER TABLE vhost_stats ADD CONSTRAINT vhost_id_exists FOREIGN KEY (vhost_id) REFERENCES vhost (id) ON DELETE SET NULL;
+ALTER TABLE broker_group_mapping ADD CONSTRAINT broker_id_exists FOREIGN KEY (broker_id) REFERENCES broker (id) ON DELETE CASCADE;
+
+ALTER TABLE broker_group_mapping ADD CONSTRAINT broker_group_id_exists FOREIGN KEY (broker_group_id) REFERENCES broker_group (id) ON DELETE CASCADE;
+
+ALTER TABLE subject_role_mapping ADD CONSTRAINT subject_id_exists FOREIGN KEY (subject_id) REFERENCES subject (id) ON DELETE CASCADE;
+
+ALTER TABLE subject_role_mapping ADD CONSTRAINT role_id_exists FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE;
+
More information about the rhmessaging-commits
mailing list