Skip to content

Instantly share code, notes, and snippets.

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 clayg/93bcc37ec4f5fc7ab028f07ac4305148 to your computer and use it in GitHub Desktop.
Save clayg/93bcc37ec4f5fc7ab028f07ac4305148 to your computer and use it in GitHub Desktop.
$ swift-ring-builder test.builder add r1z1-127.0.0.1:6000/sdb_555 1.0
$ swift-ring-builder test.builder
test.builder, build version 2
16 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 0 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file test.ring.gz is up-to-date
Devices: id region zone ip address port replication ip replication port name weight partitions balance flags meta
0 1 1 127.0.0.1 6000 127.0.0.1 6000 sdb 1.00 16 0.00 555
[object-replicator]
rsync_module = {replication_ip}:{meta}:object
#!/usr/bin/env python
import sys
from swift.common.ring import Ring
from swift.common.utils import readconf, rsync_module_interpolation
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('--ring', default='/etc/swift/object.ring.gz',
help='the path to the ring')
parser.add_argument('--config', default='/etc/swift/object-server/1.conf.d',
help='the path to the config')
def main():
args = parser.parse_args()
r = Ring(args.ring)
for dev in r.devs:
if dev is None:
continue
break
conf = readconf(args.config, 'object-replicator')
template = conf.get('rsync_module', '{replication_ip}::object')
print rsync_module_interpolation(template, dev)
if __name__ == "__main__":
sys.exit(main())
$./test_rsync_module.py --ring test.ring.gz --config test.conf
127.0.0.1:555:object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment