Merge lp:~letterj/swift/getnodewhh into lp:~hudson-openstack/swift/trunk

Proposed by Jay Payne
Status: Merged
Approved by: gholt
Approved revision: 73
Merged at revision: 76
Proposed branch: lp:~letterj/swift/getnodewhh
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 150 lines (+47/-91)
1 file modified
bin/swift-get-nodes (+47/-91)
To merge this branch: bzr merge lp:~letterj/swift/getnodewhh
Reviewer Review Type Date Requested Status
Chuck Thier (community) Approve
gholt (community) Approve
Review via email: mp+35624@code.launchpad.net

Commit message

swift-get-nodes cleanup

To post a comment you must log in.
Revision history for this message
gholt (gholt) wrote :

PEP8 Issues:

$ apt-get install pep8
$ pep8 bin/swift-get-nodes
bin/swift-get-nodes:25:3: E111 indentation is not a multiple of four
bin/swift-get-nodes:43:21: E701 multiple statements on one line (colon)
bin/swift-get-nodes:43:27: E231 missing whitespace after ','
bin/swift-get-nodes:69:68: W291 trailing whitespace

review: Needs Fixing
Revision history for this message
gholt (gholt) wrote :

Might want to add an option to specify how many handoff nodes to show and default it to 1 or something. Currently, if there are 100 zones you'll get over 300 lines of output.

Revision history for this message
gholt (gholt) wrote :

Bug on line 73 with references to node instead of mnode.

review: Needs Fixing
Revision history for this message
Jay Payne (letterj) wrote :

Fixed:
1. pep8 errors
2. error in setting the directory for the listing section. It was always object instead of the correct directory for type of request
3. Consolidated duplicate if logic [Made DRYer]

Will think about handoff default

Revision history for this message
gholt (gholt) wrote :

Looks good. The option to limit how many handoffs get emitted can be a future task; nobody we know has "too many" zones right now.

review: Approve
Revision history for this message
Chuck Thier (cthier) wrote :

