From 35acd5912ff9478b18c0466fac1184fa3cd6600a Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Wed, 13 Mar 2013 13:34:19 -0700 Subject: [PATCH] Fix swift-ring-builder's list_parts command. I broke it in 7548cb9 when a ring's replica count changed from an int to a float. Change-Id: I49fa7e2961a09daad0c96e19cf1e39fec248d998 --- bin/swift-ring-builder | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/swift-ring-builder b/bin/swift-ring-builder index 16859924f5..e50ed62eeb 100755 --- a/bin/swift-ring-builder +++ b/bin/swift-ring-builder @@ -18,6 +18,7 @@ import cPickle as pickle from array import array from errno import EEXIST from itertools import islice, izip +from math import ceil from os import mkdir from os.path import basename, abspath, dirname, exists, join as pathjoin from sys import argv, exit @@ -167,16 +168,17 @@ swift-ring-builder list_parts [] .. print 'No matching devices found' exit(EXIT_ERROR) devs = [d['id'] for d in devs] - matches = [array('i') for x in xrange(builder.replicas)] + max_replicas = int(ceil(builder.replicas)) + matches = [array('i') for x in xrange(max_replicas)] for part in xrange(builder.parts): count = len([d for d in builder.get_part_devices(part) if d['id'] in devs]) if count: - matches[builder.replicas - count].append(part) + matches[max_replicas - count].append(part) print 'Partition Matches' for index, parts in enumerate(matches): for part in parts: - print '%9d %7d' % (part, builder.replicas - index) + print '%9d %7d' % (part, max_replicas - index) exit(EXIT_SUCCESS) def add():