summaryrefslogtreecommitdiff
path: root/qpid/tools
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2012-03-05 21:04:04 +0000
committerTed Ross <tross@apache.org>2012-03-05 21:04:04 +0000
commit15f7c4dd7936a34151b748a4ddbf7cdc2bdb87f0 (patch)
tree939675fc59b52ef004d2caf2834f26c767482326 /qpid/tools
parent309c1956acf1332d09867c1bbab8a7a1624909da (diff)
downloadqpid-python-15f7c4dd7936a34151b748a4ddbf7cdc2bdb87f0.tar.gz
NO-JIRA - Cleaned up qpidtoollibs
1) Fixed the update() method to work on all object types 2) Shortened the path needed in import statements 3) Updated the connection-stats test to use qpidtoollibs git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1297230 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/tools')
-rwxr-xr-xqpid/tools/src/py/qpid-config2
-rwxr-xr-xqpid/tools/src/py/qpid-stat4
-rw-r--r--qpid/tools/src/py/qpidtoollibs/__init__.py4
-rw-r--r--qpid/tools/src/py/qpidtoollibs/broker.py44
4 files changed, 30 insertions, 24 deletions
diff --git a/qpid/tools/src/py/qpid-config b/qpid/tools/src/py/qpid-config
index 367fd0574e..fb0f34f72e 100755
--- a/qpid/tools/src/py/qpid-config
+++ b/qpid/tools/src/py/qpid-config
@@ -29,7 +29,7 @@ home = os.environ.get("QPID_TOOLS_HOME", os.path.normpath("/usr/share/qpid-tools
sys.path.append(os.path.join(home, "python"))
from qpid.messaging import Connection
-from qpidtoollibs.broker import BrokerAgent
+from qpidtoollibs import BrokerAgent
usage = """
Usage: qpid-config [OPTIONS]
diff --git a/qpid/tools/src/py/qpid-stat b/qpid/tools/src/py/qpid-stat
index 17e4120f60..5a816baf6e 100755
--- a/qpid/tools/src/py/qpid-stat
+++ b/qpid/tools/src/py/qpid-stat
@@ -30,8 +30,8 @@ from qpid.messaging import Connection
home = os.environ.get("QPID_TOOLS_HOME", os.path.normpath("/usr/share/qpid-tools"))
sys.path.append(os.path.join(home, "python"))
-from qpidtoollibs.broker import BrokerAgent
-from qpidtoollibs.disp import Display, Header, Sorter, YN, Commas, TimeLong
+from qpidtoollibs import BrokerAgent
+from qpidtoollibs import Display, Header, Sorter, YN, Commas, TimeLong
class Config:
diff --git a/qpid/tools/src/py/qpidtoollibs/__init__.py b/qpid/tools/src/py/qpidtoollibs/__init__.py
index 31d5a2ef58..2815bac22f 100644
--- a/qpid/tools/src/py/qpidtoollibs/__init__.py
+++ b/qpid/tools/src/py/qpidtoollibs/__init__.py
@@ -16,3 +16,7 @@
# specific language governing permissions and limitations
# under the License.
#
+
+from qpidtoollibs.broker import *
+from qpidtoollibs.disp import *
+
diff --git a/qpid/tools/src/py/qpidtoollibs/broker.py b/qpid/tools/src/py/qpidtoollibs/broker.py
index 98c1bfaa32..c2340de9dd 100644
--- a/qpid/tools/src/py/qpidtoollibs/broker.py
+++ b/qpid/tools/src/py/qpidtoollibs/broker.py
@@ -95,9 +95,8 @@ class BrokerAgent(object):
self.sess.acknowledge()
return items
- def _doNameQuery(self, class_name, object_name, package_name='org.apache.qpid.broker'):
- query = {'_what' : 'OBJECT',
- '_object_id' : {'_object_name' : "%s:%s:%s" % (package_name, class_name, object_name)}}
+ def _doNameQuery(self, object_id):
+ query = {'_what' : 'OBJECT', '_object_id' : {'_object_name' : object_id}}
correlator = self._sendRequest('_query_request', query)
response = self.reply_rx.fetch(10)
if response.properties['qmf.opcode'] != '_query_response':
@@ -123,13 +122,18 @@ class BrokerAgent(object):
objs.append(cls(self, item))
return objs
- def _getBrokerObject(self, cls, name):
- obj = self._doNameQuery(cls.__name__.lower(), name)
+ def _getBrokerObject(self, cls, oid):
+ obj = self._doNameQuery(oid)
if obj:
return cls(self, obj)
return None
def _getSingleObject(self, cls):
+ #
+ # getAllBrokerObjects is used instead of getBrokerObject(Broker, 'amqp-broker') because
+ # of a bug that used to be in the broker whereby by-name queries did not return the
+ # object timestamps.
+ #
objects = self._getAllBrokerObjects(cls)
if objects: return objects[0]
return None
@@ -138,11 +142,6 @@ class BrokerAgent(object):
"""
Get the Broker object that contains broker-scope statistics and operations.
"""
- #
- # getAllBrokerObjects is used instead of getBrokerObject(Broker, 'amqp-broker') because
- # of a bug that used to be in the broker whereby by-name queries did not return the
- # object timestamps.
- #
return self._getSingleObject(Broker)
@@ -155,32 +154,32 @@ class BrokerAgent(object):
def getAllConnections(self):
return self._getAllBrokerObjects(Connection)
- def getConnection(self, name):
- return self._getBrokerObject(Connection, name)
+ def getConnection(self, oid):
+ return self._getBrokerObject(Connection, "org.apache.qpid.broker:connection:%s" % oid)
def getAllSessions(self):
return self._getAllBrokerObjects(Session)
- def getSession(self, name):
- return self._getBrokerObject(Session, name)
+ def getSession(self, oid):
+ return self._getBrokerObject(Session, "org.apache.qpid.broker:session:%s" % oid)
def getAllSubscriptions(self):
return self._getAllBrokerObjects(Subscription)
- def getSubscription(self, name):
- return self._getBrokerObject(Subscription, name)
+ def getSubscription(self, oid):
+ return self._getBrokerObject(Subscription, "org.apache.qpid.broker:subscription:%s" % oid)
def getAllExchanges(self):
return self._getAllBrokerObjects(Exchange)
def getExchange(self, name):
- return self._getBrokerObject(Exchange, name)
+ return self._getBrokerObject(Exchange, "org.apache.qpid.broker:exchange:%s" % name)
def getAllQueues(self):
return self._getAllBrokerObjects(Queue)
def getQueue(self, name):
- return self._getBrokerObject(Queue, name)
+ return self._getBrokerObject(Queue, "org.apache.qpid.broker:queue:%s" % name)
def getAllBindings(self):
return self._getAllBrokerObjects(Binding)
@@ -277,9 +276,9 @@ class BrokerAgent(object):
"""Delete an object of the specified type"""
pass
- def query(self, _type, name):
+ def query(self, _type, oid):
"""Query the current state of an object"""
- return self._getBrokerObject(self, _type, name)
+ return self._getBrokerObject(self, _type, oid)
class BrokerObject(object):
@@ -302,6 +301,9 @@ class BrokerObject(object):
return full_name[colon+1:]
return value
+ def getObjectId(self):
+ return self.content['_object_id']['_object_name']
+
def getAttributes(self):
return self.values
@@ -318,7 +320,7 @@ class BrokerObject(object):
"""
Reload the property values from the agent.
"""
- refreshed = self.broker._getBrokerObject(self.__class__, self.name)
+ refreshed = self.broker._getBrokerObject(self.__class__, self.getObjectId())
if refreshed:
self.content = refreshed.content
self.values = self.content['_values']