Skip to content

Instantly share code, notes, and snippets.

@sougou
Created February 12, 2016 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sougou/a6826dd38e5c5bce5d48 to your computer and use it in GitHub Desktop.
Save sougou/a6826dd38e5c5bce5d48 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
"""This tool prints a list of all vttablets from vtctld.
This is meant to be used in conjucntion with vtexec.py.
Run vtlist.py and pipe it through grep filters to narrow down
the list of vttablets you want to identify. Once you're satisfied with the
list, pipe the final output to vtexec.py, which will execute the given
command on all vttablets of the list.
Example commands:
Run a command on all prod masters:
vtlist.py cell | grep master | grep -v test | vtexec.py '...'
Run a command on all replicas of a keyspace:
vtlist.py cell | grep keyspace| grep replica | vtexec.py '...'
"""
import argparse
import subprocess
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("cell")
args = parser.parse_args()
subprocess.check_call(["vtctl", "ListAllTablets", args.cell])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment