summaryrefslogtreecommitdiff
path: root/python/commands
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-05-09 11:15:35 +0000
committerGordon Sim <gsim@apache.org>2008-05-09 11:15:35 +0000
commit539672f9fa39dd22bb68fc50c22608aec2bdfe22 (patch)
tree5c78311f958e5bc45d90d02cb61c3274a0de651b /python/commands
parent53428ae6d4d2705a5df7eda2d43fdfbc92da3670 (diff)
downloadqpid-python-539672f9fa39dd22bb68fc50c22608aec2bdfe22.tar.gz
Enabled PLAIN authentication and setting of username and password for 0-10 python client.
Added options to all command line tools to allow a username and password to be specified. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@654759 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/commands')
-rwxr-xr-xpython/commands/qpid-config22
-rwxr-xr-xpython/commands/qpid-queue-stats20
-rwxr-xr-xpython/commands/qpid-route21
3 files changed, 13 insertions, 50 deletions
diff --git a/python/commands/qpid-config b/python/commands/qpid-config
index e916ee0f6c..8f2fb7ff1b 100755
--- a/python/commands/qpid-config
+++ b/python/commands/qpid-config
@@ -26,6 +26,7 @@ import socket
import qpid
from threading import Condition
from qpid.management import managementClient
+from qpid.managementdata import Broker
from qpid.peer import Closed
from qpid.connection import Connection
from qpid.datatypes import uuid4
@@ -62,8 +63,8 @@ def Usage ():
print "Options:"
print " -b [ --bindings ] Show bindings in queue or exchange list"
print " -a [ --broker-addr ] Address (localhost) Address of qpidd broker"
- print " broker-addr is in the form: hostname | ip-address [:<port>]"
- print " ex: localhost, 10.1.1.7:10000, broker-host:10000"
+ print " broker-addr is in the form: [username/password@] hostname | ip-address [:<port>]"
+ print " ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost"
print " -s [ --spec-file] Path (" + _defspecpath + ")"
print " AMQP specification file"
print
@@ -79,20 +80,6 @@ def Usage ():
print
sys.exit (1)
-class Broker:
- def __init__ (self, text):
- colon = text.find (":")
- if colon == -1:
- host = text
- self.port = 5672
- else:
- host = text[:colon]
- self.port = int (text[colon+1:])
- self.host = socket.gethostbyname (host)
-
- def name (self):
- return self.host + ":" + str (self.port)
-
class BrokerManager:
def __init__ (self):
self.dest = None
@@ -106,7 +93,8 @@ class BrokerManager:
try:
self.spec = qpid.spec.load (_specpath)
self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
- self.conn = Connection (connect (self.broker.host, self.broker.port), self.spec)
+ self.conn = Connection (connect (self.broker.host, self.broker.port), self.spec,
+ username=self.broker.username, password=self.broker.password)
self.conn.start ()
self.session = self.conn.session(str(uuid4()))
self.mclient = managementClient (self.spec)
diff --git a/python/commands/qpid-queue-stats b/python/commands/qpid-queue-stats
index 813c6e0cd2..8771c7dc5d 100755
--- a/python/commands/qpid-queue-stats
+++ b/python/commands/qpid-queue-stats
@@ -27,25 +27,12 @@ import socket
import qpid
from threading import Condition
from qpid.management import managementClient
+from qpid.managementdata import Broker
from qpid.peer import Closed
from qpid.connection import Connection
from qpid.util import connect
from time import sleep
-class Broker:
- def __init__ (self, text):
- colon = text.find (":")
- if colon == -1:
- host = text
- self.port = 5672
- else:
- host = text[:colon]
- self.port = int (text[colon+1:])
- self.host = socket.gethostbyname (host)
-
- def name (self):
- return self.host + ":" + str (self.port)
-
class mgmtObject (object):
""" Generic object that holds the contents of a management object with its
attributes set as object attributes. """
@@ -74,7 +61,8 @@ class BrokerManager:
try:
self.spec = qpid.spec.load (self.specpath)
self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
- self.conn = Connection (connect (self.broker.host, self.broker.port), self.spec)
+ self.conn = Connection (connect (self.broker.host, self.broker.port), self.spec,
+ username=self.broker.username, password=self.broker.password)
self.conn.start ()
self.mclient = managementClient (self.spec, None, self.configCb, self.instCb)
self.mchannel = self.mclient.addChannel (self.conn.session(self.sessionId))
@@ -154,7 +142,7 @@ class BrokerManager:
##
def main():
p = optparse.OptionParser()
- p.add_option('--broker-address','-a', default='localhost' , help='broker-addr is in the form: hostname | ip-address [:<port>] \n ex: localhost, 10.1.1.7:10000, broker-host:10000')
+ p.add_option('--broker-address','-a', default='localhost' , help='broker-addr is in the form: [username/password@] hostname | ip-address [:<port>] \n ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost')
p.add_option('--amqp-spec-file','-s', default='"/usr/share/amqp/amqp.0-10.xml', help='the path to the amqp spec file')
p.add_option('--filter','-f' ,default=None ,help='a list of comma separated queue names (regex are accepted) to show')
diff --git a/python/commands/qpid-route b/python/commands/qpid-route
index b08293fa00..baa45a320f 100755
--- a/python/commands/qpid-route
+++ b/python/commands/qpid-route
@@ -25,6 +25,7 @@ import socket
import qpid
import os
from qpid.management import managementClient
+from qpid.managementdata import Broker
from qpid.peer import Closed
from qpid.connection import Connection
from qpid.util import connect
@@ -41,8 +42,8 @@ def Usage ():
print " -v [ --verbose ] Verbose output"
print " -q [ --quiet ] Quiet output, don't print duplicate warnings"
print
- print " dest-broker and src-broker are in the form: hostname | ip-address [:<port>]"
- print " ex: localhost, 10.1.1.7:10000, broker-host:10000"
+ print " dest-broker and src-broker are in the form: [username/password@] hostname | ip-address [:<port>]"
+ print " ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost"
print
#print " If loading the route configuration from a file, the input file has one line per route"
#print " in the form:"
@@ -55,20 +56,6 @@ _specpath = "/usr/share/amqp/amqp.0-10.xml"
_verbose = False
_quiet = False
-class Broker:
- def __init__ (self, text):
- colon = text.find (":")
- if colon == -1:
- host = text
- self.port = 5672
- else:
- host = text[:colon]
- self.port = int (text[colon+1:])
- self.host = socket.gethostbyname (host)
-
- def name (self):
- return self.host + ":" + str (self.port)
-
class RouteManager:
def __init__ (self, destBroker):
self.dest = Broker (destBroker)
@@ -81,7 +68,7 @@ class RouteManager:
try:
self.spec = qpid.spec.load (_specpath)
self.sessionId = "%s.%d" % (os.uname()[1], os.getpid())
- self.conn = Connection (connect (broker.host, broker.port), self.spec)
+ self.conn = Connection (connect (broker.host, broker.port), self.spec, username=broker.username, password=broker.password)
self.conn.start ()
self.mclient = managementClient (self.spec)
self.mch = self.mclient.addChannel (self.conn.session(self.sessionId))