-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathc-foreach-nt
executable file
·36 lines (25 loc) · 989 Bytes
/
c-foreach-nt
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
#!/usr/bin/python
import logging
import sys
sys.path.append("/usr/share/cassandra-tools-wmf")
from cassandra.tools import get_instances
from cassandra.tools.config import LOG_LEVEL
from cassandra.tools.nodetool import NodetoolOutputWriter
from cassandra.tools.output import MAGENTA, CYAN
logging.basicConfig(level=LOG_LEVEL)
def main(args):
for (i, instance) in enumerate(get_instances()):
color = MAGENTA if (i % 2) == 0 else CYAN
instance.nodetool.run(*args, output=NodetoolOutputWriter(color, False, instance.name))
def usage(out):
print >>out, "Usage: {} <ARG> [ARG ...]\n".format(sys.argv[0])
print >>out, "Execute nodetool on each local Cassandra instance.\n"
print >>out, "Positional arguments:"
print >>out, " ARG Arguments to pass to nodetool\n"
def get_args():
if len(sys.argv[1:]) < 1:
usage(sys.stderr)
sys.exit(1)
return sys.argv[1:]
if __name__ == "__main__":
main(get_args())