Last active
September 21, 2016 07:42
-
-
Save clayg/035dc3b722b7f89cce66520dde285c9a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import sys | |
from argparse import ArgumentParser | |
from swift.common.direct_client import direct_get_suffix_hashes | |
from swift.common.storage_policy import POLICIES | |
parser = ArgumentParser() | |
parser.add_argument('--policy-index', default=0, help='policy index') | |
parser.add_argument('part', help='the part') | |
parser.add_argument('-s', '--suffix', nargs='*', | |
help='any suffixes to recalculate') | |
parser.add_argument('-d', '--device', help='limit command to single node') | |
def main(): | |
args = parser.parse_args() | |
policy = POLICIES[args.policy_index] | |
policy.load_ring('/etc/swift/') | |
ring = policy.object_ring | |
suffixes = args.suffix or [] | |
for node in ring.devs: | |
if node is None: | |
continue | |
if args.device and node['device'] != args.device: | |
continue | |
data = direct_get_suffix_hashes( | |
node, args.part, suffixes, headers={ | |
'x-backend-storage-policy-index': int(policy)}) | |
print node['ip'], node['port'], node['device'] | |
print data | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment