summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnest Allen <eallen@apache.org>2015-01-12 22:18:34 +0000
committerErnest Allen <eallen@apache.org>2015-01-12 22:18:34 +0000
commit2875ee8a2e91e8ce21a990da046ce88e2db0e112 (patch)
treece2142d7da359e03a078cb1e0b751b7f88920838
parent22f1697cbe8585c9534052b0ced167ed6c827555 (diff)
downloadqpid-python-2875ee8a2e91e8ce21a990da046ce88e2db0e112.tar.gz
QPID-6013 qpid-route should warn when a federation link was not created successfully
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1651216 13f79535-47bb-0310-9956-ffa450edef68
-rwxr-xr-xqpid/tools/src/py/qpid-route25
1 files changed, 19 insertions, 6 deletions
diff --git a/qpid/tools/src/py/qpid-route b/qpid/tools/src/py/qpid-route
index 6890f2a819..66c0e6d829 100755
--- a/qpid/tools/src/py/qpid-route
+++ b/qpid/tools/src/py/qpid-route
@@ -25,6 +25,7 @@ import socket
import os
import locale
from qmf.console import Session, BrokerURL
+from time import sleep
usage = """
Usage: qpid-route [OPTIONS] dynamic add <dest-broker> <src-broker> <exchange> [tag] [exclude-list] [mechanism]
@@ -184,6 +185,21 @@ class RouteManager:
return link
return None
+ def checkLink(self, link):
+ retry = 3
+ while link is None or (link.state in ("Waiting", "Connecting", "Closing") and retry > 0):
+ sleep(1)
+ link = self.getLink()
+ retry -= 1
+
+ if link == None:
+ raise Exception("Link failed to create")
+
+ if link.state == "Failed":
+ raise Exception("Link failed to create %s" % (link.lastError or ""))
+ elif config._verbose:
+ print "Link state is", link.state
+
def addLink(self, remoteBroker, interbroker_mechanism=""):
self.remote = BrokerURL(remoteBroker)
if self.local.match(self.remote.host, self.remote.port):
@@ -196,8 +212,6 @@ class RouteManager:
res = broker.connect(self.remote.host, self.remote.port, config._durable,
interbroker_mechanism, self.remote.authName or "", self.remote.authPass or "",
config._transport)
- if config._verbose:
- print "Connect method returned:", res.status, res.text
def delLink(self, remoteBroker):
self.remote = BrokerURL(remoteBroker)
@@ -321,8 +335,7 @@ class RouteManager:
self.addLink(remoteBroker, interbroker_mechanism)
link = self.getLink()
- if link == None:
- raise Exception("Link failed to create")
+ self.checkLink(link)
bridges = self.agent.getObjects(_class="bridge")
for bridge in bridges:
@@ -345,8 +358,7 @@ class RouteManager:
def addQueueRoute(self, remoteBroker, interbroker_mechanism, exchange, queue ):
self.addLink(remoteBroker, interbroker_mechanism)
link = self.getLink()
- if link == None:
- raise Exception("Link failed to create")
+ self.checkLink(link)
bridges = self.agent.getObjects(_class="bridge")
for bridge in bridges:
@@ -537,6 +549,7 @@ def main(argv=None):
interbroker_mechanism = ""
if nargs > 4: interbroker_mechanism = args[4]
rm.addLink(remoteBroker, interbroker_mechanism)
+ rm.checkLink(rm.getLink())
elif cmd == "del":
if nargs != 4:
Usage()