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
=== modified file 'bin/swift-get-nodes'
--- bin/swift-get-nodes 2010-09-14 06:51:20 +0000
+++ bin/swift-get-nodes 2010-09-16 14:11:43 +0000
@@ -40,99 +40,55 @@
40container = None40container = None
41obj = None41obj = None
4242
43if len(sys.argv) > 4: ring,account,container,obj = sys.argv[1:5]43if len(sys.argv) > 4:
44elif len(sys.argv) > 3: ring,account,container = sys.argv[1:4]44 # Acount, Container and Object
45elif len(sys.argv) > 2: ring,account = sys.argv[1:3]45 ring, account, container, obj = sys.argv[1:5]
46 hash_str = hash_path(account, container, obj)
47 part, nodes = Ring(ring).get_nodes(account, container, obj)
48 target = "%s/%s/%s" % (account, container, obj)
49 loc = 'object'
50elif len(sys.argv) > 3:
51 # Account, Container
52 ring, account, container = sys.argv[1:4]
53 hash_str = hash_path(account, container)
54 part, nodes = Ring(ring).get_nodes(account, container)
55 target = "%s/%s" % (account, container)
56 loc = 'container'
57elif len(sys.argv) > 2:
58 # Account
59 ring, account = sys.argv[1:3]
60 hash_str = hash_path(account)
61 part, nodes = Ring(ring).get_nodes(account)
62 target = "%s" % (account)
63 loc = 'account'
64
65more_nodes = list(Ring(ring).get_more_nodes(part))
4666
47print '\nAccount \t%s' % account67print '\nAccount \t%s' % account
48print 'Container\t%s' % container68print 'Container\t%s' % container
49print 'Object \t%s\n' % obj69print 'Object \t%s\n' % obj
70print '\nPartition\t%s' % part
71print 'Hash \t%s\n' % hash_str
5072
51if obj:73for node in nodes:
52 hash_str = hash_path(account,container,obj)74 print 'Server:Port Device\t%s:%s %s' % (node['ip'], node['port'],
53 part, nodes = Ring(ring).get_nodes(account,container,obj)75 node['device'])
54 more_nodes = Ring(ring).get_more_nodes(part)76for mnode in more_nodes:
55 print '\nPartition\t%s' % part77 print 'Server:Port Device\t%s:%s %s\t [Handoff]' \
56 print 'Hash \t%s\n' % hash_str78 % (mnode['ip'], mnode['port'], mnode['device'])
57 for node in nodes:79print "\n"
58 print 'Server:Port Device\t%s:%s %s' % (node['ip'], node['port'], node['device'])80for node in nodes:
59 for mnode in more_nodes:81 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
60 print 'Server:Port Device\t%s:%s %s\t [Handoff]' \82 % (node['ip'], node['port'], node['device'], part,
61 % (node['ip'], node['port'], node['device'])83 urllib.quote(target))
62 print "\n"84for mnode in more_nodes:
63 more_nodes = Ring(ring).get_more_nodes(part)85 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \
64 for node in nodes:86 % (mnode['ip'], mnode['port'], mnode['device'], part,
65 acct_cont_obj = "%s/%s/%s" % (account, container, obj)87 urllib.quote(target))
66 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \88print "\n"
67 % (node['ip'],node['port'],node['device'],part,urllib.quote(acct_cont_obj))89for node in nodes:
68 for mnode in more_nodes:90 print 'ssh %s "ls -lah /srv/node/%s/%s/%s/%s/%s/"' \
69 acct_cont_obj = "%s/%s/%s" % (account, container, obj)91 % (node['ip'], loc, node['device'], part, hash_str[-3:], hash_str)
70 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \92for mnode in more_nodes:
71 % (mnode['ip'],mnode['port'],mnode['device'],part,urllib.quote(acct_cont_obj))93 print 'ssh %s "ls -lah /srv/node/%s/%s/%s/%s/%s/" # [Handoff]' \
72 print "\n"94 % (mnode['ip'], loc, mnode['device'], part, hash_str[-3:], hash_str)
73 more_nodes = Ring(ring).get_more_nodes(part)
74 for node in nodes:
75 print 'ssh %s "ls -lah /srv/node/%s/objects/%s/%s/%s/"' \
76 % (node['ip'],node['device'],part,hash_str[-3:],hash_str)
77 for mnode in more_nodes:
78 print 'ssh %s "ls -lah /srv/node/%s/objects/%s/%s/%s/" # [Handoff]' \
79 % (mnode['ip'],mnode['device'],part,hash_str[-3:],hash_str)
80elif container:
81 hash_str = hash_path(account,container)
82 part, nodes = Ring(ring).get_nodes(account,container)
83 more_nodes = Ring(ring).get_more_nodes(part)
84 print '\nPartition %s' % part
85 print 'Hash %s\n' % hash_str
86 for node in nodes:
87 print 'Server:Port Device\t%s:%s %s' \
88 % (node['ip'], node['port'], node['device'])
89 for mnode in more_nodes:
90 print 'Server:Port Device\t%s:%s %s\t [Handoff]' \
91 % (mnode['ip'], mnode['port'], mnode['device'])
92 print "\n"
93 more_nodes = Ring(ring).get_more_nodes(part)
94 for node in nodes:
95 acct_cont = "%s/%s" % (account,container)
96 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
97 % (node['ip'],node['port'],node['device'],part,urllib.quote(acct_cont))
98 for mnode in more_nodes:
99 acct_cont = "%s/%s" % (account,container)
100 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \
101 % (mnode['ip'],mnode['port'],mnode['device'],part,urllib.quote(acct_cont))
102 print "\n"
103 more_nodes = Ring(ring).get_more_nodes(part)
104 for node in nodes:
105 print 'ssh %s "ls -lah /srv/node/%s/containers/%s/%s/%s/%s.db"' \
106 % (node['ip'],node['device'],part,hash_str[-3:],hash_str,hash_str)
107 for mnode in more_nodes:
108 print 'ssh %s "ls -lah /srv/node/%s/containers/%s/%s/%s/%s.db" # [Handoff]' \
109 % (mnode['ip'],mnode['device'],part,hash_str[-3:],hash_str,hash_str)
110elif account:
111 hash_str = hash_path(account)
112 part, nodes = Ring(ring).get_nodes(account)
113 more_nodes = Ring(ring).get_more_nodes(part)
114 print '\nPartition %s' % part
115 print 'Hash %s\n' % hash_str
116 for node in nodes:
117 print 'Server:Port Device\t%s:%s %s' \
118 % (node['ip'], node['port'], node['device'])
119 for mnode in more_nodes:
120 print 'Server:Port Device\t%s:%s %s\t [Handoff]' \
121 % (mnode['ip'], mnode['port'], mnode['device'])
122 print "\n"
123 for node in nodes:
124 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
125 % (node['ip'],node['port'],node['device'],part, urllib.quote(account))
126 more_nodes = Ring(ring).get_more_nodes(part)
127 for mnode in more_nodes:
128 print 'curl -I -XHEAD "http://%s:%s/%s/%s/%s" # [Handoff]' \
129 % (mnode['ip'],mnode['port'],mnode['device'],part, urllib.quote(account))
130 print "\n"
131 for node in nodes:
132 print 'ssh %s "ls -lah /srv/node/%s/accounts/%s/%s/%s/%s.db"' \
133 % (node['ip'],node['device'],part,hash_str[-3:],hash_str,hash_str)
134 more_nodes = Ring(ring).get_more_nodes(part)
135 for mnode in more_nodes:
136 print 'ssh %s "ls -lah /srv/node/%s/accounts/%s/%s/%s/%s.db" # [Handoff]' \
137 % (mnode['ip'],mnode['device'],part,hash_str[-3:],hash_str,hash_str)
138 print "\n\n"