Author: jonathan
Date: Tue Dec 21 23:46:42 2010
New Revision: 1051700
URL: http://svn.apache.org/viewvc?rev=1051700&view=rev
Log:
Allow command line utilities to require a given SASL mechanism.
Useful if the client's most secure mechanism is suspect, e.g. if Kerberos
configuration problems may exist.
Also useful in a variety of test scenarios.
Modified:
qpid/trunk/qpid/cpp/src/tests/cli_tests.py
qpid/trunk/qpid/tools/src/py/qpid-config
qpid/trunk/qpid/tools/src/py/qpid-printevents
qpid/trunk/qpid/tools/src/py/qpid-queue-stats
qpid/trunk/qpid/tools/src/py/qpid-route
qpid/trunk/qpid/tools/src/py/qpid-stat
Modified: qpid/trunk/qpid/cpp/src/tests/cli_tests.py
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/cli_tests.py?rev=1051700&r1=1051699&r2=1051700&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/cli_tests.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/cli_tests.py Tue Dec 21 23:46:42 2010
@@ -177,6 +177,24 @@ class CliTests(TestBase010):
found = True
self.assertEqual(found, False)
+
+ def test_qpid_config_sasl_plain_expect_succeed(self):
+ self.startQmf();
+ qmf = self.qmf
+ qname = "test_qpid_config_sasl_plain_expect_succeed"
+ cmd = " --sasl-mechanism PLAIN -a
guest/gu...@localhost:"+str(self.broker.port) + " add queue " + qname
+ ret = self.qpid_config_api(cmd)
+ self.assertEqual(ret, 0)
+
+ def test_qpid_config_sasl_plain_expect_fail(self):
+ """Fails because no user name and password is supplied"""
+ self.startQmf();
+ qmf = self.qmf
+ qname = "test_qpid_config_sasl_plain_expect_succeed"
+ cmd = " --sasl-mechanism PLAIN -a localhost:"+str(self.broker.port) +
" add queue " + qname
+ ret = self.qpid_config_api(cmd)
+ assert ret != 0
+
# helpers for some of the test methods
def helper_find_exchange(self, xchgname, typ, expected=True):
xchgs = self.qmf.getObjects(_class = "exchange")
@@ -382,6 +400,37 @@ class CliTests(TestBase010):
self.assertEqual(found, True)
+ def test_qpid_route_api(self):
+ self.startQmf();
+ qmf = self.qmf
+
+ ret = self.qpid_route_api("dynamic add "
+ + " --sasl-mechanism PLAIN "
+ +
"guest/gu...@localhost:"+str(self.broker.port) + " "
+ +
str(self.remote_host())+":"+str(self.remote_port()) + " "
+ +"amq.direct")
+
+ self.assertEqual(ret, 0)
+
+ links = qmf.getObjects(_class="link")
+ found = False
+ for link in links:
+ if link.port == self.remote_port():
+ found = True
+ self.assertEqual(found, True)
+
+ def test_qpid_route_api_expect_fail(self):
+ self.startQmf();
+ qmf = self.qmf
+
+ ret = self.qpid_route_api("dynamic add "
+ + " --sasl-mechanism PLAIN "
+ + "localhost:"+str(self.broker.port) + " "
+ +
str(self.remote_host())+":"+str(self.remote_port()) + " "
+ +"amq.direct")
+ assert ret != 0
+
+
def getProperty(self, msg, name):
for h in msg.headers:
if hasattr(h, name): return getattr(h, name)
Modified: qpid/trunk/qpid/tools/src/py/qpid-config
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-config?rev=1051700&r1=1051699&r2=1051700&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-config (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-config Tue Dec 21 23:46:42 2010
@@ -46,6 +46,7 @@ class Config:
self._ive = False
self._eventGeneration = None
self._file = None
+ self._sasl_mechanism = None
config = Config()
@@ -138,26 +139,27 @@ def OptionsAndArguments(argv):
formatter=JHelpFormatter())
group1 = OptionGroup(parser, "General Options")
- group1.add_option("-t", "--timeout", action="store", type="int",
default=10, metavar="SECS", help="Maximum time to wait for broker connection
(in seconds)")
+ group1.add_option("-t", "--timeout", action="store", type="int",
default=10, metavar="<secs>", help="Maximum time to wait for broker connection
(in seconds)")
group1.add_option("-b", "--bindings", action="store_true", help="Show
bindings in queue or exchange list")
- group1.add_option("-a", "--broker-addr", action="store", type="string",
default="localhost:5672", metavar="ADDRESS", help="Maximum time to wait for
broker connection (in seconds)")
+ group1.add_option("-a", "--broker-addr", action="store", type="string",
default="localhost:5672", metavar="<address>", help="Maximum time to wait for
broker connection (in seconds)")
+ group1.add_option("--sasl-mechanism", action="store",
choices=["EXTERNAL","ANONYMOUS","PLAIN","CRAM-MD5","DIGEST-MD5","GSSAPI"],
metavar="<mech>", help="SASL mechanism for authentication. SASL automatically
picks the most secure available mechanism - use this option to override.")
parser.add_option_group(group1)
group2 = OptionGroup(parser, "Options for Adding Exchanges and Queues")
- group2.add_option("--alternate-exchange", action="store", type="string",
metavar="NAME", help="Name of the alternate-exchange for the new queue or
exchange. Exchanges route messages to the alternate exchange if they are unable
to route them elsewhere. Queues route messages to the alternate exchange if
they are rejected by a subscriber or orphaned by queue deletion.")
+ group2.add_option("--alternate-exchange", action="store", type="string",
metavar="<aexname>", help="Name of the alternate-exchange for the new queue or
exchange. Exchanges route messages to the alternate exchange if they are unable
to route them elsewhere. Queues route messages to the alternate exchange if
they are rejected by a subscriber or orphaned by queue deletion.")
group2.add_option("--passive", "--dry-run", action="store_true", help="Do
not actually add the exchange or queue, ensure that all parameters and
permissions are correct and would allow it to be created.")
group2.add_option("--durable", action="store_true", help="The new queue or
exchange is durable.")
parser.add_option_group(group2)
group3 = OptionGroup(parser, "Options for Adding Queues")
group3.add_option("--cluster-durable", action="store_true", help="The new
queue becomes durable if there is only one functioning cluster node")
- group3.add_option("--file-count", action="store", type="int", default=8,
metavar="N", help="Number of files in queue's persistence journal")
- group3.add_option("--file-size", action="store", type="int", default=24,
metavar="N", help="File size in pages (64Kib/page)")
- group3.add_option("--max-queue-size", action="store", type="int",
metavar="N", help="Number of files in queue's persistence journal")
- group3.add_option("--max-queue-count", action="store", type="int",
metavar="N", help="Number of files in queue's persistence journal")
- group3.add_option("--limit-policy", action="store", choices=["none",
"reject", "flow-to-disk", "ring", "ring-strict"], metavar="CHOICE",
help="Action to take when queue limit is reached")
- group3.add_option("--order", action="store", choices=["fifo", "lvq",
"lvq-no-browse"], metavar="CHOICE", help="Queue ordering policy")
- group3.add_option("--generate-queue-events", action="store", type="int",
metavar="N", help="If set to 1, every enqueue will generate an event that can
be processed by registered listeners (e.g. for replication). If set to 2,
events will be generated for enqueues and dequeues.")
+ group3.add_option("--file-count", action="store", type="int", default=8,
metavar="<n>", help="Number of files in queue's persistence journal")
+ group3.add_option("--file-size", action="store", type="int", default=24,
metavar="<n>", help="File size in pages (64Kib/page)")
+ group3.add_option("--max-queue-size", action="store", type="int",
metavar="<n>", help="Number of files in queue's persistence journal")
+ group3.add_option("--max-queue-count", action="store", type="int",
metavar="<n>", help="Number of files in queue's persistence journal")
+ group3.add_option("--limit-policy", action="store", choices=["none",
"reject", "flow-to-disk", "ring", "ring-strict"], metavar="<policy>",
help="Action to take when queue limit is reached")
+ group3.add_option("--order", action="store", choices=["fifo", "lvq",
"lvq-no-browse"], metavar="<ordering>", help="Queue ordering policy")
+ group3.add_option("--generate-queue-events", action="store", type="int",
metavar="<n>", help="If set to 1, every enqueue will generate an event that can
be processed by registered listeners (e.g. for replication). If set to 2,
events will be generated for enqueues and dequeues.")
# no option for declaring an exclusive queue - which can only be used by
the session that creates it.
parser.add_option_group(group3)
@@ -173,7 +175,7 @@ def OptionsAndArguments(argv):
parser.add_option_group(group5)
group6 = OptionGroup(parser, "Options for Declaring Bindings")
- group6.add_option("-f", "--file", action="store", type="string",
metavar="FILE.xq", help="For XML Exchange bindings - specifies the name of a
file containing an XQuery.")
+ group6.add_option("-f", "--file", action="store", type="string",
metavar="<file.xq>", help="For XML Exchange bindings - specifies the name of a
file containing an XQuery.")
parser.add_option_group(group6)
opts, encArgs = parser.parse_args(args=argv)
@@ -227,7 +229,8 @@ def OptionsAndArguments(argv):
config._if_empty = False
if opts.force_if_not_used:
config._if_unused = False
-
+ if opts.sasl_mechanism:
+ config._sasl_mechanism = opts.sasl_mechanism
return args
@@ -272,15 +275,16 @@ def snarf_header_args(args):
return [False]
class BrokerManager:
- def __init__ (self):
+ def __init__(self):
self.brokerName = None
self.qmf = None
self.broker = None
+ self.mechanism = None
- def SetBroker (self, brokerUrl):
+ def SetBroker(self, brokerUrl, mechanism):
self.url = brokerUrl
self.qmf = Session()
- self.broker = self.qmf.addBroker(brokerUrl, config._connTimeout)
+ self.broker = self.qmf.addBroker(brokerUrl, config._connTimeout,
mechanism)
agents = self.qmf.getAgents()
for a in agents:
if a.getAgentBank() == '0':
@@ -290,7 +294,7 @@ class BrokerManager:
if self.broker:
self.qmf.delBroker(self.broker)
- def Overview (self):
+ def Overview(self):
exchanges = self.qmf.getObjects(_class="exchange",
_agent=self.brokerAgent)
queues = self.qmf.getObjects(_class="queue",
_agent=self.brokerAgent)
print "Total Exchanges: %d" % len (exchanges)
@@ -312,7 +316,7 @@ class BrokerManager:
print " durable: %d" % durable
print " non-durable: %d" % (len (queues) - durable)
- def ExchangeList (self, filter):
+ def ExchangeList(self, filter):
exchanges = self.qmf.getObjects(_class="exchange",
_agent=self.brokerAgent)
caption1 = "Type "
caption2 = "Exchange Name"
@@ -327,7 +331,7 @@ class BrokerManager:
print line
for ex in exchanges:
- if self.match (ex.name, filter):
+ if self.match(ex.name, filter):
print "%-10s%-*s " % (ex.type, maxNameLen, ex.name),
args = ex.arguments
if ex.durable: print "--durable",
@@ -337,29 +341,29 @@ class BrokerManager:
print "--alternate-exchange=%s" % ex._altExchange_.name,
print
- def ExchangeListRecurse (self, filter):
+ def ExchangeListRecurse(self, filter):
exchanges = self.qmf.getObjects(_class="exchange",
_agent=self.brokerAgent)
bindings = self.qmf.getObjects(_class="binding",
_agent=self.brokerAgent)
queues = self.qmf.getObjects(_class="queue",
_agent=self.brokerAgent)
for ex in exchanges:
- if self.match (ex.name, filter):
+ if self.match(ex.name, filter):
print "Exchange '%s' (%s)" % (ex.name, ex.type)
for bind in bindings:
if bind.exchangeRef == ex.getObjectId():
qname = "<unknown>"
- queue = self.findById (queues, bind.queueRef)
+ queue = self.findById(queues, bind.queueRef)
if queue != None:
qname = queue.name
print " bind [%s] => %s" % (bind.bindingKey, qname)
- def QueueList (self, filter):
+ def QueueList(self, filter):
queues = self.qmf.getObjects(_class="queue", _agent=self.brokerAgent)
caption = "Queue Name"
maxNameLen = len(caption)
for q in queues:
- if self.match (q.name, filter):
+ if self.match(q.name, filter):
if len(q.name) > maxNameLen: maxNameLen = len(q.name)
print "%-*s Attributes" % (maxNameLen, caption)
line = ""
@@ -368,7 +372,7 @@ class BrokerManager:
print line
for q in queues:
- if self.match (q.name, filter):
+ if self.match(q.name, filter):
print "%-*s " % (maxNameLen, q.name),
args = q.arguments
if q.durable: print "--durable",
@@ -387,25 +391,25 @@ class BrokerManager:
print "--alternate-exchange=%s" % q._altExchange_.name,
print
- def QueueListRecurse (self, filter):
+ def QueueListRecurse(self, filter):
exchanges = self.qmf.getObjects(_class="exchange",
_agent=self.brokerAgent)
bindings = self.qmf.getObjects(_class="binding",
_agent=self.brokerAgent)
queues = self.qmf.getObjects(_class="queue",
_agent=self.brokerAgent)
for queue in queues:
- if self.match (queue.name, filter):
+ if self.match(queue.name, filter):
print "Queue '%s'" % queue.name
for bind in bindings:
if bind.queueRef == queue.getObjectId():
ename = "<unknown>"
- ex = self.findById (exchanges, bind.exchangeRef)
+ ex = self.findById(exchanges, bind.exchangeRef)
if ex != None:
ename = ex.name
if ename == "":
ename = "''"
print " bind [%s] => %s" % (bind.bindingKey, ename)
- def AddExchange (self, args):
- if len (args) < 2:
+ def AddExchange(self, args):
+ if len(args) < 2:
Usage()
etype = args[0]
ename = args[1]
@@ -415,18 +419,18 @@ class BrokerManager:
if config._ive:
declArgs[IVE] = 1
if config._altern_ex != None:
- self.broker.getAmqpSession().exchange_declare (exchange=ename,
type=etype, alternate_exchange=config._altern_ex, passive=config._passive,
durable=config._durable, arguments=declArgs)
+ self.broker.getAmqpSession().exchange_declare(exchange=ename,
type=etype, alternate_exchange=config._altern_ex, passive=config._passive,
durable=config._durable, arguments=declArgs)
else:
- self.broker.getAmqpSession().exchange_declare (exchange=ename,
type=etype, passive=config._passive, durable=config._durable,
arguments=declArgs)
+ self.broker.getAmqpSession().exchange_declare(exchange=ename,
type=etype, passive=config._passive, durable=config._durable,
arguments=declArgs)
- def DelExchange (self, args):
- if len (args) < 1:
+ def DelExchange(self, args):
+ if len(args) < 1:
Usage()
ename = args[0]
- self.broker.getAmqpSession().exchange_delete (exchange=ename)
+ self.broker.getAmqpSession().exchange_delete(exchange=ename)
- def AddQueue (self, args):
- if len (args) < 1:
+ def AddQueue(self, args):
+ if len(args) < 1:
Usage()
qname = args[0]
declArgs = {}
@@ -463,24 +467,24 @@ class BrokerManager:
declArgs[QUEUE_EVENT_GENERATION] = config._eventGeneration
if config._altern_ex != None:
- self.broker.getAmqpSession().queue_declare (queue=qname,
alternate_exchange=config._altern_ex, passive=config._passive,
durable=config._durable, arguments=declArgs)
+ self.broker.getAmqpSession().queue_declare(queue=qname,
alternate_exchange=config._altern_ex, passive=config._passive,
durable=config._durable, arguments=declArgs)
else:
- self.broker.getAmqpSession().queue_declare (queue=qname,
passive=config._passive, durable=config._durable, arguments=declArgs)
+ self.broker.getAmqpSession().queue_declare(queue=qname,
passive=config._passive, durable=config._durable, arguments=declArgs)
- def DelQueue (self, args):
- if len (args) < 1:
+ def DelQueue(self, args):
+ if len(args) < 1:
Usage()
qname = args[0]
- self.broker.getAmqpSession().queue_delete (queue=qname,
if_empty=config._if_empty, if_unused=config._if_unused)
+ self.broker.getAmqpSession().queue_delete(queue=qname,
if_empty=config._if_empty, if_unused=config._if_unused)
- def Bind (self, args):
- if len (args) < 2:
+ def Bind(self, args):
+ if len(args) < 2:
Usage()
ename = args[0]
qname = args[1]
key = ""
- if len (args) > 2:
+ if len(args) > 2:
key = args[2]
# query the exchange to determine its type.
@@ -507,35 +511,35 @@ class BrokerManager:
if not ok:
sys.exit(1)
- self.broker.getAmqpSession().exchange_bind (queue=qname,
+ self.broker.getAmqpSession().exchange_bind(queue=qname,
exchange=ename,
binding_key=key,
arguments=_args)
- def Unbind (self, args):
- if len (args) < 2:
+ def Unbind(self, args):
+ if len(args) < 2:
Usage()
ename = args[0]
qname = args[1]
key = ""
- if len (args) > 2:
+ if len(args) > 2:
key = args[2]
- self.broker.getAmqpSession().exchange_unbind (queue=qname,
exchange=ename, binding_key=key)
+ self.broker.getAmqpSession().exchange_unbind(queue=qname,
exchange=ename, binding_key=key)
- def findBId (self, items, id):
+ def findBId(self, items, id):
for item in items:
if item.getObjectId() == id:
return item
return None
- def match (self, name, filter):
+ def match(self, name, filter):
if filter == "":
return True
- if name.find (filter) == -1:
+ if name.find(filter) == -1:
return False
return True
-def YN (bool):
+def YN(bool):
if bool:
return 'Y'
return 'N'
@@ -543,12 +547,12 @@ def YN (bool):
def main(argv=None):
args = OptionsAndArguments(argv)
- bm = BrokerManager ()
+ bm = BrokerManager()
try:
- bm.SetBroker(config._host)
+ bm.SetBroker(config._host, config._sasl_mechanism)
if len(args) == 0:
- bm.Overview ()
+ bm.Overview()
else:
cmd = args[0]
modifier = ""
@@ -556,32 +560,32 @@ def main(argv=None):
modifier = args[1]
if cmd == "exchanges":
if config._recursive:
- bm.ExchangeListRecurse (modifier)
+ bm.ExchangeListRecurse(modifier)
else:
- bm.ExchangeList (modifier)
+ bm.ExchangeList(modifier)
elif cmd == "queues":
if config._recursive:
- bm.QueueListRecurse (modifier)
+ bm.QueueListRecurse(modifier)
else:
- bm.QueueList (modifier)
+ bm.QueueList(modifier)
elif cmd == "add":
if modifier == "exchange":
- bm.AddExchange (args[2:])
+ bm.AddExchange(args[2:])
elif modifier == "queue":
- bm.AddQueue (args[2:])
+ bm.AddQueue(args[2:])
else:
Usage()
elif cmd == "del":
if modifier == "exchange":
- bm.DelExchange (args[2:])
+ bm.DelExchange(args[2:])
elif modifier == "queue":
- bm.DelQueue (args[2:])
+ bm.DelQueue(args[2:])
else:
Usage()
elif cmd == "bind":
- bm.Bind (args[1:])
+ bm.Bind(args[1:])
elif cmd == "unbind":
- bm.Unbind (args[1:])
+ bm.Unbind(args[1:])
else:
Usage()
except KeyboardInterrupt:
Modified: qpid/trunk/qpid/tools/src/py/qpid-printevents
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-printevents?rev=1051700&r1=1051699&r2=1051700&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-printevents (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-printevents Tue Dec 21 23:46:42 2010
@@ -27,6 +27,7 @@ import socket
from time import time, strftime, gmtime, sleep
from qmf.console import Console, Session
+
class EventConsole(Console):
def event(self, broker, event):
print event
@@ -75,17 +76,19 @@ $ %prog guest/gu...@broker-host:10000
def main(argv=None):
p = optparse.OptionParser(usage=_usage, description=_description,
formatter=JHelpFormatter())
+ p.add_option("--heartbeats", action="store_true", default=False, help="Use
heartbeats.")
+ p.add_option("--sasl-mechanism", action="store",
choices=["EXTERNAL","ANONYMOUS","PLAIN","CRAM-MD5","DIGEST-MD5","GSSAPI"],
metavar="<mech>", help="SASL mechanism for authentication. SASL automatically
picks the most secure available mechanism - use this option to override.")
options, arguments = p.parse_args(args=argv)
if len(arguments) == 0:
arguments.append("localhost")
console = EventConsole()
- session = Session(console, rcvObjects=False, rcvHeartbeats=False,
manageConnections=True)
+ session = Session(console, rcvObjects=False,
rcvHeartbeats=options.heartbeats, manageConnections=True)
brokers = []
try:
for host in arguments:
- brokers.append(session.addBroker(host))
+ brokers.append(session.addBroker(host, None, options.sasl_mechanism))
try:
while (True):
sleep(10)
Modified: qpid/trunk/qpid/tools/src/py/qpid-queue-stats
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-queue-stats?rev=1051700&r1=1051699&r2=1051700&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-queue-stats (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-queue-stats Tue Dec 21 23:46:42 2010
@@ -32,13 +32,13 @@ from qpid.connection import Connection,
from time import sleep
class BrokerManager(Console):
- def __init__(self, host):
+ def __init__(self, host, mechanism):
self.url = host
self.objects = {}
self.filter = None
self.session = Session(self, rcvEvents=False, rcvHeartbeats=False,
userBindings=True, manageConnections=True)
- self.broker = self.session.addBroker(self.url)
+ self.broker = self.session.addBroker(self.url, None, mechanism)
self.firstError = True
def setFilter(self,filter):
@@ -121,13 +121,11 @@ class BrokerManager(Console):
print
self.session.delBroker(self.broker)
-##
-## Main Program
-##
def main(argv=None):
p = optparse.OptionParser()
p.add_option('--broker-address','-a', default='localhost' ,
help='broker-addr is in the form: [username/passw...@] hostname | ip-address
[:<port>] \n ex: localhost, 10.1.1.7:10000, broker-host:10000,
guest/gu...@localhost')
p.add_option('--filter','-f' ,default=None ,help='a list of comma separated
queue names (regex are accepted) to show')
+ p.add_option("--sasl-mechanism", action="store",
choices=["EXTERNAL","ANONYMOUS","PLAIN","CRAM-MD5","DIGEST-MD5","GSSAPI"],
metavar="<mech>", help="SASL mechanism for authentication. SASL automatically
picks the most secure available mechanism - use this option to override.")
options, arguments = p.parse_args(args=argv)
@@ -137,7 +135,7 @@ def main(argv=None):
for s in options.filter.split(","):
filter.append(re.compile(s))
- bm = BrokerManager(host)
+ bm = BrokerManager(host, options.sasl_mechanism)
bm.setFilter(filter)
bm.Display()
Modified: qpid/trunk/qpid/tools/src/py/qpid-route
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-route?rev=1051700&r1=1051699&r2=1051700&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-route (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-route Tue Dec 21 23:46:42 2010
@@ -36,6 +36,7 @@ class Config:
self._transport = "tcp"
self._ack = 0
self._connTimeout = 10
+ self._sasl_mechanism = None
config = Config()
@@ -86,7 +87,7 @@ def OptionsAndArguments(argv):
description=description,
formatter=JHelpFormatter())
- parser.add_option("--timeout", action="store", type="int", default=10,
metavar="SECS", help="Maximum time to wait for broker connection (in seconds)")
+ parser.add_option("--timeout", action="store", type="int", default=10,
metavar="<secs>", help="Maximum time to wait for broker connection (in
seconds)")
parser.add_option("-v", "--verbose", action="store_true", help="Verbose
output")
parser.add_option("-q", "--quiet", action="store_true", help="Quiet
output, don't print duplicate warnings")
parser.add_option("-d", "--durable", action="store_true", help="Added
configuration shall be durable")
@@ -94,9 +95,11 @@ def OptionsAndArguments(argv):
parser.add_option("-e", "--del-empty-link", action="store_true",
help="Delete link after deleting last route on the link")
parser.add_option("-s", "--src-local", action="store_true", help="Make
connection to source broker (push route)")
- parser.add_option("--ack", action="store", type="int", metavar="N",
help="Acknowledge transfers over the bridge in batches of N")
+ parser.add_option("--ack", action="store", type="int", metavar="<n>",
help="Acknowledge transfers over the bridge in batches of N")
parser.add_option("-t", "--transport", action="store", type="string",
default="tcp", metavar="<transport>", help="Transport to use for links,
defaults to tcp")
+ parser.add_option("--sasl-mechanism", action="store",
choices=["EXTERNAL","ANONYMOUS","PLAIN","CRAM-MD5","DIGEST-MD5","GSSAPI"],
metavar="<mech>", help="SASL mechanism for authentication. Used when the client
connects to the destination broker (not for authentication between the source
and destination brokers - that is specified using the [mechanisms] argument to
'add route'). SASL automatically picks the most secure available mechanism -
use this option to override.")
+
opts, encArgs = parser.parse_args(args=argv)
try:
@@ -131,6 +134,9 @@ def OptionsAndArguments(argv):
if opts.ack:
config._ack = opts.ack
+ if opts.sasl_mechanism:
+ config._sasl_mechanism = opts.sasl_mechanism
+
return args
@@ -140,7 +146,7 @@ class RouteManager:
self.local = BrokerURL(localBroker)
self.remote = None
self.qmf = Session()
- self.broker = self.qmf.addBroker(localBroker, config._connTimeout)
+ self.broker = self.qmf.addBroker(localBroker, config._connTimeout,
config._sasl_mechanism)
self.broker._waitForStable()
self.agent = self.broker.getBrokerAgent()
Modified: qpid/trunk/qpid/tools/src/py/qpid-stat
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-stat?rev=1051700&r1=1051699&r2=1051700&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-stat (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-stat Tue Dec 21 23:46:42 2010
@@ -38,6 +38,7 @@ class Config:
self._increasing = False
self._sortcol = None
self._cluster_detail = False
+ self._sasl_mechanism = None
config = Config()
@@ -47,11 +48,11 @@ def OptionsAndArguments(argv):
global config
parser = OptionParser(usage="usage: %prog [options] BROKER",
- description="Example: $ qpid-stat -q
broker-host:10000")
+ description="Example: $ qpid-stat -q broker-host:10000")
group1 = OptionGroup(parser, "General Options")
- group1.add_option("-t", "--timeout", action="store", type="int",
default=10, metavar="SECS", help="Maximum time to wait for broker connection
(in seconds)")
-
+ group1.add_option("-t", "--timeout", action="store", type="int",
default=10, metavar="<secs>", help="Maximum time to wait for broker connection
(in seconds)")
+ group1.add_option("--sasl-mechanism", action="store",
choices=["EXTERNAL","ANONYMOUS","PLAIN","CRAM-MD5","DIGEST-MD5","GSSAPI"],
metavar="<mech>", help="SASL mechanism for authentication. SASL automatically
picks the most secure available mechanism - use this option to override.")
parser.add_option_group(group1)
group2 = OptionGroup(parser, "Display Options")
@@ -62,17 +63,17 @@ def OptionsAndArguments(argv):
group2.add_option("-e", "--exchanges", help="Show Exchanges",
action="store_const", const="e", dest="show")
group2.add_option("-q", "--queues", help="Show Queues",
- action="store_const", const="q", dest="show")
+ action="store_const", const="q", dest="show")
group2.add_option("-u", "--subscriptions", help="Show Subscriptions",
- action="store_const", const="u", dest="show")
- group2.add_option("-S", "--sort-by", metavar="COLNAME",
- help="Sort by column name")
+ action="store_const", const="u", dest="show")
+ group2.add_option("-S", "--sort-by", metavar="<colname>",
+ help="Sort by column name")
group2.add_option("-I", "--increasing", action="store_true", default=False,
- help="Sort by increasing value (default = decreasing)")
- group2.add_option("-L", "--limit", default=50, metavar="NUM",
- help="Limit output to NUM rows")
+ help="Sort by increasing value (default = decreasing)")
+ group2.add_option("-L", "--limit", default=50, metavar="<n>",
+ help="Limit output to n rows")
group2.add_option("-C", "--cluster", action="store_true", default=False,
- help="Display per-broker cluster detail.")
+ help="Display per-broker cluster detail.")
parser.add_option_group(group2)
opts, args = parser.parse_args(args=argv)
@@ -86,6 +87,7 @@ def OptionsAndArguments(argv):
config._increasing = opts.increasing
config._limit = opts.limit
config._cluster_detail = opts.cluster
+ config._sasl_mechanism = opts.sasl_mechanism
if args:
config._host = args[0]
@@ -178,10 +180,11 @@ class BrokerManager(Console):
self.brokers = []
self.cluster = None
- def SetBroker(self, brokerUrl):
+ def SetBroker(self, brokerUrl, mechanism):
self.url = brokerUrl
self.qmf = Session()
- self.broker = self.qmf.addBroker(brokerUrl, config._connTimeout)
+ self.mechanism = mechanism
+ self.broker = self.qmf.addBroker(brokerUrl, config._connTimeout,
mechanism)
agents = self.qmf.getAgents()
for a in agents:
if a.getAgentBank() == '0':
@@ -502,7 +505,7 @@ def main(argv=None):
bm = BrokerManager()
try:
- bm.SetBroker(config._host)
+ bm.SetBroker(config._host, config._sasl_mechanism)
bm.display()
bm.Disconnect()
return 0
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]