diff options
| author | Ted Ross <tross@apache.org> | 2008-07-31 13:15:16 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2008-07-31 13:15:16 +0000 |
| commit | 12b33f499c8a33d5010fedecdb267c721483f0a5 (patch) | |
| tree | 0c60fb8918c0ca3ac2ca8cf020c9fa8f4c796022 /qpid/python | |
| parent | 5ec77e5be4feca03b2c13866286a6bec911ab4fc (diff) | |
| download | qpid-python-12b33f499c8a33d5010fedecdb267c721483f0a5.tar.gz | |
QPID-1174 - Management updates for remote agents
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@681362 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
| -rwxr-xr-x | qpid/python/commands/qpid-tool | 4 | ||||
| -rw-r--r-- | qpid/python/qpid/management.py | 15 | ||||
| -rw-r--r-- | qpid/python/qpid/managementdata.py | 92 |
3 files changed, 87 insertions, 24 deletions
diff --git a/qpid/python/commands/qpid-tool b/qpid/python/commands/qpid-tool index 0ab47a01e7..7301dad6e4 100755 --- a/qpid/python/commands/qpid-tool +++ b/qpid/python/commands/qpid-tool @@ -65,6 +65,7 @@ class Mcli (Cmd): print " schema <className> - Print details of an object class" print " set time-format short - Select short timestamp format (default)" print " set time-format long - Select long timestamp format" + print " id [<ID>] - Display translations of display object ids" print " quit or ^D - Exit the program" print @@ -93,6 +94,9 @@ class Mcli (Cmd): except: pass + def do_id (self, data): + self.dataObject.do_id(data) + def complete_schema (self, text, line, begidx, endidx): tokens = split (line) if len (tokens) > 2: diff --git a/qpid/python/qpid/management.py b/qpid/python/qpid/management.py index 55479de0e6..1059c70ada 100644 --- a/qpid/python/qpid/management.py +++ b/qpid/python/qpid/management.py @@ -154,7 +154,7 @@ class managementChannel: def accept (self, msg): self.qpidChannel.message_accept(RangedSet(msg.id)) - def message (self, body, routing_key="agent"): + def message (self, body, routing_key="broker"): dp = self.qpidChannel.delivery_properties() dp.routing_key = routing_key mp = self.qpidChannel.message_properties() @@ -227,14 +227,14 @@ class managementClient: """ Invoke a method on a managed object. """ self.method (channel, userSequence, objId, className, methodName, args) - def getObjects (self, channel, userSequence, className): + def getObjects (self, channel, userSequence, className, bank=0): """ Request immediate content from broker """ codec = Codec (self.spec) self.setHeader (codec, ord ('G'), userSequence) ft = {} ft["_class"] = className codec.write_map (ft) - msg = channel.message(codec.encoded) + msg = channel.message(codec.encoded, routing_key="agent.%d" % bank) channel.send ("qpid.management", msg) def syncWaitForStable (self, channel): @@ -273,14 +273,14 @@ class managementClient: self.cv.release () return result - def syncGetObjects (self, channel, className): + def syncGetObjects (self, channel, className, bank=0): """ Synchronous (blocking) get call """ self.cv.acquire () self.syncInFlight = True self.syncResult = [] self.syncSequence = self.seqMgr.reserve ("sync") self.cv.release () - self.getObjects (channel, self.syncSequence, className) + self.getObjects (channel, self.syncSequence, className, bank) self.cv.acquire () starttime = time () while self.syncInFlight: @@ -748,6 +748,8 @@ class managementClient: sequence = self.seqMgr.reserve ((userSequence, classId, methodName)) self.setHeader (codec, ord ('M'), sequence) codec.write_uint64 (objId) # ID of object + codec.write_str8 (methodName) + bank = (objId & 0x0000FFFFFF000000) >> 24 # Encode args according to schema if classId not in self.schema: @@ -777,6 +779,5 @@ class managementClient: packageName = classId[0] className = classId[1] - msg = channel.message(codec.encoded, "agent.method." + packageName + "." + \ - className + "." + methodName) + msg = channel.message(codec.encoded, "agent." + str(bank)) channel.send ("qpid.management", msg) diff --git a/qpid/python/qpid/managementdata.py b/qpid/python/qpid/managementdata.py index 4c34b514d4..f6ebf4a381 100644 --- a/qpid/python/qpid/managementdata.py +++ b/qpid/python/qpid/managementdata.py @@ -167,10 +167,14 @@ class ManagementData: if self.cli != None: self.cli.setPromptMessage ("Broker Disconnected") - def schemaHandler (self, context, className, configs, insts, methods, events): + def schemaHandler (self, context, classKey, configs, insts, methods, events): """ Callback for schema updates """ - if className not in self.schema: - self.schema[className] = (configs, insts, methods, events) + if classKey not in self.schema: + schemaRev = 0 + for key in self.schema: + if classKey[0] == key[0] and classKey[1] == key[1]: + schemaRev += 1 + self.schema[classKey] = (configs, insts, methods, events, schemaRev) def setCli (self, cliobj): self.cli = cliobj @@ -248,17 +252,17 @@ class ManagementData: return str (value) return "*type-error*" - def getObjIndex (self, className, config): + def getObjIndex (self, classKey, config): """ Concatenate the values from index columns to form a unique object name """ result = "" - schemaConfig = self.schema[className][0] + schemaConfig = self.schema[classKey][0] for item in schemaConfig: if item[5] == 1 and item[0] != "id": if result != "": result = result + "." for key,val in config: if key == item[0]: - result = result + self.valueDisplay (className, key, val) + result = result + self.valueDisplay (classKey, key, val) return result def getClassKey (self, className): @@ -268,11 +272,17 @@ class ManagementData: if key[1] == className: return key else: - package = className[0:dotPos] - name = className[dotPos + 1:] + package = className[0:dotPos] + name = className[dotPos + 1:] + schemaRev = 0 + delim = name.find(".") + if delim != -1: + schemaRev = int(name[delim + 1:]) + name = name[0:delim] for key in self.schema: if key[0] == package and key[1] == name: - return key + if self.schema[key][4] == schemaRev: + return key return None def classCompletions (self, prefix): @@ -508,7 +518,11 @@ class ManagementData: sorted.sort () for classKey in sorted: tuple = self.schema[classKey] - className = classKey[0] + "." + classKey[1] + if tuple[4] == 0: + suffix = "" + else: + suffix = ".%d" % tuple[4] + className = classKey[0] + "." + classKey[1] + suffix row = (className, len (tuple[0]), len (tuple[1]), len (tuple[2]), len (tuple[3])) rows.append (row) self.disp.table ("Classes in Schema:", @@ -527,6 +541,7 @@ class ManagementData: raise ValueError () rows = [] + schemaRev = self.schema[classKey][4] for config in self.schema[classKey][0]: name = config[0] if name != "id": @@ -554,7 +569,7 @@ class ManagementData: rows.append ((name, typename, unit, "", "", desc)) titles = ("Element", "Type", "Unit", "Access", "Notes", "Description") - self.disp.table ("Schema for class '%s.%s':" % (classKey[0], classKey[1]), titles, rows) + self.disp.table ("Schema for class '%s.%s.%d':" % (classKey[0], classKey[1], schemaRev), titles, rows) for mname in self.schema[classKey][2]: (mdesc, args) = self.schema[classKey][2][mname] @@ -603,13 +618,20 @@ class ManagementData: raise ValueError () schemaMethod = self.schema[classKey][2][methodName] - if len (args) != len (schemaMethod[1]): - print "Wrong number of method args: Need %d, Got %d" % (len (schemaMethod[1]), len (args)) + count = 0 + for arg in range(len(schemaMethod[1])): + if schemaMethod[1][arg][2].find("I") != -1: + count += 1 + if len (args) != count: + print "Wrong number of method args: Need %d, Got %d" % (count, len (args)) raise ValueError () namedArgs = {} - for idx in range (len (args)): - namedArgs[schemaMethod[1][idx][0]] = args[idx] + idx = 0 + for arg in range(len(schemaMethod[1])): + if schemaMethod[1][arg][2].find("I") != -1: + namedArgs[schemaMethod[1][arg][0]] = args[idx] + idx += 1 self.methodSeq = self.methodSeq + 1 self.methodsPending[self.methodSeq] = methodName @@ -623,6 +645,35 @@ class ManagementData: # except ValueError, e: # print "Error invoking method:", e + def makeIdRow (self, displayId): + if displayId in self.idMap: + rawId = self.idMap[displayId] + else: + return None + return (displayId, + rawId, + (rawId & 0x7FFF000000000000) >> 48, + (rawId & 0x0000FFFFFF000000) >> 24, + (rawId & 0x0000000000FFFFFF)) + + def listIds (self, select): + rows = [] + if select == 0: + sorted = self.idMap.keys() + sorted.sort() + for displayId in sorted: + row = self.makeIdRow (displayId) + rows.append(row) + else: + row = self.makeIdRow (select) + if row == None: + print "Display Id %d not known" % select + return + rows.append(row) + self.disp.table("Translation of Display IDs:", + ("DisplayID", "RawID", "BootSequence", "Bank", "Object"), + rows) + def do_list (self, data): tokens = data.split () if len (tokens) == 0: @@ -644,10 +695,17 @@ class ManagementData: print "Not enough arguments supplied" return - userOid = long (tokens[0]) + displayId = long (tokens[0]) methodName = tokens[1] args = tokens[2:] - self.callMethod (userOid, methodName, args) + self.callMethod (displayId, methodName, args) + + def do_id (self, data): + if data == "": + select = 0 + else: + select = int(data) + self.listIds(select) def do_exit (self): self.mclient.removeChannel (self.mch) |
