Created
January 3, 2018 20:06
-
-
Save clayg/fd127be1c3394a036d59fab418198109 to your computer and use it in GitHub Desktop.
this will list expired objects from the .expiring_objects account in a format that you can feed to swift-integrity do_delete
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 | |
import time | |
import urllib | |
from swift.common.internal_client import InternalClient | |
from swift.container.sync import ic_conf_body | |
from swift.common.wsgi import ConfigString | |
from swift.common.utils import split_path | |
def main(): | |
now = time.time() | |
expiring_account = '.expiring_objects' | |
swift = InternalClient(ConfigString(ic_conf_body), 'test', 1) | |
for container_item in swift.iter_containers(expiring_account): | |
container = container_item['name'] | |
if int(container) > now: | |
break | |
for item in swift.iter_objects(expiring_account, container): | |
obj = item['name'] | |
ts, path = obj.split('-', 1) | |
if int(ts) > now: | |
break | |
a, c, o = split_path('/' + path, 1, 3, True) | |
print ' '.join(( | |
urllib.quote(a.encode('utf8')), | |
urllib.quote(c.encode('utf8')), | |
urllib.quote(o.encode('utf8')))) | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment