qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r699148 - in /incubator/qpid/trunk/qpid/python: commands/qpid-config commands/qpid-route qpid/qmfconsole.py tests_0-10/management.py
Date Fri, 26 Sep 2008 01:34:52 GMT
Author: tross
Date: Thu Sep 25 18:34:52 2008
New Revision: 699148

URL: http://svn.apache.org/viewvc?rev=699148&view=rev
Log:
Added property-selector to the console getObjects function

Modified:
    incubator/qpid/trunk/qpid/python/commands/qpid-config
    incubator/qpid/trunk/qpid/python/commands/qpid-route
    incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py
    incubator/qpid/trunk/qpid/python/tests_0-10/management.py

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-config
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-config?rev=699148&r1=699147&r2=699148&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-config (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-config Thu Sep 25 18:34:52 2008
@@ -82,8 +82,8 @@
         self.qmf.delBroker(self.broker)
 
     def Overview (self):
-        exchanges = self.qmf.getObjects(name="exchange")
-        queues    = self.qmf.getObjects(name="queue")
+        exchanges = self.qmf.getObjects(cls="exchange")
+        queues    = self.qmf.getObjects(cls="queue")
         print "Total Exchanges: %d" % len (exchanges)
         etype = {}
         for ex in exchanges:
@@ -104,7 +104,7 @@
         print "    non-durable: %d" % (len (queues) - _durable)
 
     def ExchangeList (self, filter):
-        exchanges = self.qmf.getObjects(name="exchange")
+        exchanges = self.qmf.getObjects(cls="exchange")
         print "Durable   Type      Bindings  Exchange Name"
         print "======================================================="
         for ex in exchanges:
@@ -112,9 +112,9 @@
                 print "%4c      %-10s%5d     %s" % (YN (ex.durable), ex.type, ex.bindingCount,
ex.name)
 
     def ExchangeListRecurse (self, filter):
-        exchanges = self.qmf.getObjects(name="exchange")
-        bindings  = self.qmf.getObjects(name="binding")
-        queues    = self.qmf.getObjects(name="queue")
+        exchanges = self.qmf.getObjects(cls="exchange")
+        bindings  = self.qmf.getObjects(cls="binding")
+        queues    = self.qmf.getObjects(cls="queue")
         for ex in exchanges:
             if self.match (ex.name, filter):
                 print "Exchange '%s' (%s)" % (ex.name, ex.type)
@@ -128,8 +128,8 @@
             
 
     def QueueList (self, filter):
-        queues   = self.qmf.getObjects(name="queue")
-        journals = self.qmf.getObjects(name="journal")
+        queues   = self.qmf.getObjects(cls="queue")
+        journals = self.qmf.getObjects(cls="journal")
         print "                                      Store Size"
         print "Durable  AutoDel  Excl  Bindings  (files x file pages)  Queue Name"
         print "==========================================================================================="
@@ -149,9 +149,9 @@
                              YN (q.exclusive), q.bindingCount, q.name)
 
     def QueueListRecurse (self, filter):
