Created
May 29, 2012 12:42
-
-
Save CrackerJackMack/2828189 to your computer and use it in GitHub Desktop.
SoftLayer object storage recursive container deletion
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 object_storage | |
def get_objects(container): | |
f = container.objects() | |
objlist = list() | |
while True: | |
objlist = objlist + f | |
try: | |
f = container.objects(marker=f[-1].name) | |
except Exception: | |
break | |
def delete_container(container): | |
obj = get_objects(container) | |
for o in obj: | |
d = container.storage_object(o.name) | |
d.delete() | |
container.delete() | |
if __name__ == "__main__": | |
storage = object_storage.get_client('USER', 'APIKEY') | |
delete_container(storage['CONTAINER']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment