Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CrackerJackMack/2828189 to your computer and use it in GitHub Desktop.
Save CrackerJackMack/2828189 to your computer and use it in GitHub Desktop.
SoftLayer object storage recursive container deletion
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