[rhmessaging-commits] rhmessaging commits: r2004 - mgmt/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Thu May 8 11:40:21 EDT 2008
Author: justi9
Date: 2008-05-08 11:40:21 -0400 (Thu, 08 May 2008)
New Revision: 2004
Modified:
mgmt/cumin/python/cumin/broker.py
Log:
Prevent the user from creating duplicate registrations. Use the
parse_broker_addr utility function.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-05-07 15:41:15 UTC (rev 2003)
+++ mgmt/cumin/python/cumin/broker.py 2008-05-08 15:40:21 UTC (rev 2004)
@@ -589,21 +589,15 @@
if addr:
name = names[i]
+ host, port = parse_broker_addr(addr)
- elems = addr.split(":")
-
- if len(elems) > 1:
- host, port = elems[0], int(elems[1])
- else:
- host, port = elems[0], 5672
-
args = {
"name": name,
"host": host,
"port": port
}
- reg = action.invoke(None, args);
+ reg = action.invoke(None, args)
if len(groups) > i:
group = groups[i]
@@ -633,7 +627,14 @@
if not addr:
errs = aerrs.setdefault(i, list())
errs.append("The address field is empty; it is required")
+ else:
+ host, port = parse_broker_addr(addr)
+ if BrokerRegistration.selectBy(host=host, port=port).count():
+ errs = aerrs.setdefault(i, list())
+ errs.append("The broker at %s:%i " % (host, port) +
+ "is already registered")
+
return not len(nerrs) and not len(aerrs)
def render_title(self, session):
More information about the rhmessaging-commits
mailing list