Author: eallen
Date: 2008-07-25 15:33:12 -0400 (Fri, 25 Jul 2008)
New Revision: 2222
Modified:
mgmt/trunk/cumin/python/cumin/model.py
Log:
Added Route(bridge) to model
Added durable/autoDel/exclusivity to Queue summary properties
Added Add + Remove queue actions to summary actions
Added useSsl + durable to Link properties
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-07-25 19:26:39 UTC (rev 2221)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-07-25 19:33:12 UTC (rev 2222)
@@ -29,6 +29,7 @@
CuminConnection(self)
CuminSession(self)
CuminLink(self)
+ CuminRoute(self)
CuminStore(self)
CuminJournal(self)
@@ -140,6 +141,9 @@
return self.title
else:
return self.name
+
+ def get_modifier(self, session):
+ pass
def invoke(self, object, args={}):
invoc = CuminActionInvocation(self, object)
@@ -178,6 +182,9 @@
def get_description(self, session):
verb = self.action.get_title(session)
+ modifier = self.action.get_modifier(session)
+ if modifier:
+ verb = verb + modifier
if self.object:
cls = self.action.cumin_model.get_class_by_object(self.object)
@@ -557,12 +564,15 @@
prop = CuminProperty(self, "durable")
prop.title = "Durable?"
+ prop.summary = True
prop = CuminProperty(self, "autoDelete")
prop.title = "Auto Delete?"
+ prop.summary = True
prop = CuminProperty(self, "exclusive")
prop.title = "Exclusive?"
+ prop.summary = True
stat = CuminStat(self, "consumerCount")
stat.title = "Consumers"
@@ -712,6 +722,12 @@
action = self.Purge(self, "purge")
action.summary = True
+
+ action = self.Remove(self, "remove")
+ action.summary = True
+
+ action = self.Add(self, "add")
+ action.summary = True
def get_title(self, session):
return "Queue"
@@ -721,12 +737,12 @@
def show_object(self, session, queue):
frame = self.cumin_model.show_main(session)
- frame = frame.show_broker(session, queue.vhost.broker.registration)
- return frame.show_queue(session, queue)
+ return frame.show_broker(session, queue.vhost.broker.registration)
class Purge(CuminAction):
def show(self, session, queue):
frame = self.cumin_class.show_object(session, queue)
+ frame = frame.show_queue(session, queue)
return frame.show_purge(session)
def get_title(self, session):
@@ -735,6 +751,67 @@
def do_invoke(self, queue, args, completion):
queue.purge(self.cumin_model.data, completion)
+ class Remove(CuminAction):
+ def show(self, session, queue):
+ frame = self.cumin_class.show_object(session, queue)
+ frame = frame.show_queue(session, queue)
+ return frame.show_remove(session)
+
+ def get_title(self, session):
+ return "Remove"
+
+ def do_invoke(self, queue, args, completion):
+ # once qpid management supports queue_delete
+ # replace the rest of this method with
+ #queue.delete(self.cumin_model.data, completion)
+
+ reg = queue.vhost.broker.registration
+ conn = self.cumin_model.data.getConnectionByRegistration(reg)
+ for sess in conn.mconn.sessions:
+ if conn.mconn.sessions[sess].name == conn.getSessionId():
+ #this is management session
+ msess = conn.mconn.sessions[sess]
+ msess.queue_delete(queue=queue.name)
+ break
+
+ #sess = conn.mconn.session(str(uuid4()))
+ #sess.queue_delete(queue=queue.name)
+ completion("OK")
+
+ class Add(CuminAction):
+ def get_title(self, session):
+ return "Add New Queue"
+
+ def get_modifier(self, session):
+ return " to "
+
+ def show(self, session, queue):
+ frame = self.cumin_class.show_object(session, queue)
+ return frame.show_queue_add(session)
+
+ def do_invoke(self, reg, args, completion):
+ conn = self.cumin_model.data.getConnectionByRegistration(reg)
+ for sess in conn.mconn.sessions:
+ if conn.mconn.sessions[sess].name == conn.getSessionId():
+ #this is management session
+ msess = conn.mconn.sessions[sess]
+ msess.queue_declare(queue=args['queue'],
+ exclusive=(args['exclusive'] == "exclusive"),
+ durable=(args['durable'] == "durable"),
+ auto_delete=(args['auto_delete'] ==
"autodel"))
+
+ # optionally bind to exchanges
+ exchange_keys = args['exchange_keys']
+ for exchange_name in exchange_keys:
+ msess.exchange_bind(queue=args['queue'],
+ exchange=exchange_name,
+ binding_key=exchange_keys[exchange_name])
+
+ break
+
+
+ completion("OK")
+
class CuminExchange(RemoteClass):
def __init__(self, model):
super(CuminExchange, self).__init__(model, "exchange",
@@ -787,10 +864,12 @@
stat.unit = "message"
stat.category = "io"
+ action = self.Add(self, "add")
+ action.summary = True
+
def show_object(self, session, exchange):
frame = self.cumin_model.show_main(session)
- frame = frame.show_broker(exchange.vhost.broker.registration)
- return frame.show_queue(session, exchange)
+ return frame.show_broker(session, exchange.vhost.broker.registration)
def get_title(self, session):
return "Exchange"
@@ -806,6 +885,25 @@
else:
return "Default Exchange"
+ class Add(CuminAction):
+ def get_title(self, session):
+ return "Add New Exchange"
+
+ def show(self, session, exchange):
+ frame = self.cumin_class.show_object(session, exchange)
+ return frame.show_exchange_add(session)
+
+ def do_invoke(self, reg, exchange, completion):
+ conn = self.cumin_model.data.getConnectionByRegistration(reg)
+ for sess in conn.mconn.sessions:
+ if conn.mconn.sessions[sess].name == conn.getSessionId():
+ #this is management session
+ msess = conn.mconn.sessions[sess]
+ msess.exchange_declare(exchange=exchange.name,
+ type=exchange.type)
+
+ completion("OK")
+
class CuminBinding(RemoteClass):
def __init__(self, model):
super(CuminBinding, self).__init__(model, "binding",
@@ -824,6 +922,20 @@
def get_object_name(self, binding):
return ""
+class CuminRoute(RemoteClass):
+ def __init__(self, model):
+ super(CuminRoute, self).__init__(model, "route",
+ Bridge, BridgeStats)
+
+ prop = CuminProperty(self, "routeKey")
+ prop.title = "Route Key"
+
+ def get_title(self, session):
+ return "Route"
+
+ def get_object_name(self, route):
+ return route.src
+
class CuminConnection(RemoteClass):
def __init__(self, model):
super(CuminConnection, self).__init__(model, "connection",
@@ -976,11 +1088,11 @@
def __init__(self, model):
super(CuminLink, self).__init__(model, "link", Link, LinkStats)
- prop = CuminProperty(self, "address")
- prop.title = "Peer Address"
+ prop = CuminProperty(self, "useSsl")
+ prop.title = "Use SSL"
- prop = CuminProperty(self, "authIdentity")
- prop.title = "Auth. Identity"
+ prop = CuminProperty(self, "durable")
+ prop.title = "Durable"
stat = CuminStat(self, "closing")
stat.title = "Closing Down"
@@ -1008,6 +1120,9 @@
def get_title(self, session):
return "Broker Link"
+ def get_object_name(self, link):
+ return "%s:%d" % (link.host, link.port)
+
class CuminStore(RemoteClass):
def __init__(self, model):
super(CuminStore, self).__init__(model, "store", Store, StoreStats)