Skip to content

Instantly share code, notes, and snippets.

@clayg
Created September 2, 2016 08:51
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 clayg/590caf4c5b650af950add2aab3943e36 to your computer and use it in GitHub Desktop.
Save clayg/590caf4c5b650af950add2aab3943e36 to your computer and use it in GitHub Desktop.
import sys
from swift.common.ring import Ring
from swift.common.utils import hash_path
account = 'AUTH_test'
container = 'test'
obj_template = 'obj%x'
def main():
try:
ring_filename = sys.argv[1]
except IndexError:
return 'USAGE: %s </path/to/ring.gz>' % sys.argv[0]
r = Ring(ring_filename)
names = {}
# I don't think it can take more than this, maybe half of this
# really, should be enough tho... pretty sure, this is a lot
attempts = int(r.partition_count * 0xfff)
for i in range(attempts):
obj = obj_template % i
part = r.get_part(account, container, obj)
suffix = hash_path(account, container, obj)[-3:]
key = (part, suffix)
if key in names:
break
names[key] = obj
print key, names[key], obj
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment