Author: eallen
Date: 2008-08-13 18:23:34 -0400 (Wed, 13 Aug 2008)
New Revision: 2301
Modified:
mgmt/trunk/cumin/python/cumin/brokerlink.py
mgmt/trunk/cumin/python/cumin/brokerlink.strings
mgmt/trunk/cumin/python/cumin/model.py
Log:
Added "Add Route" to Route List
Modified: mgmt/trunk/cumin/python/cumin/brokerlink.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-08-13 22:20:39 UTC (rev 2300)
+++ mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-08-13 22:23:34 UTC (rev 2301)
@@ -1,14 +1,16 @@
+from cumin.binding import ExchangeKeysField
+from cumin.exchange import ExchangeInfo
+from formats import *
+from model import *
+from parameters import *
+from stat import *
+from util import *
+from widgets import *
from wooly import *
-from wooly.widgets import *
from wooly.forms import *
from wooly.resources import *
+from wooly.widgets import *
-from stat import *
-from model import *
-from widgets import *
-from parameters import *
-from formats import *
-from util import *
strings = StringCatalog(__file__)
@@ -127,10 +129,17 @@
remove = LinkRemove(app, "remove")
self.add_mode(remove)
self.set_remove_mode(remove)
+
+ self.__bridge_add = BridgeAdd(app, "bridgeadd")
+ self.add_mode(self.__bridge_add)
def render_title(self, session, peer):
return super(PeerFrame, self).render_title(session, peer)
+ def show_bridge_add(self, session):
+ self.page.set_current_frame(session, self.__bridge_add)
+ return self.show_mode(session, self.__bridge_add)
+
class LinkRemove(CuminConfirmForm):
def get_args(self, session):
return self.frame.get_args(session)
@@ -215,6 +224,11 @@
start, end = self.get_bounds(session)
return peer.bridges[start:end]
+ def render_add_bridge_url(self, session, route):
+ branch = session.branch()
+ self.frame.show_bridge_add(branch)
+ return branch.marshal()
+
def render_item_destination(self, session, route):
return route.link.managedBroker
@@ -255,6 +269,122 @@
def render_title(self, session, exchange):
return "Messages Received, Routed, and Dropped"
+class ExchangeRadioField(RadioField):
+ def __init__(self, app, name, form):
+ super(ExchangeRadioField, self).__init__(app, name, form)
+
+ self.exchange_param = Parameter(app, "exchange_param")
+ self.exchange_param.default = ""
+ self.add_parameter(self.exchange_param)
+ form.add_form_parameter(self.exchange_param)
+
+ self.exchange_tmpl = Template(self, "exchange_html")
+
+ def get(self, session):
+ return self.exchange_param.get(session)
+
+ def set(self, session, value):
+ self.exchange_param.set(session, value)
+
+ def render_title(self, session):
+ return "Choose an Exchange"
+
+ def render_exchange_name_path(self, session, exchange):
+ return self.exchange_param.path
+
+ def render_exchange_name(self, session, exchange):
+ return exchange.name or "Default"
+
+ def render_exchange_value(self, session, exchange):
+ return str(exchange.id)
+
+ def render_exchange_id(self, session, exchange):
+ return ".".join((self.path, str(exchange.id)))
+
+ def render_checked(self, session, exchange):
+ return self.exchange_param.get(session) == str(exchange.id) and
"checked=\"checked\"" or ""
+
+ def render_exchanges(self, session, *args):
+
+ #reg = self.frame.frame.frame.get_object(session)
+ broker = self.get_parent_named("broker")
+ reg = broker.get_object(session)
+ vhost = reg.getDefaultVhost()
+ sortedExchanges = sorted_by(vhost.exchanges)
+
+ writer = Writer()
+ for exchange in sortedExchanges:
+ if ExchangeInfo.is_builtin(exchange) or is_active(exchange):
+ if not exchange.name in ["qpid.management", ""]:
+ if not self.get(session):
+ self.exchange_param.set(session, str(exchange.id))
+ self.exchange_tmpl.render(writer, session, exchange)
+
+ return writer.to_string()
+
+class BridgeAdd(CuminFieldForm):
+ def __init__(self, app, name):
+ super(BridgeAdd, self).__init__(app, name)
+
+ self.__exchange = ExchangeRadioField(app, "exchange", self)
+ self.add_field(self.__exchange)
+
+ self.__key = TextField(app, "key", self)
+ self.__key.set_title("Routing Key")
+ self.add_field(self.__key)
+
+ self.__tag = TextField(app, "tag", self)
+ self.__tag.set_required(False)
+ self.__tag.set_title("Tag")
+ self.add_field(self.__tag)
+
+ self.__excludes = TextField(app, "excludes", self)
+ self.__excludes.set_required(False)
+ self.__excludes.set_title("Excludes")
+ self.add_field(self.__excludes)
+
+
+ def get_args(self, session):
+ return self.frame.get_args(session)
+
+ def render_title(self, session, link):
+ return "Add Route to '%s:%d'" % (link.host, link.port)
+
+ def process_cancel(self, session, *args):
+ self.__key.set(session, "")
+ self.__tag.set(session, "")
+ self.__excludes.set(session, "")
+ self.__exchange.set(session, "")
+
+ branch = session.branch()
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, link):
+ errors = self.validate(session)
+ if errors:
+ pass
+ else:
+ key = self.__key.get(session)
+ tag = self.__tag.get(session)
+ excludes = self.__excludes.get(session)
+ exchange_id = self.__exchange.get(session)
+ exchange = Exchange.get(int(exchange_id))
+ durable = exchange.durable
+
+ args = {"durable": durable,
+ "exchange": exchange.name,
+ "key": key,
+ "tag": tag,
+ "excludes": excludes
+ }
+
+ action = self.app.model.link.bridge
+ action.invoke(link, args)
+
+ self.process_cancel(session, link)
+
+
class BrokerLinkAdd(CuminFieldForm):
def __init__(self, app, name):
super(BrokerLinkAdd, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/brokerlink.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokerlink.strings 2008-08-13 22:20:39 UTC (rev 2300)
+++ mgmt/trunk/cumin/python/cumin/brokerlink.strings 2008-08-13 22:23:34 UTC (rev 2301)
@@ -48,6 +48,10 @@
</form>
[PeerRouteSet.html]
+ <ul class="actions">
+ <li><a class="nav" href="{add_bridge_url}">Add
Route</a></li>
+ </ul>
+
<div class="rfloat">{page}</div>
<ul class="radiotabs"> </ul>
@@ -152,3 +156,15 @@
wooly.doc().elembyid("{id}").node.elements[0].focus();
</script>
+[ExchangeRadioField.exchange_html]
+ <div class="field">
+ <input id="{exchange_id}" type="radio"
name="{exchange_name_path}" {checked} value="{exchange_value}"/>
+ <label for="{exchange_id}">{exchange_name}</label>
+ </div>
+
+[ExchangeRadioField.html]
+ <span class="legend">Choose an Exchange</span>
+ <fieldset>
+ {exchanges}
+ </fieldset>
+
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-08-13 22:20:39 UTC (rev 2300)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-08-13 22:23:34 UTC (rev 2301)
@@ -1209,6 +1209,9 @@
action = self.Close(self, "close")
action.summary = True
+ action = self.Bridge(self, "bridge")
+ action.summary = True
+
def get_title(self, session):
return "Broker Link"
@@ -1219,6 +1222,32 @@
frame = self.cumin_model.show_main(session)
return frame.show_broker(session, link.vhost.broker.registration)
+ class Bridge(CuminAction):
+ def show(self, session, link):
+ frame = self.cumin_class.show_object(session, link)
+ frame = frame.show_peer(session, link)
+ return frame.show_bridge_add(session)
+
+ def get_title(self, session):
+ return "Add Route"
+
+ def get_verb(self, session):
+ return "Add Route"
+
+ def do_invoke(self, link, args, completion):
+ durable = args["durable"]
+ src = args["exchange"]
+ dest = args["exchange"] # see qpid-route
+ key = args["key"]
+ tag = args["tag"]
+ excludes = args["excludes"]
+ srcIsQueue = 0
+ srcIsLocal = 0
+
+ link.bridge(self.cumin_model.data, completion,
+ durable, src, dest, key,
+ tag, excludes, srcIsQueue, srcIsLocal)
+
class Close(CuminAction):
def show(self, session, link):
frame = self.cumin_class.show_object(session, link)