-        exchanges = self.qmf.getObjects(name="exchange")
-        bindings  = self.qmf.getObjects(name="binding")
-        queues    = self.qmf.getObjects(name="queue")
+        exchanges = self.qmf.getObjects(cls="exchange")
+        bindings  = self.qmf.getObjects(cls="binding")
+        queues    = self.qmf.getObjects(cls="queue")
         for queue in queues:
             if self.match (queue.name, filter):
                 print "Queue '%s'" % queue.name

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-route
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-route?rev=699148&r1=699147&r2=699148&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-route (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-route Thu Sep 25 18:34:52 2008
@@ -62,7 +62,7 @@
         self.qmf.delBroker(self.broker)
 
     def getLink (self):
-        links = self.qmf.getObjects(name="link")
+        links = self.qmf.getObjects(cls="link")
         for link in links:
             if "%s:%d" % (link.host, link.port) == self.src.name ():
                 return link
@@ -74,7 +74,7 @@
             print "Linking broker to itself is not permitted"
             sys.exit(1)
 
-        brokers = self.qmf.getObjects(name="broker")
+        brokers = self.qmf.getObjects(cls="broker")
         broker = brokers[0]
         link = self.getLink()
         if link != None:
@@ -92,7 +92,7 @@
 
     def DelLink (self, srcBroker):
         self.src = qmfconsole.BrokerURL(srcBroker)
-        brokers = self.qmf.getObjects(name="broker")
+        brokers = self.qmf.getObjects(cls="broker")
         broker = brokers[0]
         link = self.getLink()
         if link == None:
@@ -103,7 +103,7 @@
             print "Close method returned:", res.status, res.text
 
     def ListLinks (self):
-        links = self.qmf.getObjects(name="link")
+        links = self.qmf.getObjects(cls="link")
         if len(links) == 0:
             print "No Links Found"
         else:
@@ -119,7 +119,7 @@
         if self.dest.name() == self.src.name():
             raise Exception("Linking broker to itself is not permitted")
 
-        brokers = self.qmf.getObjects(name="broker")
+        brokers = self.qmf.getObjects(cls="broker")
         broker = brokers[0]
 
         link = self.getLink()
@@ -140,7 +140,7 @@
         if link == None:
             raise Exception("Protocol Error - Missing link ID")
 
-        bridges = self.qmf.getObjects(name="bridge")
+        bridges = self.qmf.getObjects(cls="bridge")
         for bridge in bridges:
             if bridge.linkRef == link.getObjectId() and \
                     bridge.dest == exchange and bridge.key == routingKey:
@@ -164,7 +164,7 @@
                 raise Exception("No link found from %s to %s" % (self.src.name(), self.dest.name()))
             sys.exit (0)
 
-        bridges = self.qmf.getObjects(name="bridge")
+        bridges = self.qmf.getObjects(cls="bridge")
         for bridge in bridges:
             if bridge.linkRef == link.getObjectId() and bridge.dest == exchange and bridge.key
== routingKey:
                 if _verbose:
@@ -186,8 +186,8 @@
             raise Exception("Route not found")
 
     def ListRoutes (self):
-        links   = self.qmf.getObjects(name="link")
-        bridges = self.qmf.getObjects(name="bridge")
+        links   = self.qmf.getObjects(cls="link")
+        bridges = self.qmf.getObjects(cls="bridge")
 
         for bridge in bridges:
             myLink = None
@@ -199,8 +199,8 @@
                 print "%s %s:%d %s %s" % (self.dest.name(), myLink.host, myLink.port, bridge.dest,
bridge.key)
 
     def ClearAllRoutes (self):
-        links   = self.qmf.getObjects(name="link")
-        bridges = self.qmf.getObjects(name="bridge")
+        links   = self.qmf.getObjects(cls="link")
+        bridges = self.qmf.getObjects(cls="bridge")
 
         for bridge in bridges:
             if _verbose:
@@ -218,7 +218,7 @@
                 print "Ok"
 
         if _dellink:
-            links = self.qmf.getObjects(name="link")
+            links = self.qmf.getObjects(cls="link")
             for link in links:
                 if _verbose:
                     print "Deleting Link: %s:%d... " % (link.host, link.port),

Modified: incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py?rev=699148&r1=699147&r2=699148&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py Thu Sep 25 18:34:52 2008
@@ -139,6 +139,7 @@
     self.cv                = Condition()
     self.syncSequenceList  = []
     self.getResult         = []
+    self.getSelect         = []
     self.error             = None
     self.bindingKeyList    = self._bindingKeys(rcvObjects, rcvEvents, rcvHeartbeats)
     self.manageConnections = manageConnections
@@ -157,7 +158,7 @@
       raise Exception(broker.error)
 
     self.brokers.append(broker)
-    self.getObjects(broker=broker, name="agent")
+    self.getObjects(broker=broker, cls="agent")
     return broker
 
   def delBroker(self, broker):
@@ -220,7 +221,7 @@
 
     schema = <schema> - supply a schema object returned from getSchema
     key = <key>       - supply a classKey from the list returned by getClasses
-    name = <name>     - supply a class name as a string
+    cls = <name>      - supply a class name as a string
 
     If objects should be obtained from only one agent, use the following argument.
     Otherwise, the query will go to all agents.
@@ -231,6 +232,10 @@
     add the following argument:
 
     broker = <broker> - supply a broker as returned by addBroker
+
+    If additional arguments are supplied, they are used as property selectors.  For example,
+    if the argument name="test" is supplied, only objects whose "name" property is "test"
+    will be returned in the result.
     """
     if "broker" in kwargs:
       brokerList = []
@@ -254,14 +259,19 @@
     cname = None
     if   "schema" in kwargs: pname, cname, hash = kwargs["schema"].getKey()
     elif "key"    in kwargs: pname, cname, hash = kwargs["key"]
-    elif "name"   in kwargs: pname, cname, hash = None, kwargs["name"], None
+    elif "cls"    in kwargs: pname, cname, hash = None, kwargs["cls"], None
     if cname == None:
-      raise Exception("No class supplied, use 'schema', 'key', or 'name' argument")
+      raise Exception("No class supplied, use 'schema', 'key', or 'cls' argument")
     map = {}
     map["_class"] = cname
     if pname != None: map["_package"] = pname
     if hash  != None: map["_hash"]    = hash
 
+    self.getSelect = []
+    for item in kwargs:
+      if item != "schema" and item != "key" and item != "cls":
+        self.getSelect.append((item, kwargs[item]))
+
     self.getResult = []
     for agent in agentList:
       broker = agent.broker
@@ -453,7 +463,7 @@
 
     self.cv.acquire()
     if seq in self.syncSequenceList:
-      if object.getTimestamps()[2] == 0:
+      if object.getTimestamps()[2] == 0 and self._selectMatch(object):
         self.getResult.append(object)
       self.cv.release()
       return
@@ -471,6 +481,14 @@
     self.syncSequenceList = []
     self.cv.notify()
     self.cv.release()
+
+  def _selectMatch(self, object):
+    """ Check the object against self.getSelect to check for a match """
+    for key, value in self.getSelect:
+      for prop, propval in object.properties:
+        if key == prop.name and value != propval:
+          return False
+    return True
   
   def _decodeValue(self, codec, typecode):
     """ Decode, from the codec, a value based on its typecode. """

Modified: incubator/qpid/trunk/qpid/python/tests_0-10/management.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests_0-10/management.py?rev=699148&r1=699147&r2=699148&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests_0-10/management.py (original)
+++ incubator/qpid/trunk/qpid/python/tests_0-10/management.py Thu Sep 25 18:34:52 2008
@@ -59,7 +59,7 @@
         session = self.session
         self.startQmf()
  
-        brokers = self.qmf.getObjects(name="broker")
+        brokers = self.qmf.getObjects(cls="broker")
         self.assertEqual (len(brokers), 1)
         broker = brokers[0]
 
@@ -147,54 +147,44 @@
         session.queue_declare(queue="dest-queue", exclusive=True, auto_delete=True)
         session.exchange_bind(queue="dest-queue", exchange="amq.direct")
 
-        queues = self.qmf.getObjects(name="queue")
+        queues = self.qmf.getObjects(cls="queue")
 
         "Move 10 messages from src-queue to dest-queue"
-        result = self.qmf.getObjects(name="broker")[0].queueMoveMessages("src-queue", "dest-queue",
10)
+        result = self.qmf.getObjects(cls="broker")[0].queueMoveMessages("src-queue", "dest-queue",
10)
         self.assertEqual (result.status, 0) 
 
-        queues = self.qmf.getObjects(name="queue")
-        for q in queues:
-            if q.name == "src-queue":
-               sq = q 
-            elif q.name == "dest-queue":
-               dq = q 
+        sq = self.qmf.getObjects(cls="queue", name="src-queue")[0]
+        dq = self.qmf.getObjects(cls="queue", name="dest-queue")[0]
 
         self.assertEqual (sq.msgDepth,10)
         self.assertEqual (dq.msgDepth,10)
 
         "Move all remaining messages to destination"
-        result = self.qmf.getObjects(name="broker")[0].queueMoveMessages("src-queue", "dest-queue",
0)
+        result = self.qmf.getObjects(cls="broker")[0].queueMoveMessages("src-queue", "dest-queue",
0)
         self.assertEqual (result.status,0)
 
-        queues = self.qmf.getObjects(name="queue")
-        for q in queues:
-            if q.name == "src-queue":
-               sq = q 
-            elif q.name == "dest-queue":
-               dq = q 
+        sq = self.qmf.getObjects(cls="queue", name="src-queue")[0]
+        dq = self.qmf.getObjects(cls="queue", name="dest-queue")[0]
+
         self.assertEqual (sq.msgDepth,0)
         self.assertEqual (dq.msgDepth,20)
 
         "Use a bad source queue name"
-        result = self.qmf.getObjects(name="broker")[0].queueMoveMessages("bad-src-queue",
"dest-queue", 0)
+        result = self.qmf.getObjects(cls="broker")[0].queueMoveMessages("bad-src-queue",
"dest-queue", 0)
         self.assertEqual (result.status,4)
 
         "Use a bad destination queue name"
-        result = self.qmf.getObjects(name="broker")[0].queueMoveMessages("src-queue", "bad-dest-queue",
0)
+        result = self.qmf.getObjects(cls="broker")[0].queueMoveMessages("src-queue", "bad-dest-queue",
0)
         self.assertEqual (result.status,4)
 
         " Use a large qty (40) to move from dest-queue back to "
         " src-queue- should move all "
-        result = self.qmf.getObjects(name="broker")[0].queueMoveMessages("dest-queue", "src-queue",
40)
+        result = self.qmf.getObjects(cls="broker")[0].queueMoveMessages("dest-queue", "src-queue",
40)
         self.assertEqual (result.status,0)
 
-        queues = self.qmf.getObjects(name="queue")
-        for q in queues:
-            if q.name == "src-queue":
-               sq = q 
-            elif q.name == "dest-queue":
-               dq = q 
+        sq = self.qmf.getObjects(cls="queue", name="src-queue")[0]
+        dq = self.qmf.getObjects(cls="queue", name="dest-queue")[0]
+
         self.assertEqual (sq.msgDepth,20)
         self.assertEqual (dq.msgDepth,0)
 
@@ -226,35 +216,23 @@
             msg = Message(props, body)
             session.message_transfer(destination="amq.direct", message=msg)
 
-        queues = self.qmf.getObjects(name="queue")
-        for q in queues:
-            if q.name == "purge-queue":
-               pq = q 
+        pq = self.qmf.getObjects(cls="queue", name="purge-queue")[0]
 
         "Purge top message from purge-queue"
         result = pq.purge(1)
         self.assertEqual (result.status, 0) 
-        queues = self.qmf.getObjects(name="queue")
-        for q in queues:
-            if q.name == "purge-queue":
-               pq = q 
+        pq = self.qmf.getObjects(cls="queue", name="purge-queue")[0]
         self.assertEqual (pq.msgDepth,19)
 
         "Purge top 9 messages from purge-queue"
         result = pq.purge(9)
         self.assertEqual (result.status, 0) 
-        queues = self.qmf.getObjects(name="queue")
-        for q in queues:
-            if q.name == "purge-queue":
-               pq = q 
+        pq = self.qmf.getObjects(cls="queue", name="purge-queue")[0]
         self.assertEqual (pq.msgDepth,10)
 
         "Purge all messages from purge-queue"
         result = pq.purge(0)
         self.assertEqual (result.status, 0) 
-        queues = self.qmf.getObjects(name="queue")
-        for q in queues:
-            if q.name == "purge-queue":
-               pq = q 
+        pq = self.qmf.getObjects(cls="queue", name="purge-queue")[0]
         self.assertEqual (pq.msgDepth,0)
 



Mime
View raw message