You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/10/20 17:27:38 UTC

svn commit: r706320 - in /incubator/qpid/trunk/qpid/python: commands/qpid-route qpid/qmfconsole.py

Author: gsim
Date: Mon Oct 20 08:27:37 2008
New Revision: 706320

URL: http://svn.apache.org/viewvc?rev=706320&view=rev
Log:
Allow transport to be set on qpid-route.


Modified:
    incubator/qpid/trunk/qpid/python/commands/qpid-route
    incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py

Modified: incubator/qpid/trunk/qpid/python/commands/qpid-route
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-route?rev=706320&r1=706319&r2=706320&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-route (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-route Mon Oct 20 08:27:37 2008
@@ -40,6 +40,8 @@
     print "    -q [ --quiet ]           Quiet output, don't print duplicate warnings"
     print "    -d [ --durable ]         Added configuration shall be durable"
     print "    -e [ --del-empty-link ]  Delete link after deleting last route on the link"
+    print "    -t <transport> [ --transport <transport>]"
+    print "                             Specify transport to use for links, defaults to tcp"
     print
     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"
@@ -65,13 +67,13 @@
     def getLink (self):
         links = self.qmf.getObjects(_class="link")
         for link in links:
-            if "%s:%d" % (link.host, link.port) == self.src.name ():
+            if self.src.match(link.host, link.port):
                 return link
         return None
 
     def AddLink (self, srcBroker):
         self.src = qmfconsole.BrokerURL(srcBroker)
-        if self.dest.name() == self.src.name():
+        if self.dest.match(self.src.host, self.src.port):
             print "Linking broker to itself is not permitted"
             sys.exit(1)
 
@@ -118,7 +120,7 @@
 
     def AddRoute (self, srcBroker, exchange, routingKey, tag, excludes):
         self.src = qmfconsole.BrokerURL(srcBroker)
-        if self.dest.name() == self.src.name():
+        if self.dest.match(self.src.host, self.src.port):
             raise Exception("Linking broker to itself is not permitted")
 
         brokers = self.qmf.getObjects(_class="broker")
@@ -241,8 +243,8 @@
 ##
 
 try:
-    longOpts = ("verbose", "quiet", "durable", "del-empty-link")
-    (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], "vqde", longOpts)
+    longOpts = ("verbose", "quiet", "durable", "del-empty-link", "transport=")
+    (optlist, cargs) = getopt.gnu_getopt (sys.argv[1:], "vqdet:", longOpts)
 except:
     Usage ()
 
@@ -255,6 +257,8 @@
         _durable = True
     if opt[0] == "-e" or opt[0] == "--del-empty-link":
         _dellink = True
+    if opt[0] == "-t" or opt[0] == "--transport":
+        _transport = opt[1]
 
 nargs = len (cargs)
 if nargs < 2:
@@ -304,7 +308,7 @@
             else:
                 Usage ()
 except Exception,e:
-    print "Failed:", e.message
+    print "Failed:", e.args[0]
     sys.exit(1)
 
 rm.Disconnect ()

Modified: incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py?rev=706320&r1=706319&r2=706320&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/qmfconsole.py Mon Oct 20 08:27:37 2008
@@ -91,7 +91,8 @@
     if not match: raise ValueError("'%s' is not a valid broker url" % (text))
     user, password, host, port = match.groups()
 
-    self.host = socket.gethostbyname(host)
+    socket.gethostbyname(host)
+    self.host = host
     if port: self.port = int(port)
     else: self.port = 5672
     self.authName = user or "guest"
@@ -101,6 +102,9 @@
   def name(self):
     return self.host + ":" + str(self.port)
 
+  def match(self, host, port):
+    return socket.gethostbyname(self.host) == socket.gethostbyname(host) and self.port == port
+
 class Session:
   """
   An instance of the Session class represents a console session running
@@ -784,8 +788,8 @@
       self.first = first
       self.second = second
 
-  def __cmp__(self, other):
-    if other == None:
+  def __cmp__(self, other):    
+    if other == None or not isinstance(other, ObjectId) :
       return 1
     if self.first < other.first:
       return -1