def purge_prefix_vaults(): conn = GlacierTestsConfig().connection() all_vaults = conn.list_vaults() jobs = {} for vault in all_vaults['VaultList']: if vault['VaultName'].startswith(GlacierTestsConfig().prefix()): # Try to delete and only schedule an inventory job if delete fails try: print 'delete vault %s' % vault['VaultName'] conn.delete_vault(vault['VaultName']) except Exception as e: print 'delete failed %s' % str(e) jobs[vault['VaultName']] = enumerate_vault(vault['VaultName'], conn) while jobs: remaining = {} while jobs: vault, job_id = jobs.popitem() status = conn.describe_job(vault, job_id) if status['Completed'] == 'false': print 'Waiting for: %s' % job_id remaining[vault] = job_id continue resp = None try: resp = conn.get_job_output(vault, job_id) except Exception as e: print "Error: %s" % str(e) remaining[vault] = job_id continue for archive in resp['ArchiveList']: conn.delete_archive(vault, archive['ArchiveId']) jobs = remaining if jobs: time.sleep(10)
def test_archive_delete(): conn = GlacierTestsConfig().connection() vault = Util.get_new_vault() vault_name = vault['Location'].split('/')[-1] archive = Util.upload_archive(vault_name, b"hello", None) ok_('ArchiveId' in archive) archive_id = archive['ArchiveId'] conn.delete_archive(vault_name, archive_id)