Author: eallen
Date: 2012-12-19 19:46:58 +0000 (Wed, 19 Dec 2012)
New Revision: 5622
Modified:
trunk/cumin/python/cumin/session.py
Log:
Fix for bug found while fixing BZ 886937 - unable to remove routes.
Added special method to generate route keys
Modified: trunk/cumin/python/cumin/session.py
===================================================================
--- trunk/cumin/python/cumin/session.py 2012-12-19 19:41:03 UTC (rev 5621)
+++ trunk/cumin/python/cumin/session.py 2012-12-19 19:46:58 UTC (rev 5622)
@@ -83,23 +83,7 @@
if obj._qmf_object_id.isdigit():
# Translate v1 object ids
-
- if obj._class is self.app.model.org_apache_qpid_broker.Queue:
- # A very special workaround for queue keys
-
- key = obj.name
- elif obj._class is self.app.model.org_apache_qpid_broker.Link:
- # A very special workaround for link keys
- key = "qpid.%s:%s:%d" % (obj.transport, obj.host, obj.port)
- else:
- key_args = [str(getattr(obj, x.name))
- for x in obj._class._attributes
- if x.index and not x.references]
- key = ",".join(key_args)
-
- id_args = (obj._class._package._name, obj._class._name.lower(), key)
-
- object_id = ":".join(id_args)
+ object_id = self.gen_object_id(obj)
else:
object_id = obj._qmf_object_id
@@ -125,6 +109,40 @@
finally:
self.lock.release()
+ def gen_object_id(self, obj):
+ # special case objects are queue, link , and bridge
+ if obj._class in (self.app.model.org_apache_qpid_broker.Queue,
+ self.app.model.org_apache_qpid_broker.Link,
+ self.app.model.org_apache_qpid_broker.Bridge):
+ if obj._class is self.app.model.org_apache_qpid_broker.Queue:
+ key = obj.name
+ else:
+ if obj._class is self.app.model.org_apache_qpid_broker.Bridge:
+ # bridges need the link object_id as well as their own object_id
+ cls = self.app.model.org_apache_qpid_broker.Link
+ cursor = self.app.database.get_read_cursor()
+ link = cls.get_object(cursor, _id=obj._linkRef_id)
+ if not link:
+ raise Exception("Object '%s' is not a valid
bridge" % obj._id)
+ else:
+ link = obj
+ key = "qpid.%s:%s:%d" % (link.transport, link.host, link.port)
+
+ if obj._class is self.app.model.org_apache_qpid_broker.Bridge:
+
#org.apache.qpid.broker:bridge:org.apache.qpid.broker:link:qpid.tcp:localhost:5671,qpid.tcp:localhost:5671!amq.direct!amq.direct!r-key
+ key = "%s:%s:%s,%s!%s!%s!%s" % (link._class._package._name,
link._class._name.lower(),
+ key, key, obj.src, obj.dest,
obj.key)
+ else:
+ # other objects use the schema index fields
+ key_args = [str(getattr(obj, x.name))
+ for x in obj._class._attributes
+ if x.index and not x.references]
+ key = ",".join(key_args)
+
+ id_args = (obj._class._package._name, obj._class._name.lower(), key)
+ object_id = ":".join(id_args)
+ return object_id
+
def __repr__(self):
uris_without_password = [x[x.rfind("@")+1:] for x in
self.broker_uris]
return "%s(%s)" % (self.__class__.__name__, uris_without_password)
Show replies by date