This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrmm.py
66 lines (56 loc) · 1.55 KB
/
rmm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from json import loads
from sys import argv
from rabbit import Describe, Migrate
__author__ = "Vinicius Justino"
__version__ = "1.0.0"
__banner__ = '''
\t ____ __ __ __ __
\t| _ \| \/ | \/ |
\t| |_) | |\/| | |\/| |
\t| _ <| | | | | | |
\t|_| \_\_| |_|_| |_|
\tRabbitMQ Message Migrator author: Vinicius Justino | github: @Vdgonc | Twitter: @VdGonc\n
\tUsage:
\t\trmm.py -c config.json
'''
__help__ = '''
\tFlags:
\t\t-h or --help help for rmm
\t\t-c or --config Json path configuration
'''
if __name__ == '__main__':
if len(argv) > 1:
__option = argv[1]
if __option == '-h' or __option == '--help':
print(__banner__)
print(__help__)
pass
elif __option == '-c' or __option == '--config':
__file = argv[2]
print(__banner__)
with open(__file, 'r') as file:
configfile = loads(file.read())
consumer = configfile["consumer"]
publisher = configfile["publisher"]
server = configfile["server"]
migrator = Migrate(consumer=consumer, publisher=publisher)
describer = Describe(hostname=server["host"],
username=server["username"],
password=server["password"],
virtualhost=server["virtualhost"])
queues = describer.describe_queues()
if queues != []:
for queue in queues:
print(f'Migrating ...')
print(f'Queue: {queue["queue"]} exchange: {queue["exchange"]} routing key: {queue["rk"]}')
migrator.migrate(queue=queue)
print(f'Done!\n')
else:
print(f'No queues found!')
else:
print(__banner__)
print(__help__)
pass
else:
print(__banner__)
print(__help__)