Created
June 25, 2020 16:30
-
-
Save clayg/41eb5bd149e9dd75ed5a666cdf4a48e0 to your computer and use it in GitHub Desktop.
Make a no replication ring if you need it
This file contains hidden or 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 | |
| from argparse import ArgumentParser | |
| import sys | |
| import os | |
| from swift.common.ring import RingData | |
| parser = ArgumentParser() | |
| parser.add_argument('ring', help='path to a ring') | |
| parser.add_argument('--output', default=None, help='override output path') | |
| def main(): | |
| args = parser.parse_args() | |
| r = RingData.load(args.ring) | |
| for dev in r.devs: | |
| if not dev: | |
| continue | |
| dev['replication_ip'] = dev['ip'] | |
| dev['replication_port'] = dev['port'] | |
| if not args.output: | |
| path_part, filename = os.path.split(args.ring) | |
| name, ext = filename.split('.', 1) | |
| name += '-no-replication' | |
| newname = '%s.%s' % (name, ext) | |
| args.output = os.path.join(path_part, newname) | |
| r.save(args.output) | |
| print('wrote: %s' % args.output) | |
| if __name__ == "__main__": | |
| sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment