Author: justi9
Date: 2008-11-24 13:16:15 -0500 (Mon, 24 Nov 2008)
New Revision: 2871
Modified:
mgmt/trunk/cumin/python/cumin/tools.py
Log:
Normalize broker urls before we store them
Modified: mgmt/trunk/cumin/python/cumin/tools.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/tools.py 2008-11-24 16:48:07 UTC (rev 2870)
+++ mgmt/trunk/cumin/python/cumin/tools.py 2008-11-24 18:16:15 UTC (rev 2871)
@@ -1,4 +1,4 @@
-import sys, os
+import sys, os, re
from parsley.config import *
from parsley.command import *
@@ -219,6 +219,18 @@
print "Error: a broker at %s already exists" % url
sys.exit(1)
+ url = url.strip()
+
+ expr = re.compile("^amqps?://")
+
+ if not expr.match(url):
+ url = "amqp://%s" % url
+
+ expr = re.compile(":[0-9]+$")
+
+ if not expr.match(url):
+ url = "%s:5672" % url
+
reg = BrokerRegistration(name=name, url=url)
reg.syncUpdate()