Looks much better. Thanks J!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/swift-get-nodes'
2--- bin/swift-get-nodes 2010-09-14 06:51:20 +0000
3+++ bin/swift-get-nodes 2010-09-16 14:11:43 +0000
4@@ -40,99 +40,55 @@
5 container = None
6 obj = None
7
8-if len(sys.argv) > 4: ring,account,container,obj = sys.argv[1:5]
9-elif len(sys.argv) > 3: ring,account,container = sys.argv[1:4]
10-elif len(sys.argv) > 2: ring,account = sys.argv[1:3]
11+if len(sys.argv) > 4:
12+ # Acount, Container and Object
13+ ring, account, container, obj = sys.argv[1:5]
14+ hash_str = hash_path(account, container, obj)
15+ part, nodes = Ring(ring).get_nodes(account, container, obj)
16+ target = "%s/%s/%s" % (account, container, obj)
17+ loc = 'object'
18+elif len(sys.argv) > 3:
19+ # Account, Container
20+ ring, account, container = sys.argv[1:4]
21+ hash_str = hash_path(account, container)
22+ part, nodes = Ring(ring).get_nodes(account, container)
23+ target = "%s/%s" % (account, container)
24+ loc = 'container'
25+elif len(sys.argv) > 2:
26+ # Account
27+ ring, account = sys.argv[1:3]
28+ hash_str = hash_path(account)
29+ part, nodes = Ring(ring).get_nodes(account)
30+ target = "%s" % (account)
31+ loc = 'account'
32+
33+more_nodes = list(Ring(ring).get_more_nodes(part))
34
35 print '\nAccount \t%s' % account
36 print 'Container\t%s' % container
37 print 'Object \t%s\n' % obj
38+print '\nPartition\t%s' % part
39+print 'Hash \t%s\n' % hash_str
40
41-if obj:
42- hash_str = hash_path(account,container,obj)
43- part, nodes = Ring(ring).get_nodes(account,container,obj)
44- more_nodes = Ring(ring).get_more_nodes(part)
45- print '\nPartition\t%s' % part
46- print 'Hash \t%s\n' % hash_str
47- for node in nodes:
48- print 'Server:Port Device\t%s:%s %s' % (node['ip'], node['port'], node['device'])
49- for mnode in more_nodes:
50- print 'Server:Port Device\t%s:%s %s\t [Handoff]' \
51- % (node['ip'], node['port'], node['device'])
52- print "\n"
53- more_nodes = Ring(ring).get_more_nodes(part)
54- for node in nodes:
55- acct_cont_obj = "%s/%s/%s" % (account, container, obj)
56- print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
57- % (node['ip'],node['port'],node['device'],part,urllib.quote(acct_cont_obj))
58- for mnode in more_nodes:
59- acct_cont_obj = "%s/%s/%s" % (account, container, obj)
60- print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \
61- % (mnode['ip'],mnode['port'],mnode['device'],part,urllib.quote(acct_cont_obj))
62- print "\n"
63- more_nodes = Ring(ring).get_more_nodes(part)
64- for node in nodes:
65- print 'ssh %s "ls -lah /srv/node/%s/objects/%s/%s/%s/"' \
66- % (node['ip'],node['device'],part,hash_str[-3:],hash_str)
67- for mnode in more_nodes:
68- print 'ssh %s "ls -lah /srv/node/%s/objects/%s/%s/%s/" # [Handoff]' \
69- % (mnode['ip'],mnode['device'],part,hash_str[-3:],hash_str)
70-elif container:
71- hash_str = hash_path(account,container)
72- part, nodes = Ring(ring).get_nodes(account,container)
73- more_nodes = Ring(ring).get_more_nodes(part)
74- print '\nPartition %s' % part
75- print 'Hash %s\n' % hash_str
76- for node in nodes:
77- print 'Server:Port Device\t%s:%s %s' \
78- % (node['ip'], node['port'], node['device'])
79- for mnode in more_nodes:
80- print 'Server:Port Device\t%s:%s %s\t [Handoff]' \
81- % (mnode['ip'], mnode['port'], mnode['device'])
82- print "\n"
83- more_nodes = Ring(ring).get_more_nodes(part)
84- for node in nodes:
85- acct_cont = "%s/%s" % (account,container)
86- print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
87- % (node['ip'],node['port'],node['device'],part,urllib.quote(acct_cont))
88- for mnode in more_nodes:
89- acct_cont = "%s/%s" % (account,container)
90- print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \
91- % (mnode['ip'],mnode['port'],mnode['device'],part,urllib.quote(acct_cont))
92- print "\n"
93- more_nodes = Ring(ring).get_more_nodes(part)
94- for node in nodes:
95- print 'ssh %s "ls -lah /srv/node/%s/containers/%s/%s/%s/%s.db"' \
96- % (node['ip'],node['device'],part,hash_str[-3:],hash_str,hash_str)
97- for mnode in more_nodes:
98- print 'ssh %s "ls -lah /srv/node/%s/containers/%s/%s/%s/%s.db" # [Handoff]' \
99- % (mnode['ip'],mnode['device'],part,hash_str[-3:],hash_str,hash_str)
100-elif account:
101- hash_str = hash_path(account)
102- part, nodes = Ring(ring).get_nodes(account)
103- more_nodes = Ring(ring).get_more_nodes(part)
104- print '\nPartition %s' % part
105- print 'Hash %s\n' % hash_str
106- for node in nodes:
107- print 'Server:Port Device\t%s:%s %s' \
108- % (node['ip'], node['port'], node['device'])
109- for mnode in more_nodes:
110- print 'Server:Port Device\t%s:%s %s\t [Handoff]' \
111- % (mnode['ip'], mnode['port'], mnode['device'])
112- print "\n"
113- for node in nodes:
114- print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
115- % (node['ip'],node['port'],node['device'],part, urllib.quote(account))
116- more_nodes = Ring(ring).get_more_nodes(part)
117- for mnode in more_nodes:
118- print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \
119- % (mnode['ip'],mnode['port'],mnode['device'],part, urllib.quote(account))
120- print "\n"
121- for node in nodes:
122- print 'ssh %s "ls -lah /srv/node/%s/accounts/%s/%s/%s/%s.db"' \
123- % (node['ip'],node['device'],part,hash_str[-3:],hash_str,hash_str)
124- more_nodes = Ring(ring).get_more_nodes(part)
125- for mnode in more_nodes:
126- print 'ssh %s "ls -lah /srv/node/%s/accounts/%s/%s/%s/%s.db" # [Handoff]' \
127- % (mnode['ip'],mnode['device'],part,hash_str[-3:],hash_str,hash_str)
128- print "\n\n"
129+for node in nodes:
130+ print 'Server:Port Device\t%s:%s %s' % (node['ip'], node['port'],
131+ node['device'])
132+for mnode in more_nodes:
133+ print 'Server:Port Device\t%s:%s %s\t [Handoff]' \
134+ % (mnode['ip'], mnode['port'], mnode['device'])
135+print "\n"
136+for node in nodes:
137+ print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
138+ % (node['ip'], node['port'], node['device'], part,
139+ urllib.quote(target))
140+for mnode in more_nodes:
141+ print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \
142+ % (mnode['ip'], mnode['port'], mnode['device'], part,
143+ urllib.quote(target))
144+print "\n"
145+for node in nodes:
146+ print 'ssh %s "ls -lah /srv/node/%s/%s/%s/%s/%s/"' \
147+ % (node['ip'], loc, node['device'], part, hash_str[-3:], hash_str)
148+for mnode in more_nodes:
149+ print 'ssh %s "ls -lah /srv/node/%s/%s/%s/%s/%s/" # [Handoff]' \
150+ % (mnode['ip'], loc, mnode['device'], part, hash_str[-3:], hash_str)