This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- rabbitctl_service.py is now more full featured, including introspec…
…tion of all queues and exchanges. Responses now have a more standard format. - webui.py more cleanup up, generalized. Now returns json. - add several examples of twotp usage in examples dir.
- Loading branch information
1 parent
69fe44b
commit 36db426
Showing
7 changed files
with
306 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) 2007-2009 Thomas Herve <therve@free.fr>. | ||
# See LICENSE for details. | ||
|
||
""" | ||
Example emulating rabbitmqctl | ||
""" | ||
|
||
from twisted.internet import reactor | ||
|
||
from twotp import Process, readCookie, buildNodeName | ||
from twotp.term import Binary, Atom | ||
|
||
|
||
def add_user(process, username, password): | ||
def cb(resp): | ||
print resp | ||
reactor.stop() | ||
def eb(error): | ||
print "Got error", error | ||
reactor.stop() | ||
un, pw = Binary(username), Binary(password) | ||
process.callRemote("rabbit", "rabbit_access_control", "add_user", un, pw).addCallback(cb).addErrback(eb) | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
if len(sys.argv) != 4: | ||
print "USAGE: ./add_user.py COOKIE username password" | ||
sys.exit(1) | ||
cookie = sys.argv[1] #cookie = readCookie() | ||
username = sys.argv[2] | ||
password = sys.argv[3] | ||
nodeName = buildNodeName("twotp-rabbit") | ||
process = Process(nodeName, cookie) | ||
reactor.callWhenRunning(add_user, process, username, password) | ||
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Get RabbitMQ exchange info. | ||
""" | ||
|
||
from twisted.internet import reactor | ||
|
||
from twotp import Process, readCookie, buildNodeName | ||
from twotp.term import Binary, Atom | ||
|
||
|
||
items = ["name", "type", "durable", "auto_delete", "arguments"] | ||
INFO_ARGS = [Atom(item) for item in items] | ||
VHOST = Binary("/") | ||
|
||
def exchange_info(process): | ||
|
||
def cb(resp): | ||
#print resp | ||
for info in _exchange_info(resp): | ||
print "\n", info, "\n" | ||
reactor.stop() | ||
|
||
def _exchange_info(resp): | ||
allinfo = [] | ||
for v in resp: | ||
# [(exch1, infodict1), (exch2, infodict2), ...] | ||
allinfo.append((v[0][1][3].value, | ||
{"name":v[0][1][3].value, | ||
"type":v[1][1].text, | ||
"durable":v[2][1].text == "true", | ||
"auto_delete":v[3][1].text == "true", | ||
"arguments":v[4][1]})) | ||
return allinfo | ||
|
||
|
||
def eb(error): | ||
print "Got error", error | ||
reactor.stop() | ||
|
||
process.callRemote("rabbit", "rabbit_exchange", "info_all", VHOST, INFO_ARGS).addCallback(cb).addErrback(eb) | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
cookie = sys.argv[1] #cookie = readCookie() | ||
nodeName = buildNodeName("twotp-rabbit") | ||
process = Process(nodeName, cookie) | ||
reactor.callWhenRunning(exchange_info, process) | ||
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Get RabbitMQ queue info. | ||
""" | ||
|
||
from twisted.internet import reactor | ||
|
||
from twotp import Process, readCookie, buildNodeName | ||
from twotp.term import Binary, Atom | ||
|
||
|
||
items = ["name", "durable", "auto_delete", "arguments", "pid", | ||
"messages_ready", "messages_unacknowledged", | ||
"messages_uncommitted", "messages", "acks_uncommitted", | ||
"consumers", "transactions", "memory"] | ||
INFO_ARGS = [Atom(item) for item in items] | ||
VHOST = Binary("/") | ||
|
||
def queue_info(process): | ||
|
||
def cb(resp): | ||
#print resp | ||
for info in _queue_info(resp): | ||
print "\n", info, "\n" | ||
reactor.stop() | ||
|
||
def _queue_info(resp): | ||
allinfo = [] | ||
for queue in resp: | ||
# [(qname1, infodict1), (qname2, infodict2), ...] | ||
allinfo.append((queue[0][1][3].value, | ||
{"name":queue[0][1][3].value, | ||
"durable":queue[1][1].text == "true", | ||
"auto_delete":queue[2][1].text == "true", | ||
"arguments":queue[3][1], | ||
"pid":queue[4][1].nodeName.text, | ||
"messages_ready":queue[5][1], | ||
"messages_unacknowledged":queue[6][1], | ||
"messages_uncommitted":queue[7][1], | ||
"messages":queue[8][1], | ||
"acks_uncommitted":queue[9][1], | ||
"memory":queue[10][1], | ||
"transactions":queue[11][1], | ||
"memory":queue[12][1]})) | ||
return allinfo | ||
|
||
|
||
def eb(error): | ||
print "Got error", error | ||
reactor.stop() | ||
|
||
process.callRemote("rabbit", "rabbit_amqqueue", "info_all", VHOST, INFO_ARGS).addCallback(cb).addErrback(eb) | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
cookie = sys.argv[1] #cookie = readCookie() | ||
nodeName = buildNodeName("twotp-rabbit") | ||
process = Process(nodeName, cookie) | ||
reactor.callWhenRunning(queue_info, process) | ||
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.