Skip to content

Instantly share code, notes, and snippets.

@bloodeagle40234
Created November 18, 2016 09:00
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 bloodeagle40234/e2ce7d55e140fdb88ff72a645cf7bcba to your computer and use it in GitHub Desktop.
Save bloodeagle40234/e2ce7d55e140fdb88ff72a645cf7bcba to your computer and use it in GitHub Desktop.
from swift.common import ring
from collections import defaultdict
if __name__ == '__main__':
rb = ring.RingBuilder(8, 3, 1)
for id, (region, zone) in enumerate(11 * [(0, 0), (1, 10), (1, 11)]):
rb.add_dev({'id': id, 'region': region, 'zone': zone, 'weight': 1,
'ip': '127.0.0.1', 'port': 10000 + region * 100 + zone,
'device': 'sda%d' % id})
rb.rebalance()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment