Created
September 2, 2016 08:51
-
-
Save clayg/590caf4c5b650af950add2aab3943e36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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