Make swift-get-nodes -a
show all handoffs.
Commit 95786e5
made swift-get-nodes only output N handoff nodes, where
N is the ring's replica count. This change leaves that behavior in
place as the default, but adds the option -a/--all to print all the
handoff nodes.
This is handy if you're consuming the output with a script, e.g. if
you're doing some analysis of the distribution of primary+handoff
nodes for a particular set of things.
Change-Id: Ie0253575bb21ccf25559a1c5fd20570a58a2d9fa
This commit is contained in:
parent
cc73f5cbe0
commit
67af56b156
@ -14,6 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import optparse
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
@ -21,8 +22,13 @@ from swift.common.ring import Ring
|
||||
from swift.common.utils import hash_path
|
||||
|
||||
|
||||
if len(sys.argv) < 3 or len(sys.argv) > 5:
|
||||
print 'Usage: %s <ring.gz> <account> [<container>] [<object>]' \
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-a', '--all', action='store_true',
|
||||
help='Show all handoff nodes')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) < 2 or len(args) > 4:
|
||||
print 'Usage: %s [-a] <ring.gz> <account> [<container>] [<object>]' \
|
||||
% sys.argv[0]
|
||||
print 'Shows the nodes responsible for the item specified.'
|
||||
print 'Example:'
|
||||
@ -40,25 +46,25 @@ account = None
|
||||
container = None
|
||||
obj = None
|
||||
|
||||
if len(sys.argv) > 4:
|
||||
# Acount, Container and Object
|
||||
ring_file, account, container, obj = sys.argv[1:5]
|
||||
if len(args) == 4:
|
||||
# Account, Container and Object
|
||||
ring_file, account, container, obj = args
|
||||
ring = Ring(ring_file)
|
||||
hash_str = hash_path(account, container, obj)
|
||||
part, nodes = ring.get_nodes(account, container, obj)
|
||||
target = "%s/%s/%s" % (account, container, obj)
|
||||
loc = 'objects'
|
||||
elif len(sys.argv) > 3:
|
||||
elif len(args) == 3:
|
||||
# Account, Container
|
||||
ring_file, account, container = sys.argv[1:4]
|
||||
ring_file, account, container = args
|
||||
ring = Ring(ring_file)
|
||||
hash_str = hash_path(account, container)
|
||||
part, nodes = ring.get_nodes(account, container)
|
||||
target = "%s/%s" % (account, container)
|
||||
loc = 'containers'
|
||||
elif len(sys.argv) > 2:
|
||||
elif len(args) == 2:
|
||||
# Account
|
||||
ring_file, account = sys.argv[1:3]
|
||||
ring_file, account = args
|
||||
ring = Ring(ring_file)
|
||||
hash_str = hash_path(account)
|
||||
part, nodes = ring.get_nodes(account)
|
||||
@ -68,7 +74,7 @@ elif len(sys.argv) > 2:
|
||||
more_nodes = []
|
||||
for more_node in ring.get_more_nodes(part):
|
||||
more_nodes.append(more_node)
|
||||
if len(more_nodes) >= ring.replica_count:
|
||||
if not options.all and len(more_nodes) >= ring.replica_count:
|
||||
break
|
||||
|
||||
print '\nAccount \t%s' % account
|
||||
|
Loading…
Reference in New Issue
Block a user