Author: eallen
Date: 2008-11-08 12:48:36 -0500 (Sat, 08 Nov 2008)
New Revision: 2767
Modified:
mgmt/trunk/cumin/python/cumin/brokerlink.py
mgmt/trunk/cumin/python/cumin/brokerlink.strings
Log:
Added missing bridge and route options to the respective add forms.
Modified: mgmt/trunk/cumin/python/cumin/brokerlink.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-11-08 17:46:25 UTC (rev 2766)
+++ mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-11-08 17:48:36 UTC (rev 2767)
@@ -115,7 +115,7 @@
self.parent.ids.clear(session)
href = self.frame.links_close.get_href(session, ids)
- self.page.set_redirect_url(session, branch.marshal())
+ self.page.set_redirect_url(session, href)
class PeerRouteSet(CuminTable, Form):
def __init__(self, app, name):
@@ -335,68 +335,63 @@
def render_title(self, session, exchange):
return "Messages Received, Routed, and Dropped"
-class ExchangeRadioField(RadioField):
- def __init__(self, app, name):
- super(ExchangeRadioField, self).__init__(app, name, None)
+class ExchangeInputSet(RadioInputSet):
+ def __init__(self, app, name, state):
+ super(ExchangeInputSet, self).__init__(app, name, None)
- self.param = Parameter(app, "exchange_param")
- self.param.default = ""
+ self.param = IntegerParameter(app, "param")
self.add_parameter(self.param)
- self.exchange_tmpl = Template(self, "exchange_html")
-
- self.state = ExchangeState(app, "phase")
- self.add_child(self.state)
-
- self.phase = Parameter(app, "phase")
- self.add_parameter(self.phase)
-
- def render_title(self, session):
- return "Choose an Exchange"
-
- def render_exchange_name_path(self, session, exchange):
- return self.param.path
+ self.state = state
- 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.param.get(session) == str(exchange.id) and
"checked=\"checked\"" or ""
-
- def render_phase_path(self, session, *args):
- return self.phase.path
-
- def render_exchanges(self, session, *args):
+ def do_get_items(self, session, *args):
+ exchanges = list()
+
reg = self.frame.get_ancestor("broker").get_object(session)
vhost = reg.getDefaultVhost()
sortedExchanges = sorted_by(vhost.exchanges)
- writer = Writer()
for exchange in sortedExchanges:
if ExchangeInfo.is_builtin(exchange) or \
- not (self.state.is_active(session) and not is_active(exchange)):
+ (not exchange._get_deletionTime() and \
+ not (self.state.is_active(session) and not is_active(exchange))):
if not exchange.name in ["qpid.management", ""]:
- if not self.get(session):
- self.set(session, str(exchange.id))
- self.exchange_tmpl.render(writer, session, exchange)
+ if not self.param.get(session):
+ self.param.set(session, exchange.id)
+ exchanges.append(exchange)
- return writer.to_string()
+ return exchanges
- def render(self, session, *args):
- phase = self.phase.get(session)
- if phase:
- self.state.set(session, phase)
- return super(ExchangeRadioField, self).render(session, *args)
+ def render_item_value(self, session, exchange):
+ return exchange.id
+
+ def render_item_content(self, session, exchange):
+ return exchange.name
+
+ def render_item_checked_attr(self, session, exchange):
+ if self.param.get(session) == exchange.id:
+ return "checked=\"checked\""
+
+class ExchangeRadioField(FormField):
+ def __init__(self, app, name):
+ super(ExchangeRadioField, self).__init__(app, name)
+
+ self.state = ExchangeState(app, "phase")
+ self.add_child(self.state)
-class BridgeAdd(CuminFieldForm):
+ self.__exchanges = ExchangeInputSet(app, "inputs", self.state)
+ self.add_child(self.__exchanges)
+
+ def get(self, session):
+ return self.__exchanges.get(session)
+
+ def render_title(self, session):
+ return "Choose an Exchange"
+
+
+class BridgeAddForm(CuminFieldForm):
def __init__(self, app, name):
- super(BridgeAdd, self).__init__(app, name)
+ super(BridgeAddForm, self).__init__(app, name)
self.exchange = ExchangeRadioField(app, "exchange")
self.add_field(self.exchange)
@@ -421,6 +416,9 @@
self.excludes.set_title("Excludes")
self.more.add_field(self.excludes)
+ self.dynamic = self.DynamicField(app, "dynamic")
+ self.more.add_field(self.dynamic)
+
def get_args(self, session):
return self.frame.get_args(session)
@@ -434,12 +432,25 @@
if not self.excludes.get(session):
self.excludes.set(session, "%s:%s" % (args[0].host, args[0].port))
+ class DynamicField(TwoOptionRadioField):
+ def __init__(self, app, name, option1="yes", option2="no"):
+ super(BridgeAddForm.DynamicField, self).__init__(app, name, option1,
option2)
+
+ self.option1_title = "Dynamic"
+ self.option2_title = "Not dynamic"
+ self.param.default = option2
+
+ def render_title(self, session):
+ return "Dynamic Route?"
+
+ def render_field_help(self, session):
+ return "(Should the added route be dynamic)"
+
+ class BridgeAddHelpField(FormField):
+ pass
+
+class BridgeAdd(BridgeAddForm):
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())
@@ -455,12 +466,14 @@
exchange_id = self.exchange.get(session)
exchange = Exchange.get(int(exchange_id))
durable = link.durable
+ dynamic = self.dynamic.get(session) == "yes"
args = {"durable": durable,
"exchange": exchange.name,
"key": key,
"tag": tag,
- "excludes": excludes
+ "excludes": excludes,
+ "dynamic": dynamic
}
action = self.app.model.link.bridge
@@ -468,125 +481,156 @@
self.process_cancel(session, link)
- class BridgeAddHelpField(FormField):
- pass
-
-class BrokerLinkAdd(CuminFieldForm):
+class BrokerLinkAddForm(CuminFieldForm):
def __init__(self, app, name):
- super(BrokerLinkAdd, self).__init__(app, name)
+ super(BrokerLinkAddForm, self).__init__(app, name)
- self.host = DictParameter(app, "host")
- self.add_parameter(self.host)
+ self.host = self.Host(app, "host")
+ self.add_field(self.host)
- self.durable = self.SavedField(app, "saved")
- self.add_field(self.durable)
+ self.more = self.ShowButton(app, "more")
+ self.add_field(self.more)
- self.errors = self.Errors(self, "errors")
- self.add_attribute(self.errors)
+ self.port = self.PortField(app, "port")
+ self.more.add_field(self.port)
+ self.username = self.UsernameField(app, "username")
+ self.more.add_field(self.username)
+
+ self.password = self.PassField(app, "password")
+ self.more.add_field(self.password)
+
+ self.durable = self.DurableField(app, "durable")
+ self.more.add_field(self.durable)
+
+ self.transport = self.TransportField(app, "transport")
+ self.more.add_field(self.transport)
+
def render_title(self, session, *args):
reg = self.frame.get_object(session)
return "Add Broker Link to '%s'" % reg.name
- def render_broker_name_path(self, session, *args):
- return DictParameter.sep().join((self.host.path, "name"))
+ class ShowButton(MoreFieldSet):
+ def render_more_text(self, session, *args):
+ return "Show Optional Inputs..."
- def render_broker_port_path(self, session, *args):
- return DictParameter.sep().join((self.host.path, "port"))
+ def render_less_text(self, session, *args):
+ return "Hide Optional Inputs..."
+
+ class Host(NameField):
+ def render_title(self, session):
+ return "Address"
+
+ class PortField(StringField):
+ def __init__(self, app, name):
+ super(BrokerLinkAddForm.PortField, self).__init__(app, name)
+
+ self.input.size = 5
+ self.css_class = "compact first"
+
+ def render_title(self, session):
+ return "Port"
- def render_broker_name_value(self, session, *args):
- host = self.host.get(session)
- if "name" in host:
- return host["name"]
+ def do_validate(self, session, errors):
+ try:
+ port = self.get(session)
+ if port:
+ int(port)
+ except:
+ errors.append(FormError("Port must be a number"))
+
+ class UsernameField(StringField):
+ def render_title(self, session):
+ return "Username"
- def render_broker_port_value(self, session, *args):
- host = self.host.get(session)
- if "port" in host:
- return host["port"]
+ def render_form_field_class(self, session):
+ return "compact"
- def render_broker_username_path(self, session, *args):
- return DictParameter.sep().join((self.host.path, "username"))
+ class PassField(PasswordField):
+ def render_title(self, session):
+ return "Password"
- def render_broker_password_path(self, session, *args):
- return DictParameter.sep().join((self.host.path, "password"))
+ def render_form_field_class(self, session):
+ return "compact last"
- def render_broker_username_value(self, session, *args):
- host = self.host.get(session)
- if "username" in host:
- return host["username"]
+ class TransportField(RadioField):
+ def __init__(self, app, name):
+ super(BrokerLinkAddForm.TransportField, self).__init__(app, name, None)
+
+ self.param = Parameter(app, "param")
+ self.param.default = "tcp"
+ self.add_parameter(self.param)
+
+ option = self.TCP(app, "tcp", self.param)
+ self.add_option(option)
+
+ option = self.SSL(app, "ssl", self.param)
+ self.add_option(option)
+
+ option = self.RDMA(app, "rdma", self.param)
+ self.add_option(option)
+
+ def render_title(self, session):
+ return "Transport-type"
+
+ def render_field_help(self, session):
+ return "(Transport to use)"
+
+ class TCP(RadioFieldOption):
+ def render_title(self, session):
+ return "tcp"
+
+ class SSL(RadioFieldOption):
+ def render_title(self, session):
+ return "ssl"
+
+ class RDMA(RadioFieldOption):
+ def render_title(self, session):
+ return "rdma"
+
+ class DurableField(TwoOptionRadioField):
+ def __init__(self, app, name, option1="yes", option2="no"):
+ super(BrokerLinkAddForm.DurableField, self).__init__(app, name, option1,
option2)
- def render_broker_password_value(self, session, *args):
- host = self.host.get(session)
- if "password" in host:
- return host["password"]
+ self.option1_title = "Yes, restore if broker restarts"
+ self.option2_title = "No, do not restore if broker restarts"
+ self.param.default = option2
+
+ def render_title(self, session):
+ return "Restore if broker restarts?"
- def render_broker_name_error(self, session, *args):
- errors = self.errors.get(session)
- if "name" in errors:
- return "<ul class=\"errors\"
style=\"float:left;\"><li>%s</li></ul>" % \
- errors["name"]
-
- def render_broker_port_error(self, session, *args):
- errors = self.errors.get(session)
- if "port" in errors:
- return "<ul class=\"errors\"
style=\"float:left;\"><li>%s</li></ul>" % \
- errors["port"]
-
- def render_optional_prompt(self, session, *args):
- return "Optional"
-
+ def render_field_help(self, session):
+ return "(Should the added configuration be durable)"
+
+class BrokerLinkAdd(BrokerLinkAddForm):
def process_cancel(self, session):
- self.host.clear()
branch = session.branch()
self.frame.show_view(branch)
self.page.set_redirect_url(session, branch.marshal())
- def validate(self, session):
- errors = self.errors.get(session)
-
- host = self.host.get(session)
- if not "name" in host:
- errors["name"] = "Host name is required"
- if "port" in host:
- port = host["port"]
- try:
- # ensure a number and remove surrounding spaces
- port = str(int(port))
- except:
- errors["port"] = "Port must be a number"
-
- return not len(errors)
-
def process_submit(self, session):
-
- super_error = super(BrokerLinkAdd, self).validate(session)
-
- if self.validate(session) and not super_error:
+ if self.validate(session):
+ pass
+ else:
host = self.host.get(session)
- username = "anonymous"
- password = ""
- port = 5672
- addr = host["name"]
-
- if "port" in host:
- port = int(host["port"])
-
+ port = self.port.get(session) or 5672
+ if port:
+ port = int(port)
+ username = self.username.get(session) or "anonymous"
+ password = self.password.get(session)
durable = self.durable.get(session)
- if "username" in host:
- username = host["username"]
- if "password" in host:
- password = host["password"]
-
+ transport = self.transport.get(session)
+
link = Link()
- link.host = addr
+ link.host = host
link.port = port
- link.useSsl = False
- link.durable = (durable == "durable")
+ link.durable = (durable == "yes")
reg = self.frame.get_object(session)
args = {"reg": reg,
"username": username,
- "password": password}
+ "password": password,
+ "transport": transport}
action = self.app.model.broker.add_link
action.invoke(link, args)
@@ -594,23 +638,6 @@
# navigate back to main queue frame
self.process_cancel(session)
- class Errors(Attribute):
- def get_default(self, session):
- return dict()
-
- class SavedField(TwoOptionRadioField):
- def __init__(self, app, name, option1="notsaved",
option2="saved"):
- super(BrokerLinkAdd.SavedField, self).__init__(app, name, option1, option2)
-
- self.option1_title = "No, do not restore if broker restarts"
- self.option2_title = "Yes, restore if broker restarts"
-
- def render_title(self, session):
- return "Restore if broker restarts?"
-
- def render_field_help(self, session):
- return "(Should the added configuration be durable)"
-
class BrokerSetClose(CuminBulkActionForm):
def process_return(self, session):
branch = session.branch()
Modified: mgmt/trunk/cumin/python/cumin/brokerlink.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokerlink.strings 2008-11-08 17:46:25 UTC (rev 2766)
+++ mgmt/trunk/cumin/python/cumin/brokerlink.strings 2008-11-08 17:48:36 UTC (rev 2767)
@@ -99,101 +99,13 @@
<div>{hidden_inputs}</div>
</form>
-[BrokerLinkAdd.css]
-div.field div.input_prompt {
- width: 5em;
- padding-right: 1em;
- float:left;
-}
-
-div.multiple div.inputs {
- margin-bottom: 0.25em;
-}
-
-div.multiple {
- margin-bottom: 1em;
-}
-
-div.multiple div.input_prompt:after {
- content: ":";
-}
-
-div.multiple div.inputs input {
- float:left;
-}
-div.multiple div.inputs:after {
- content: ".";
- display: block;
- height: 0;
- clear: left;
- visibility: hidden;
-}
-div.multiple div.optional {
- background-color: #fcfcfc;
- border: 1px solid #999999;
- margin: 1.25em 1em 1em;
-}
-
-div.optional_prompt {
- background-color: #fcfcfc;
- border: 1px solid #cccccc;
- color: #999999;
- float:left;
- margin-left: 0.5em;
- padding: 0.25em 0.5em;
- position: relative;
- top: -1em;
-}
-
-div.optional_inputs {
- clear: left;
- position: relative;
- top: -0.5em;
-}
-
-[BrokerLinkAdd.html]
-<form id="{id}" class="mform" method="post"
action="?">
- <div class="head">{title}</div>
- <div class="body">
- <div class="field multiple">
- <div class="title">Source Broker</div>
- <div class="inputs"><div
class="input_prompt">Address</div><input type="text"
name="{broker_name_path}" value="{broker_name_value}"
tabindex="100" size="32"/>{broker_name_error}</div>
- <div class="optional">
- <div class="optional_prompt">{optional_prompt}</div>
- <div class="optional_inputs">
- <div class="inputs"><div
class="input_prompt">Port</div><input type="text"
name="{broker_port_path}" value="{broker_port_value}"
tabindex="100" size="5"/>{broker_port_error}</div>
- <div class="inputs"><div
class="input_prompt">Username</div><input type="text"
name="{broker_username_path}" value="{broker_username_value}"
tabindex="100" size="32"/></div>
- <div class="inputs"><div
class="input_prompt">Password</div><input type="text"
name="{broker_password_path}" value="{broker_password_value}"
tabindex="100" size="32"/></div>
- </div>
- </div>
- </div>
- {fields}
- </div>
- <div class="foot">
- {help}
- {submit}
- {cancel}
- </div>
- <div>{hidden_inputs}</div>
-</form>
-<script type="text/javascript">
-<![CDATA[
- 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]
- <div class="rfloat">{phase}</div> <input
id="phase_state" type="hidden" name="{phase_path}"
value="" />
- <span class="legend">Choose an Exchange</span>
- <fieldset>
- {exchanges}
- </fieldset>
+<div class="{form_field_class}">
+ <div class="rfloat">{phase}</div>
+ <div class="title">{title}</div> <div
class="field_help">{field_help}</div><div
class="clear_left"></div>
+ {errors}
+ <div class="inputs">{inputs}</div><div
style="clear:left;"><!-- --></div>
+</div>
[PeerRouteSetClose.html]
<form id="{id}" class="mform" method="post"
action="?">